From c757df3bfae22fa510f3362b4de9bf12b72a3700 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Fri, 20 Jan 2023 17:39:19 -0800 Subject: [PATCH] Remove unnecessary null checks in dev/bots (#118846) --- dev/bots/analyze.dart | 3 --- dev/bots/analyze_snippet_code.dart | 2 +- dev/bots/prepare_package.dart | 4 +--- dev/bots/test.dart | 2 +- dev/bots/unpublish_package.dart | 13 +++---------- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 3e098cb4ea00..055da52b1ef1 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -597,7 +597,6 @@ Future verifyDeprecations(String workingDirectory, { int minimumMatches = } String _generateLicense(String prefix) { - assert(prefix != null); return '${prefix}Copyright 2014 The Flutter Authors. All rights reserved.\n' '${prefix}Use of this source code is governed by a BSD-style license that can be\n' '${prefix}found in the LICENSE file.'; @@ -1576,8 +1575,6 @@ Future verifyNoBinaries(String workingDirectory, { Set? legacyBin // UTILITY FUNCTIONS bool _listEquals(List a, List b) { - assert(a != null); - assert(b != null); if (a.length != b.length) { return false; } diff --git a/dev/bots/analyze_snippet_code.dart b/dev/bots/analyze_snippet_code.dart index 63050dbb9d07..bc2cb99add2a 100644 --- a/dev/bots/analyze_snippet_code.dart +++ b/dev/bots/analyze_snippet_code.dart @@ -924,7 +924,7 @@ class _SnippetChecker { continue; } - final _SnippetFile snippet = snippets[file.path]!; + final _SnippetFile? snippet = snippets[file.path]; if (snippet == null) { errors.add(_SnippetCheckerException( "Unknown section for ${file.path}. Maybe the temporary directory wasn't empty?", diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index 5878f8e75301..3222ca269262 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -41,9 +41,7 @@ class PreparePackageException implements Exception { @override String toString() { String output = runtimeType.toString(); - if (message != null) { - output += ': $message'; - } + output += ': $message'; final String stderr = result?.stderr as String? ?? ''; if (stderr.isNotEmpty) { output += ':\n$stderr'; diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 48ad19c23fc5..17cf7e2a808d 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -1018,7 +1018,7 @@ Future _runFrameworkTests() async { printOutput: false, outputChecker: (CommandResult result) { final Iterable matches = httpClientWarning.allMatches(result.flattenedStdout!); - if (matches == null || matches.isEmpty || matches.length > 1) { + if (matches.isEmpty || matches.length > 1) { return 'Failed to print warning about HttpClientUsage, or printed it too many times.\n\n' 'stdout:\n${result.flattenedStdout}\n\n' 'stderr:\n${result.flattenedStderr}'; diff --git a/dev/bots/unpublish_package.dart b/dev/bots/unpublish_package.dart index fd8f60bd7f73..d614dc9b025f 100644 --- a/dev/bots/unpublish_package.dart +++ b/dev/bots/unpublish_package.dart @@ -37,9 +37,7 @@ class UnpublishException implements Exception { @override String toString() { String output = runtimeType.toString(); - if (message != null) { - output += ': $message'; - } + output += ': $message'; final String stderr = result?.stderr as String? ?? ''; if (stderr.isNotEmpty) { output += ':\n$stderr'; @@ -113,9 +111,7 @@ class ProcessRunner { this.subprocessOutput = true, this.defaultWorkingDirectory, this.platform = const LocalPlatform(), - }) : assert(subprocessOutput != null), - assert(processManager != null), - assert(platform != null) { + }) { environment = Map.from(platform.environment); } @@ -255,9 +251,6 @@ class ArchiveUnpublisher { continue; } final Map replacementRelease = releases.firstWhere((Map value) => value['channel'] == getChannelName(channel)); - if (replacementRelease == null) { - throw UnpublishException('Unable to find previous release for channel ${getChannelName(channel)}.'); - } (jsonData['current_release'] as Map)[getChannelName(channel)] = replacementRelease['hash']; print( '${confirmed ? 'Reverting' : 'Would revert'} current ${getChannelName(channel)} ' @@ -468,7 +461,7 @@ Future main(List rawArguments) async { final String tempDirArg = parsedArguments['temp_dir'] as String; Directory tempDir; bool removeTempDir = false; - if (tempDirArg == null || tempDirArg.isEmpty) { + if (tempDirArg.isEmpty) { tempDir = Directory.systemTemp.createTempSync('flutter_package.'); removeTempDir = true; } else {