Unverified Commit 99b5262b authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Remove unnecessary null checks in dev/tools (#118845)

parent 98c18ca9
...@@ -581,8 +581,6 @@ Iterable<String> libraryRefs() sync* { ...@@ -581,8 +581,6 @@ Iterable<String> libraryRefs() sync* {
} }
void printStream(Stream<List<int>> stream, { String prefix = '', List<Pattern> filter = const <Pattern>[] }) { void printStream(Stream<List<int>> stream, { String prefix = '', List<Pattern> filter = const <Pattern>[] }) {
assert(prefix != null);
assert(filter != null);
stream stream
.transform<String>(utf8.decoder) .transform<String>(utf8.decoder)
.transform<String>(const LineSplitter()) .transform<String>(const LineSplitter())
......
...@@ -31,12 +31,10 @@ class AndroidCodeGenerator extends PlatformCodeGenerator { ...@@ -31,12 +31,10 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
String get _androidScanCodeMap { String get _androidScanCodeMap {
final StringBuffer androidScanCodeMap = StringBuffer(); final StringBuffer androidScanCodeMap = StringBuffer();
for (final PhysicalKeyEntry entry in keyData.entries) { for (final PhysicalKeyEntry entry in keyData.entries) {
if (entry.androidScanCodes != null) {
for (final int code in entry.androidScanCodes.cast<int>()) { for (final int code in entry.androidScanCodes.cast<int>()) {
androidScanCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}'); androidScanCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}');
} }
} }
}
return androidScanCodeMap.toString().trimRight(); return androidScanCodeMap.toString().trimRight();
} }
......
...@@ -144,12 +144,10 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator { ...@@ -144,12 +144,10 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
String get _androidScanCodeMap { String get _androidScanCodeMap {
final OutputLines<int> lines = OutputLines<int>('Android scancode map'); final OutputLines<int> lines = OutputLines<int>('Android scancode map');
for (final PhysicalKeyEntry entry in keyData.entries) { for (final PhysicalKeyEntry entry in keyData.entries) {
if (entry.androidScanCodes != null) {
for (final int code in entry.androidScanCodes) { for (final int code in entry.androidScanCodes) {
lines.add(code, ' $code: PhysicalKeyboardKey.${entry.constantName},'); lines.add(code, ' $code: PhysicalKeyboardKey.${entry.constantName},');
} }
} }
}
return lines.sortedJoin().trimRight(); return lines.sortedJoin().trimRight();
} }
...@@ -296,10 +294,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator { ...@@ -296,10 +294,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
String get _fuchsiaHidCodeMap { String get _fuchsiaHidCodeMap {
final StringBuffer fuchsiaScanCodeMap = StringBuffer(); final StringBuffer fuchsiaScanCodeMap = StringBuffer();
for (final PhysicalKeyEntry entry in keyData.entries) { for (final PhysicalKeyEntry entry in keyData.entries) {
if (entry.usbHidCode != null) {
fuchsiaScanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: PhysicalKeyboardKey.${entry.constantName},'); fuchsiaScanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: PhysicalKeyboardKey.${entry.constantName},');
} }
}
return fuchsiaScanCodeMap.toString().trimRight(); return fuchsiaScanCodeMap.toString().trimRight();
} }
...@@ -328,10 +324,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator { ...@@ -328,10 +324,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
String get _webNumpadMap { String get _webNumpadMap {
final OutputLines<String> lines = OutputLines<String>('Web numpad map'); final OutputLines<String> lines = OutputLines<String>('Web numpad map');
for (final LogicalKeyEntry entry in _numpadLogicalKeyData) { for (final LogicalKeyEntry entry in _numpadLogicalKeyData) {
if (entry.name != null) {
lines.add(entry.name, " '${entry.name}': LogicalKeyboardKey.${entry.constantName},"); lines.add(entry.name, " '${entry.name}': LogicalKeyboardKey.${entry.constantName},");
} }
}
return lines.sortedJoin().trimRight(); return lines.sortedJoin().trimRight();
} }
......
...@@ -153,9 +153,6 @@ String wrapString(String input, {required String prefix}) { ...@@ -153,9 +153,6 @@ String wrapString(String input, {required String prefix}) {
/// ///
/// An null list is considered a list with length 0. /// An null list is considered a list with length 0.
void zipStrict<T1, T2>(Iterable<T1> list1, Iterable<T2> list2, void Function(T1, T2) fn) { void zipStrict<T1, T2>(Iterable<T1> list1, Iterable<T2> list2, void Function(T1, T2) fn) {
if (list1 == null && list2 == null) {
return;
}
assert(list1.length == list2.length); assert(list1.length == list2.length);
final Iterator<T1> it1 = list1.iterator; final Iterator<T1> it1 = list1.iterator;
final Iterator<T2> it2 = list2.iterator; final Iterator<T2> it2 = list2.iterator;
......
...@@ -71,12 +71,8 @@ String generateArbBasedLocalizationSubclasses({ ...@@ -71,12 +71,8 @@ String generateArbBasedLocalizationSubclasses({
required String supportedLanguagesConstant, required String supportedLanguagesConstant,
required String supportedLanguagesDocMacro, required String supportedLanguagesDocMacro,
}) { }) {
assert(localeToResources != null);
assert(localeToResourceAttributes != null);
assert(generatedClassPrefix.isNotEmpty); assert(generatedClassPrefix.isNotEmpty);
assert(baseClass.isNotEmpty); assert(baseClass.isNotEmpty);
assert(generateHeader != null);
assert(generateConstructor != null);
assert(factoryName.isNotEmpty); assert(factoryName.isNotEmpty);
assert(factoryDeclaration.isNotEmpty); assert(factoryDeclaration.isNotEmpty);
assert(factoryArguments.isNotEmpty); assert(factoryArguments.isNotEmpty);
......
...@@ -51,7 +51,7 @@ class LocaleInfo implements Comparable<LocaleInfo> { ...@@ -51,7 +51,7 @@ class LocaleInfo implements Comparable<LocaleInfo> {
scriptCode = codes[1].length > codes[2].length ? codes[1] : codes[2]; scriptCode = codes[1].length > codes[2].length ? codes[1] : codes[2];
countryCode = codes[1].length < codes[2].length ? codes[1] : codes[2]; countryCode = codes[1].length < codes[2].length ? codes[1] : codes[2];
} }
assert(codes[0] != null && codes[0].isNotEmpty); assert(codes[0].isNotEmpty);
assert(countryCode == null || countryCode.isNotEmpty); assert(countryCode == null || countryCode.isNotEmpty);
assert(scriptCode == null || scriptCode.isNotEmpty); assert(scriptCode == null || scriptCode.isNotEmpty);
...@@ -151,10 +151,6 @@ void loadMatchingArbsIntoBundleMaps({ ...@@ -151,10 +151,6 @@ void loadMatchingArbsIntoBundleMaps({
required Map<LocaleInfo, Map<String, String>> localeToResources, required Map<LocaleInfo, Map<String, String>> localeToResources,
required Map<LocaleInfo, Map<String, dynamic>> localeToResourceAttributes, required Map<LocaleInfo, Map<String, dynamic>> localeToResourceAttributes,
}) { }) {
assert(directory != null);
assert(filenamePattern != null);
assert(localeToResources != null);
assert(localeToResourceAttributes != null);
/// Set that holds the locales that were assumed from the existing locales. /// Set that holds the locales that were assumed from the existing locales.
/// ///
...@@ -214,7 +210,6 @@ void loadMatchingArbsIntoBundleMaps({ ...@@ -214,7 +210,6 @@ void loadMatchingArbsIntoBundleMaps({
} }
void exitWithError(String errorMessage) { void exitWithError(String errorMessage) {
assert(errorMessage != null);
stderr.writeln('fatal: $errorMessage'); stderr.writeln('fatal: $errorMessage');
exit(1); exit(1);
} }
......
...@@ -614,7 +614,7 @@ class PathMatcher extends Matcher { ...@@ -614,7 +614,7 @@ class PathMatcher extends Matcher {
@override @override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) { bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item == null || actual == null) { if (item == null) {
return item == actual; return item == actual;
} }
...@@ -666,7 +666,7 @@ class PathAnimationMatcher extends Matcher { ...@@ -666,7 +666,7 @@ class PathAnimationMatcher extends Matcher {
@override @override
bool matches(dynamic item, Map<dynamic, dynamic> matchState) { bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
if (item == null || expected == null) { if (item == null) {
return item == expected; return item == expected;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment