From 075a3b6abf54b38c295690ec8e043607654f2da3 Mon Sep 17 00:00:00 2001 From: Phil Quitslund Date: Mon, 8 Aug 2022 10:19:42 -0700 Subject: [PATCH] 1.27.0 (#3576) * 1.27.0 * Insert reasoning for `avoid_function_literals_in_foreach_calls` lint (#3545) * Update avoid_function_literals_in_foreach_calls.dart * Second attempt * Add a the to make for betterer english * convert unnecessary `.from`s to `.of`s (#3577) * deflake `avoid_redundant_argument_values` * ++ Co-authored-by: Brett Morgan --- CHANGELOG.md | 17 ++++++++++++++++ .../avoid_redundant_argument_values.dart | 5 ++++- lib/src/version.dart | 2 +- pubspec.yaml | 2 +- .../avoid_redundant_argument_values_test.dart | 20 +++++++++++++++++++ 5 files changed, 43 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f5d83a2..80a6e7c0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# 1.27.0 + +- fix `avoid_redundant_argument_values` when referencing required + parameters in legacy libraries +- performance improvements for `use_late_for_private_fields_and_variables` +- new lint: `use_string_in_part_of_directives` +- fixed `use_super_parameters` false positive with repeated super + parameter references +- updated `use_late_for_private_fields_and_variables` to handle enums +- fixed `prefer_contains` false positive when start index is non-zero +- improved `noop_primitive_operations` to catch `.toString()` + in string interpolations +- updated `public_member_api_docs` to report diagnostics on extension + names (instead of bodies) +- miscellaneous documentation improvements +- (internal): `DartTypeUtilities` refactoring + # 1.26.0 - new lint: `combinators_ordering` diff --git a/lib/src/rules/avoid_redundant_argument_values.dart b/lib/src/rules/avoid_redundant_argument_values.dart index b7713367c..584268d1a 100644 --- a/lib/src/rules/avoid_redundant_argument_values.dart +++ b/lib/src/rules/avoid_redundant_argument_values.dart @@ -71,7 +71,10 @@ class _Visitor extends SimpleAstVisitor { for (var i = arguments.length - 1; i >= 0; --i) { var arg = arguments[i]; var param = arg.staticParameterElement; - if (param == null || param.hasRequired || !param.isOptional) { + if (param == null || + param.declaration.isRequired || + param.hasRequired || + !param.isOptional) { continue; } var value = param.computeConstantValue(); diff --git a/lib/src/version.dart b/lib/src/version.dart index 2a919c31d..766a2916d 100644 --- a/lib/src/version.dart +++ b/lib/src/version.dart @@ -3,4 +3,4 @@ // BSD-style license that can be found in the LICENSE file. /// Package version. Synchronized w/ pubspec.yaml. -const String version = '1.26.0'; +const String version = '1.27.0'; diff --git a/pubspec.yaml b/pubspec.yaml index de0fb2e3f..01f615d1d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: linter -version: 1.26.0 +version: 1.27.0 description: >- The implementation of the lint rules supported by the analyzer framework. diff --git a/test/rules/avoid_redundant_argument_values_test.dart b/test/rules/avoid_redundant_argument_values_test.dart index a33c21853..ad2954fe5 100644 --- a/test/rules/avoid_redundant_argument_values_test.dart +++ b/test/rules/avoid_redundant_argument_values_test.dart @@ -51,6 +51,26 @@ void g() { '''); } + /// https://github.com/dart-lang/sdk/issues/49596 + test_legacyRequired() async { + var a = newFile('$testPackageLibPath/a.dart', r''' +class Foo { + int? foo; + Foo({required this.foo}); +} +'''); + await resolveFile(a.path); + + await assertNoDiagnostics(r''' +// @dart = 2.9 +import 'a.dart'; + +void f() { + Foo(foo: null); +} +'''); + } + test_requiredNullable() async { await assertNoDiagnostics(r''' void f({required int? x}) { }