diff --git a/pkg/analyzer/analysis_options.yaml b/pkg/analyzer/analysis_options.yaml index 28cd7e86c74..07e706c0d1c 100644 --- a/pkg/analyzer/analysis_options.yaml +++ b/pkg/analyzer/analysis_options.yaml @@ -38,6 +38,12 @@ linter: - always_use_package_imports - avoid_dynamic_calls - avoid_unused_constructor_parameters + # Enable after linter 1.31 is released. + #- collection_methods_unrelated_type + - enable_null_safety + - implicit_call_tearoffs + - library_annotations - unawaited_futures + - unnecessary_library_directive - unnecessary_parenthesis - use_super_parameters diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart index 23a1b21daa7..f11abecd2b1 100644 --- a/pkg/analyzer/lib/src/generated/parser.dart +++ b/pkg/analyzer/lib/src/generated/parser.dart @@ -2,8 +2,6 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -library analyzer.parser; - import 'package:_fe_analyzer_shared/src/parser/parser.dart' as fasta; import 'package:_fe_analyzer_shared/src/parser/type_info.dart' as fasta; import 'package:analyzer/dart/analysis/features.dart'; diff --git a/pkg/analyzer/lib/src/summary/format.dart b/pkg/analyzer/lib/src/summary/format.dart index 871872842c2..10fb2f96520 100644 --- a/pkg/analyzer/lib/src/summary/format.dart +++ b/pkg/analyzer/lib/src/summary/format.dart @@ -10,8 +10,6 @@ // The generator sometimes generates unnecessary 'this' references. // ignore_for_file: unnecessary_this -library analyzer.src.summary.format; - import 'dart:convert' as convert; import 'dart:typed_data' as typed_data; diff --git a/pkg/analyzer/lib/src/summary2/macro_application.dart b/pkg/analyzer/lib/src/summary2/macro_application.dart index 40ca9ad92a1..d4c7ff341ea 100644 --- a/pkg/analyzer/lib/src/summary2/macro_application.dart +++ b/pkg/analyzer/lib/src/summary2/macro_application.dart @@ -58,7 +58,7 @@ class LibraryMacroApplier { libraryBuilder.element.accept(collector); for (final targetElement in collector.targets) { - final targetNode = _linker.elementNodes[targetElement]; + final targetNode = _linker.elementNodes[targetElement as ElementImpl]; // TODO(scheglov) support other declarations if (targetNode is ClassDeclaration) { await performance.runAsync( diff --git a/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart b/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart index da370bd77d0..cf41ea2b8ff 100644 --- a/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart +++ b/pkg/analyzer/test/src/fasta/recovery/partial_code/partial_code_support.dart @@ -114,13 +114,14 @@ abstract class PartialCodeTest extends AbstractRecoveryTest { descriptor, suffixes[i], i + 1, head, tail, featureSet: featureSet); } - if (descriptor.failing != null) { + var descriptorFailing = descriptor.failing; + if (descriptorFailing != null) { test('${descriptor.name}_failingList', () { - Set failing = Set.from(descriptor.failing!); + var failing = Set.of(descriptorFailing); if (includeEof) { failing.remove('eof'); } - failing.removeAll(suffixes.map((TestSuffix suffix) => suffix.name)); + failing.removeAll(suffixes.map((suffix) => suffix.name)); expect(failing, isEmpty, reason: 'There are tests marked as failing that are not being run'); diff --git a/pkg/analyzer/tool/summary/generate.dart b/pkg/analyzer/tool/summary/generate.dart index e059a81564f..653f2426848 100644 --- a/pkg/analyzer/tool/summary/generate.dart +++ b/pkg/analyzer/tool/summary/generate.dart @@ -654,8 +654,6 @@ class _CodeGenerator { out("// The generator sometimes generates unnecessary 'this' references."); out('// ignore_for_file: unnecessary_this'); out(); - out('library analyzer.src.summary.format;'); - out(); out("import 'dart:convert' as convert;"); out("import 'dart:typed_data' as typed_data;"); out(); diff --git a/pkg/analyzer/tool/test_log_parser/test_log_parser.dart b/pkg/analyzer/tool/test_log_parser/test_log_parser.dart index 38ddab0f2c7..a72ea6479b7 100644 --- a/pkg/analyzer/tool/test_log_parser/test_log_parser.dart +++ b/pkg/analyzer/tool/test_log_parser/test_log_parser.dart @@ -1,4 +1,3 @@ -// @dart = 2.9 // Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. @@ -19,10 +18,10 @@ main(List args) async { int index = 0; final int expectedPrefixLength = 'Expected: '.length; final int actualPrefixLength = 'Actual: '.length; - TestResult currentResult; + TestResult? currentResult; Map> testsByExpectedAndActual = >{}; - Map> testsByStackTrace = + Map> testsByStackTrace = >{}; while (index < output.length) { String currentLine = output[index]; @@ -53,7 +52,7 @@ main(List args) async { } if (hasStackTrace) { currentResult.stackTrace = output.sublist(index + 1, endIndex - 2); - String traceLine = currentResult.traceLine; + var traceLine = currentResult.traceLine; testsByStackTrace .putIfAbsent(traceLine, () => []) .add(currentResult); @@ -68,11 +67,9 @@ main(List args) async { List missingCodes = []; for (List results in testsByExpectedAndActual.values) { for (TestResult result in results) { - String message = result.message; - if (message != null) { - if (message.startsWith('Bad state: Unable to convert (')) { - missingCodes.add(message); - } + var message = result.message; + if (message.startsWith('Bad state: Unable to convert (')) { + missingCodes.add(message); } } } @@ -82,15 +79,11 @@ main(List args) async { List keys = testsByExpectedAndActual.keys.toList(); keys.sort(); for (String key in keys) { - List results = testsByExpectedAndActual[key]; + var results = testsByExpectedAndActual[key]!; results.sort((first, second) => first.testName.compareTo(second.testName)); print('$key (${results.length})'); for (TestResult result in results) { - if (result.message == null) { - print(' ${result.testName}'); - } else { - print(' ${result.testName} (${result.message})'); - } + print(' ${result.testName} (${result.message})'); } } if (missingCodes.isNotEmpty) { @@ -104,12 +97,13 @@ main(List args) async { if (testsByStackTrace.isNotEmpty) { print(''); print('Unique stack traces (${testsByStackTrace.length}):'); - List keys = testsByStackTrace.keys.toList(); + var keys = testsByStackTrace.keys.toList(); keys.sort((first, second) { - return testsByStackTrace[second].length - testsByStackTrace[first].length; + return testsByStackTrace[second]!.length - + testsByStackTrace[first]!.length; }); - for (String traceLine in keys) { - print(' (${testsByStackTrace[traceLine].length}) $traceLine'); + for (var traceLine in keys) { + print(' (${testsByStackTrace[traceLine]!.length}) $traceLine'); } } } @@ -121,14 +115,14 @@ class TestResult { String testName; String expected; String actual; - String message; - List stackTrace; + late String message; + late List stackTrace; TestResult(this.testName, this.expected, this.actual); - String get traceLine { + String? get traceLine { for (int i = 0; i < stackTrace.length; i++) { - String traceLine = stackTrace[i]; + var traceLine = stackTrace[i]; if (traceLine.startsWith(framePattern) && traceLine.contains('(package:')) { if (traceLine.contains('ResolutionApplier._get') ||