From ef6840b65f3a0f5cec251c2a8af9b0caad2027d3 Mon Sep 17 00:00:00 2001 From: Michael Goderbauer Date: Wed, 1 Aug 2018 11:41:47 -0700 Subject: [PATCH] Update license script & analyze it on CI (flutter/engine#5917) --- ....analysis_options => analysis_options.yaml} | 8 ++++---- .../flutter/tools/licenses/lib/filesystem.dart | 8 ++++---- .../flutter/tools/licenses/lib/licenses.dart | 8 ++++---- .../src/flutter/tools/licenses/lib/main.dart | 18 +++++++++--------- 4 files changed, 21 insertions(+), 21 deletions(-) rename engine/src/flutter/tools/licenses/{.analysis_options => analysis_options.yaml} (87%) diff --git a/engine/src/flutter/tools/licenses/.analysis_options b/engine/src/flutter/tools/licenses/analysis_options.yaml similarity index 87% rename from engine/src/flutter/tools/licenses/.analysis_options rename to engine/src/flutter/tools/licenses/analysis_options.yaml index b228617a19..44a679430a 100644 --- a/engine/src/flutter/tools/licenses/.analysis_options +++ b/engine/src/flutter/tools/licenses/analysis_options.yaml @@ -2,9 +2,9 @@ analyzer: language: - enableStrictCallChecks: true enableSuperMixins: true - strong-mode: true + strong-mode: + implicit-dynamic: false errors: strong_mode_invalid_field_override: ignore strong_mode_down_cast_composite: ignore @@ -19,7 +19,7 @@ linter: - control_flow_in_finally - empty_statements - hash_and_equals - - invariant_booleans + # - invariant_booleans # Produces false positives, see https://github.com/flutter/flutter/issues/5790 - iterable_contains_unrelated_type - list_remove_unrelated_type - literal_only_boolean_expressions @@ -53,6 +53,6 @@ linter: - type_annotate_public_apis - type_init_formals - unawaited_futures - - unnecessary_brace_in_string_interp + - unnecessary_brace_in_string_interps - unnecessary_getters_setters - package_names diff --git a/engine/src/flutter/tools/licenses/lib/filesystem.dart b/engine/src/flutter/tools/licenses/lib/filesystem.dart index 67137a8614..be9a1f7161 100644 --- a/engine/src/flutter/tools/licenses/lib/filesystem.dart +++ b/engine/src/flutter/tools/licenses/lib/filesystem.dart @@ -59,7 +59,7 @@ const String kMultiLicenseFileHeader = 'Notices for files contained in'; bool isMultiLicenseNotice(Reader reader) { List bytes = reader(); - return (ASCII.decode(bytes.take(kMultiLicenseFileHeader.length).toList(), allowInvalid: true) == kMultiLicenseFileHeader); + return (ascii.decode(bytes.take(kMultiLicenseFileHeader.length).toList(), allowInvalid: true) == kMultiLicenseFileHeader); } FileType identifyFile(String name, Reader reader) { @@ -314,7 +314,7 @@ abstract class UTF8TextFile extends TextFile { @override String readString() { try { - return cache(new UTF8Of(this), () => UTF8.decode(readBytes())); + return cache(new UTF8Of(this), () => utf8.decode(readBytes())); } on FormatException { print(fullName); rethrow; @@ -332,13 +332,13 @@ abstract class Latin1TextFile extends TextFile { throw '$fullName contains a U+0000 NULL and is probably not actually encoded as Win1252'; bool isUTF8 = false; try { - cache(new UTF8Of(this), () => UTF8.decode(readBytes())); + cache(new UTF8Of(this), () => utf8.decode(readBytes())); isUTF8 = true; } on FormatException { } if (isUTF8) throw '$fullName contains valid UTF-8 and is probably not actually encoded as Win1252'; - return LATIN1.decode(bytes); + return latin1.decode(bytes); }); } } diff --git a/engine/src/flutter/tools/licenses/lib/licenses.dart b/engine/src/flutter/tools/licenses/lib/licenses.dart index e38b2dfd56..dc457411d6 100644 --- a/engine/src/flutter/tools/licenses/lib/licenses.dart +++ b/engine/src/flutter/tools/licenses/lib/licenses.dart @@ -325,19 +325,19 @@ abstract class License implements Comparable { bool isUTF8 = true; List latin1Encoded; try { - latin1Encoded = LATIN1.encode(body); + latin1Encoded = latin1.encode(body); isUTF8 = false; } on ArgumentError { } if (!isUTF8) { bool isAscii = false; try { - ASCII.decode(latin1Encoded); + ascii.decode(latin1Encoded); isAscii = true; } on FormatException { } if (isAscii) return; try { - UTF8.decode(latin1Encoded); + utf8.decode(latin1Encoded); isUTF8 = true; } on FormatException { } if (isUTF8) @@ -530,7 +530,7 @@ _SplitLicense _splitLicense(String body, { bool verifyResults: true }) { if (!lines.moveNext()) throw 'tried to split empty license'; int end = 0; - while (true) { + while (true) { // ignore: literal_only_boolean_expressions final String line = lines.current.value; if (line == 'Author:' || line == 'This code is derived from software contributed to Berkeley by' || diff --git a/engine/src/flutter/tools/licenses/lib/main.dart b/engine/src/flutter/tools/licenses/lib/main.dart index 06ea43faeb..309f899b2c 100644 --- a/engine/src/flutter/tools/licenses/lib/main.dart +++ b/engine/src/flutter/tools/licenses/lib/main.dart @@ -736,33 +736,33 @@ class RepositoryMultiLicenseNoticesForFilesFile extends RepositoryLicenseFile { // "Notices for files contained in the" // ...then have a second line which is 60 "=" characters final List> contents = splitIntList(io.readBytes(), 0x0A).toList(); - if (!ASCII.decode(contents[0]).startsWith('Notices for files contained in') || - ASCII.decode(contents[1]) != '============================================================\n') + if (!ascii.decode(contents[0]).startsWith('Notices for files contained in') || + ascii.decode(contents[1]) != '============================================================\n') throw 'unrecognised syntax: ${io.fullName}'; int index = 2; while (index < contents.length) { - if (ASCII.decode(contents[index]) != 'Notices for file(s):\n') + if (ascii.decode(contents[index]) != 'Notices for file(s):\n') throw 'unrecognised syntax on line ${index + 1}: ${io.fullName}'; index += 1; final List names = []; do { - names.add(ASCII.decode(contents[index])); + names.add(ascii.decode(contents[index])); index += 1; - } while (ASCII.decode(contents[index]) != '------------------------------------------------------------\n'); + } while (ascii.decode(contents[index]) != '------------------------------------------------------------\n'); index += 1; final List> body = >[]; do { body.add(contents[index]); index += 1; } while (index < contents.length && - ASCII.decode(contents[index], allowInvalid: true) != '============================================================\n'); + ascii.decode(contents[index], allowInvalid: true) != '============================================================\n'); index += 1; final List bodyBytes = body.expand((List line) => line).toList(); String bodyText; try { - bodyText = UTF8.decode(bodyBytes); + bodyText = utf8.decode(bodyBytes); } on FormatException { - bodyText = LATIN1.decode(bodyBytes); + bodyText = latin1.decode(bodyBytes); } License license = new License.unique(bodyText, LicenseType.unknown, origin: io.fullName); for (String name in names) { @@ -2545,7 +2545,7 @@ Future main(List arguments) async { system.File goldenFile = new system.File( path.join(argResults['golden'], 'licenses_${component.io.name}')); String goldenSignature = await goldenFile.openRead() - .transform(UTF8.decoder).transform(new LineSplitter()).first; + .transform(utf8.decoder).transform(new LineSplitter()).first; Match goldenMatch = signaturePattern.matchAsPrefix(goldenSignature); if (goldenMatch != null && goldenMatch.group(1) == signature) { system.stderr.writeln(' Skipping this component - no change in signature');