Skip to content

Commit 99b5262

Browse files
authored
Remove unnecessary null checks in dev/tools (#118845)
1 parent 98c18ca commit 99b5262

File tree

7 files changed

+9
-31
lines changed

7 files changed

+9
-31
lines changed

dev/tools/dartdoc.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,6 @@ Iterable<String> libraryRefs() sync* {
581581
}
582582

583583
void printStream(Stream<List<int>> stream, { String prefix = '', List<Pattern> filter = const <Pattern>[] }) {
584-
assert(prefix != null);
585-
assert(filter != null);
586584
stream
587585
.transform<String>(utf8.decoder)
588586
.transform<String>(const LineSplitter())

dev/tools/gen_keycodes/lib/android_code_gen.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ class AndroidCodeGenerator extends PlatformCodeGenerator {
3131
String get _androidScanCodeMap {
3232
final StringBuffer androidScanCodeMap = StringBuffer();
3333
for (final PhysicalKeyEntry entry in keyData.entries) {
34-
if (entry.androidScanCodes != null) {
35-
for (final int code in entry.androidScanCodes.cast<int>()) {
36-
androidScanCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}');
37-
}
34+
for (final int code in entry.androidScanCodes.cast<int>()) {
35+
androidScanCodeMap.writeln(' put(${toHex(code, digits: 10)}L, ${toHex(entry.usbHidCode, digits: 10)}L); // ${entry.constantName}');
3836
}
3937
}
4038
return androidScanCodeMap.toString().trimRight();

dev/tools/gen_keycodes/lib/keyboard_maps_code_gen.dart

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,8 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
144144
String get _androidScanCodeMap {
145145
final OutputLines<int> lines = OutputLines<int>('Android scancode map');
146146
for (final PhysicalKeyEntry entry in keyData.entries) {
147-
if (entry.androidScanCodes != null) {
148-
for (final int code in entry.androidScanCodes) {
149-
lines.add(code, ' $code: PhysicalKeyboardKey.${entry.constantName},');
150-
}
147+
for (final int code in entry.androidScanCodes) {
148+
lines.add(code, ' $code: PhysicalKeyboardKey.${entry.constantName},');
151149
}
152150
}
153151
return lines.sortedJoin().trimRight();
@@ -296,9 +294,7 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
296294
String get _fuchsiaHidCodeMap {
297295
final StringBuffer fuchsiaScanCodeMap = StringBuffer();
298296
for (final PhysicalKeyEntry entry in keyData.entries) {
299-
if (entry.usbHidCode != null) {
300-
fuchsiaScanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: PhysicalKeyboardKey.${entry.constantName},');
301-
}
297+
fuchsiaScanCodeMap.writeln(' ${toHex(entry.usbHidCode)}: PhysicalKeyboardKey.${entry.constantName},');
302298
}
303299
return fuchsiaScanCodeMap.toString().trimRight();
304300
}
@@ -328,9 +324,7 @@ class KeyboardMapsCodeGenerator extends BaseCodeGenerator {
328324
String get _webNumpadMap {
329325
final OutputLines<String> lines = OutputLines<String>('Web numpad map');
330326
for (final LogicalKeyEntry entry in _numpadLogicalKeyData) {
331-
if (entry.name != null) {
332-
lines.add(entry.name, " '${entry.name}': LogicalKeyboardKey.${entry.constantName},");
333-
}
327+
lines.add(entry.name, " '${entry.name}': LogicalKeyboardKey.${entry.constantName},");
334328
}
335329
return lines.sortedJoin().trimRight();
336330
}

dev/tools/gen_keycodes/lib/utils.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ String wrapString(String input, {required String prefix}) {
153153
///
154154
/// An null list is considered a list with length 0.
155155
void zipStrict<T1, T2>(Iterable<T1> list1, Iterable<T2> list2, void Function(T1, T2) fn) {
156-
if (list1 == null && list2 == null) {
157-
return;
158-
}
159156
assert(list1.length == list2.length);
160157
final Iterator<T1> it1 = list1.iterator;
161158
final Iterator<T2> it2 = list2.iterator;

dev/tools/localization/bin/gen_localizations.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,8 @@ String generateArbBasedLocalizationSubclasses({
7171
required String supportedLanguagesConstant,
7272
required String supportedLanguagesDocMacro,
7373
}) {
74-
assert(localeToResources != null);
75-
assert(localeToResourceAttributes != null);
7674
assert(generatedClassPrefix.isNotEmpty);
7775
assert(baseClass.isNotEmpty);
78-
assert(generateHeader != null);
79-
assert(generateConstructor != null);
8076
assert(factoryName.isNotEmpty);
8177
assert(factoryDeclaration.isNotEmpty);
8278
assert(factoryArguments.isNotEmpty);

dev/tools/localization/localizations_utils.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LocaleInfo implements Comparable<LocaleInfo> {
5151
scriptCode = codes[1].length > codes[2].length ? codes[1] : codes[2];
5252
countryCode = codes[1].length < codes[2].length ? codes[1] : codes[2];
5353
}
54-
assert(codes[0] != null && codes[0].isNotEmpty);
54+
assert(codes[0].isNotEmpty);
5555
assert(countryCode == null || countryCode.isNotEmpty);
5656
assert(scriptCode == null || scriptCode.isNotEmpty);
5757

@@ -151,10 +151,6 @@ void loadMatchingArbsIntoBundleMaps({
151151
required Map<LocaleInfo, Map<String, String>> localeToResources,
152152
required Map<LocaleInfo, Map<String, dynamic>> localeToResourceAttributes,
153153
}) {
154-
assert(directory != null);
155-
assert(filenamePattern != null);
156-
assert(localeToResources != null);
157-
assert(localeToResourceAttributes != null);
158154

159155
/// Set that holds the locales that were assumed from the existing locales.
160156
///
@@ -214,7 +210,6 @@ void loadMatchingArbsIntoBundleMaps({
214210
}
215211

216212
void exitWithError(String errorMessage) {
217-
assert(errorMessage != null);
218213
stderr.writeln('fatal: $errorMessage');
219214
exit(1);
220215
}

dev/tools/vitool/test/vitool_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ class PathMatcher extends Matcher {
614614

615615
@override
616616
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
617-
if (item == null || actual == null) {
617+
if (item == null) {
618618
return item == actual;
619619
}
620620

@@ -666,7 +666,7 @@ class PathAnimationMatcher extends Matcher {
666666

667667
@override
668668
bool matches(dynamic item, Map<dynamic, dynamic> matchState) {
669-
if (item == null || expected == null) {
669+
if (item == null) {
670670
return item == expected;
671671
}
672672

0 commit comments

Comments
 (0)