From f292b20dfd1872a0302e9e041b03d154992a1021 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Tue, 23 May 2023 14:01:49 +0000 Subject: [PATCH] Replace deprecated lint rules in front-end packages Two rules, `iterable_contains_unrelated_type` and `list_remove_unrelated_type` are deprecated (which fails the CI) and replaced with `collection_methods_unrelated_type`. See https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8780614474452305057/+/u/analyze_pkg_/stdout for the failures resulting from referencing deprecated rules. Change-Id: I00087e684bfb230b5dc94ab832c969ed67a631f7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304780 Commit-Queue: Samuel Rawlins Reviewed-by: Johnni Winther --- pkg/_fe_analyzer_shared/analysis_options.yaml | 3 +-- pkg/_fe_analyzer_shared/test/exhaustiveness/env.dart | 3 +++ .../test/flow_analysis/flow_analysis_test.dart | 3 +++ pkg/front_end/analysis_options.yaml | 3 +-- pkg/front_end/tool/kernel_ast_file_rewriter.dart | 3 +++ pkg/kernel/analysis_options.yaml | 3 +-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pkg/_fe_analyzer_shared/analysis_options.yaml b/pkg/_fe_analyzer_shared/analysis_options.yaml index b4c5c37c63d..53b419a2760 100644 --- a/pkg/_fe_analyzer_shared/analysis_options.yaml +++ b/pkg/_fe_analyzer_shared/analysis_options.yaml @@ -7,14 +7,13 @@ include: analysis_options_no_lints.yaml linter: rules: - annotate_overrides + - collection_methods_unrelated_type - curly_braces_in_flow_control_structures - prefer_adjacent_string_concatenation - unawaited_futures - recursive_getters - avoid_empty_else - empty_statements - - list_remove_unrelated_type - - iterable_contains_unrelated_type - valid_regexps - package_api_docs - lines_longer_than_80_chars diff --git a/pkg/_fe_analyzer_shared/test/exhaustiveness/env.dart b/pkg/_fe_analyzer_shared/test/exhaustiveness/env.dart index 5c46c5a399a..be918d3f108 100644 --- a/pkg/_fe_analyzer_shared/test/exhaustiveness/env.dart +++ b/pkg/_fe_analyzer_shared/test/exhaustiveness/env.dart @@ -88,6 +88,9 @@ class TestEnvironment implements ObjectPropertyLookup { if (fields.isNotEmpty) { Map fieldMap = _fields[cls] ??= {}; for (MapEntry entry in fields.entries) { + // TODO(srawlins): Look into fixing this code. Right now we get: + // "The argument type 'String' isn't related to 'Key'." + // ignore: collection_methods_unrelated_type assert(!fieldMap.containsKey(entry.key), "Duplicate field '${entry.key}' in $cls."); fieldMap[new NameKey(entry.key)] = _typeFromStaticType(entry.value); diff --git a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart index e763afc10ae..ef4572c0152 100644 --- a/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart +++ b/pkg/_fe_analyzer_shared/test/flow_analysis/flow_analysis_test.dart @@ -3628,6 +3628,9 @@ main() { var s = FlowModel(Reachability.initial)._write( h, null, objectQVar, Type('Object?'), new SsaNode(null)); + // TODO(srawlins): Look into fixing this code. Right now we get: + // "The argument type 'Var' isn't related to 'int'." + // ignore: collection_methods_unrelated_type expect(s.variableInfo[objectQVar], isNull); }); diff --git a/pkg/front_end/analysis_options.yaml b/pkg/front_end/analysis_options.yaml index 771fe354bca..ffe3431b173 100644 --- a/pkg/front_end/analysis_options.yaml +++ b/pkg/front_end/analysis_options.yaml @@ -10,6 +10,7 @@ analyzer: linter: rules: + - collection_methods_unrelated_type - curly_braces_in_flow_control_structures - prefer_adjacent_string_concatenation - unawaited_futures @@ -17,8 +18,6 @@ linter: - recursive_getters - avoid_empty_else - empty_statements - - list_remove_unrelated_type - - iterable_contains_unrelated_type - valid_regexps - package_api_docs - lines_longer_than_80_chars diff --git a/pkg/front_end/tool/kernel_ast_file_rewriter.dart b/pkg/front_end/tool/kernel_ast_file_rewriter.dart index 091640dd5cf..313f714a12d 100644 --- a/pkg/front_end/tool/kernel_ast_file_rewriter.dart +++ b/pkg/front_end/tool/kernel_ast_file_rewriter.dart @@ -24,6 +24,9 @@ void main(List args) { Map classes = {}; for (TopLevelDeclarationEnd cls in ast.getClasses()) { IdentifierHandle identifier = cls.getIdentifier(); + // TODO(srawlins): Look into fixing this code. Right now we get: + // "The argument type 'Token' isn't related to 'String'." + // ignore: collection_methods_unrelated_type assert(classes[identifier.token] == null); classes[identifier.token.toString()] = cls; } diff --git a/pkg/kernel/analysis_options.yaml b/pkg/kernel/analysis_options.yaml index 4d006322e69..27b4527f425 100644 --- a/pkg/kernel/analysis_options.yaml +++ b/pkg/kernel/analysis_options.yaml @@ -4,14 +4,13 @@ analyzer: linter: rules: + - collection_methods_unrelated_type - curly_braces_in_flow_control_structures - prefer_adjacent_string_concatenation - unawaited_futures - recursive_getters - avoid_empty_else - empty_statements - - list_remove_unrelated_type - - iterable_contains_unrelated_type - valid_regexps - package_api_docs - lines_longer_than_80_chars