From 1bd3d8516d0d82720325439dfcd9e35e895a9467 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Fri, 6 Oct 2023 13:10:14 -0500 Subject: [PATCH] Update for latest diagnostic messages (#5231) Co-authored-by: Anthony Sansone --- src/_data/linter_rules.json | 4 ++-- src/tools/diagnostic-messages.md | 39 +++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/_data/linter_rules.json b/src/_data/linter_rules.json index d59dbe590..f315df9b1 100644 --- a/src/_data/linter_rules.json +++ b/src/_data/linter_rules.json @@ -637,7 +637,7 @@ "sets": [], "fixStatus": "hasFix", "details": "**DO** annotate redeclared members.\n\nThis practice improves code readability and helps protect against\nunintentionally redeclaring members or being surprised when a member ceases to\nredeclare (due for example to a rename refactoring).\n\n**BAD:**\n```dart\nclass C {\n void f() { }\n}\n\nextension type E(C c) implements C {\n void f() {\n ...\n }\n}\n```\n\n**GOOD:**\n```dart\nimport 'package:meta/meta.dart';\n\nclass C {\n void f() { }\n}\n\nextension type E(C c) implements C {\n @redeclare\n void f() {\n ...\n }\n}\n```\n", - "sinceDartSdk": "Unreleased" + "sinceDartSdk": "3.2.0" }, { "name": "avoid_annotating_with_dynamic", @@ -2600,7 +2600,7 @@ "flutter" ], "fixStatus": "hasFix", - "details": "From [Effective Dart](https://dart.dev/effective-dart/usage#dont-use-this-when-not-needed-to-avoid-shadowing):\n\n**DON'T** use `this` when not needed to avoid shadowing.\n\n**BAD:**\n```dart\nclass Box {\n var value;\n void update(new_value) {\n this.value = new_value;\n }\n}\n```\n\n**GOOD:**\n```dart\nclass Box {\n var value;\n void update(new_value) {\n value = new_value;\n }\n}\n```\n\n**GOOD:**\n```dart\nclass Box {\n var value;\n void update(value) {\n this.value = value;\n }\n}\n```\n\n", + "details": "From [Effective Dart](https://dart.dev/effective-dart/usage#dont-use-this-when-not-needed-to-avoid-shadowing):\n\n**DON'T** use `this` when not needed to avoid shadowing.\n\n**BAD:**\n```dart\nclass Box {\n int value;\n void update(int newValue) {\n this.value = newValue;\n }\n}\n```\n\n**GOOD:**\n```dart\nclass Box {\n int value;\n void update(int newValue) {\n value = newValue;\n }\n}\n```\n\n**GOOD:**\n```dart\nclass Box {\n int value;\n void update(int value) {\n this.value = value;\n }\n}\n```\n\n", "sinceDartSdk": "2.0.0" }, { diff --git a/src/tools/diagnostic-messages.md b/src/tools/diagnostic-messages.md index 8eccb1107..bf135d4a9 100644 --- a/src/tools/diagnostic-messages.md +++ b/src/tools/diagnostic-messages.md @@ -11586,7 +11586,7 @@ The following code produces this diagnostic because the literal has a map entry even though it's a set literal: {% prettify dart tag=pre+code %} -const collection = {[!'a' : 'b'!]}; +var collection = {[!'a' : 'b'!]}; {% endprettify %} #### Common fixes @@ -11596,7 +11596,7 @@ that it is a map. In the previous example, you could do this by adding another type argument: {% prettify dart tag=pre+code %} -const collection = {'a' : 'b'}; +var collection = {'a' : 'b'}; {% endprettify %} In other cases, you might need to change the explicit type from `Set` to @@ -11607,7 +11607,7 @@ possibly by replacing the colon with a comma if both values should be included in the set: {% prettify dart tag=pre+code %} -const collection = {'a', 'b'}; +var collection = {'a', 'b'}; {% endprettify %} ### map_key_type_not_assignable @@ -11836,6 +11836,39 @@ void f(int x) {} void g({required int x}) {} {% endprettify %} +### missing_dependency + +_Missing a dependency on imported package '{0}'._ + +#### Description + +The analyzer produces this diagnostic when there's a package that has been +imported in the source but is not listed in the dependency of the +importing package. + +#### Example + +The following code produces this diagnostic because the package `path` is +not listed in the dependencies, while there is an import statement +with package `path` in the source code of package example: + +{% prettify yaml tag=pre+code %} +name: example +dependencies: + meta: ^1.0.2 +{% endprettify %} + +#### Common fixes + +Add the missing package 'path' to the `dependencies` field: + +{% prettify yaml tag=pre+code %} +name: example +dependencies: + meta: ^1.0.2 + path: any +{% endprettify %} + ### missing_enum_constant_in_switch _Missing case clause for '{0}'._