Skip to content

Commit

Permalink
Update for latest diagnostic messages (#5231)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Sansone <[email protected]>
  • Loading branch information
parlough and atsansone authored Oct 6, 2023
1 parent 2744ab0 commit 1bd3d85
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/_data/linter_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
{
Expand Down
39 changes: 36 additions & 3 deletions src/tools/diagnostic-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <String>{[!'a' : 'b'!]};
var collection = <String>{[!'a' : 'b'!]};
{% endprettify %}

#### Common fixes
Expand All @@ -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 = <String, String>{'a' : 'b'};
var collection = <String, String>{'a' : 'b'};
{% endprettify %}

In other cases, you might need to change the explicit type from `Set` to
Expand All @@ -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 = <String>{'a', 'b'};
var collection = <String>{'a', 'b'};
{% endprettify %}

### map_key_type_not_assignable
Expand Down Expand Up @@ -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}'._
Expand Down

0 comments on commit 1bd3d85

Please sign in to comment.