Skip to content

Commit fec029f

Browse files
parloughCommit Queue
authored andcommitted
[analyzer] Mark latest lint and diagnostic docs as published
Also fixes a few minor typos. Change-Id: I026bb91682440aa851f05f998c4c67c3d1a7a56e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403540 Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Auto-Submit: Parker Lougheed <[email protected]>
1 parent 525afed commit fec029f

File tree

8 files changed

+47
-14
lines changed

8 files changed

+47
-14
lines changed

pkg/analyzer/lib/src/dart/error/ffi_code.g.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,15 @@ class FfiCode extends ErrorCode {
395395
correctionMessage:
396396
"Try adding a type parameter extending `NativeType` to the `@Native` "
397397
"annotation.",
398+
hasPublishedDocs: true,
398399
);
399400

400401
/// No parameters.
401402
static const FfiCode NEGATIVE_VARIABLE_DIMENSION = FfiCode(
402403
'NEGATIVE_VARIABLE_DIMENSION',
403404
"The variable dimension of a variable-length array must be non-negative.",
404405
correctionMessage: "Try using a value that is zero or greater.",
406+
hasPublishedDocs: true,
405407
);
406408

407409
/// Parameters:

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ class CompileTimeErrorCode extends ErrorCode {
743743
"'{0}' can't be used to name both a type parameter and the extension in "
744744
"which the type parameter is defined.",
745745
correctionMessage:
746-
"Try renaming either the type variaparameterble or the extension.",
746+
"Try renaming either the type parameter or the extension.",
747747
hasPublishedDocs: true,
748748
uniqueName: 'CONFLICTING_TYPE_VARIABLE_AND_EXTENSION',
749749
);
@@ -7643,6 +7643,7 @@ class WarningCode extends ErrorCode {
76437643
'UNUSED_ELEMENT_PARAMETER',
76447644
"A value for optional parameter '{0}' isn't ever given.",
76457645
correctionMessage: "Try removing the unused parameter.",
7646+
hasPublishedDocs: true,
76467647
);
76477648

76487649
/// Parameters:

pkg/analyzer/messages.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,7 @@ CompileTimeErrorCode:
23912391
CONFLICTING_TYPE_VARIABLE_AND_EXTENSION:
23922392
sharedName: CONFLICTING_TYPE_VARIABLE_AND_CONTAINER
23932393
problemMessage: "'{0}' can't be used to name both a type parameter and the extension in which the type parameter is defined."
2394-
correctionMessage: Try renaming either the type variaparameterble or the extension.
2394+
correctionMessage: Try renaming either the type parameter or the extension.
23952395
hasPublishedDocs: true
23962396
comment: |-
23972397
Parameters:
@@ -19215,7 +19215,7 @@ FfiCode:
1921519215
NATIVE_FUNCTION_MISSING_TYPE:
1921619216
problemMessage: The native type of this function couldn't be inferred so it must be specified in the annotation.
1921719217
correctionMessage: Try adding a type parameter extending `NativeType` to the `@Native` annotation.
19218-
hasPublishedDocs: false
19218+
hasPublishedDocs: true
1921919219
comment: No parameters
1922019220
documentation: |-
1922119221
#### Description
@@ -20452,7 +20452,7 @@ FfiCode:
2045220452
NEGATIVE_VARIABLE_DIMENSION:
2045320453
problemMessage: The variable dimension of a variable-length array must be non-negative.
2045420454
correctionMessage: Try using a value that is zero or greater.
20455-
hasPublishedDocs: false
20455+
hasPublishedDocs: true
2045620456
comment: No parameters.
2045720457
documentation: |-
2045820458
#### Description
@@ -27529,7 +27529,7 @@ WarningCode:
2752927529
UNUSED_ELEMENT_PARAMETER:
2753027530
problemMessage: "A value for optional parameter '{0}' isn't ever given."
2753127531
correctionMessage: Try removing the unused parameter.
27532-
hasPublishedDocs: false
27532+
hasPublishedDocs: true
2753327533
comment: |-
2753427534
Parameters:
2753527535
0: the name of the parameter that is declared but not used

pkg/analyzer/tool/diagnostics/diagnostics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29218,7 +29218,7 @@ _Unnecessary use of multiple underscores._
2921829218
#### Description
2921929219

2922029220
The analyzer produces this diagnostic when an unused variable is named
29221-
with mutiple underscores (for example `__`). A single `_` wildcard variable
29221+
with multiple underscores (for example `__`). A single `_` wildcard variable
2922229222
can be used instead.
2922329223

2922429224
#### Example

pkg/linter/CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# 3.7.0-wip
22

33
- new lint: `unnecessary_underscores`
4-
- removed lint: `package_api_docs`
5-
- removed lint: `unsafe_html`
6-
- _(soon to be)_ deprecated lint: `avoid_null_checks_in_equality_operators`
4+
- new lint: `strict_top_level_inference`
75
- new _(experimental)_ lint: `omit_obvious_property_types`
86
- new _(experimental)_ lint: `specify_nonobvious_property_types`
97
- new _(experimental)_ lint: `unsafe_variance`
8+
- removed lint: `package_api_docs`
9+
- removed lint: `unsafe_html`
10+
- _(soon to be)_ deprecated lint: `avoid_null_checks_in_equality_operators`
1011

1112
# 3.6.0
1213

pkg/linter/lib/src/lint_codes.g.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,6 +1761,7 @@ class LinterLintCode extends LintCode {
17611761
LintNames.unnecessary_underscores,
17621762
"Unnecessary use of multiple underscores.",
17631763
correctionMessage: "Try using '_'.",
1764+
hasPublishedDocs: true,
17641765
);
17651766

17661767
static const LintCode unreachable_from_main = LinterLintCode(
@@ -1795,6 +1796,7 @@ class LinterLintCode extends LintCode {
17951796
correctionMessage:
17961797
"Try using a more general type that doesn't contain any type "
17971798
"parameters in such a position.",
1799+
hasPublishedDocs: true,
17981800
);
17991801

18001802
static const LintCode use_build_context_synchronously_async_use =

pkg/linter/messages.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10837,7 +10837,7 @@ LintCode:
1083710837
type argument, but not C(14) if C accepts one or more type arguments.
1083810838
- e is a cascade whose target has an obvious type. For instance,
1083910839
1..isEven..isEven has an obvious type because 1 has an obvious type.
10840-
- e is a type cast. For instance, myComplexpression as int.
10840+
- e is a type cast. For instance, `myComplexExpression as int`.
1084110841
1084210842
**BAD:**
1084310843
```dart
@@ -13011,12 +13011,12 @@ LintCode:
1301113011
state:
1301213012
experimental: "3.7"
1301313013
categories: [brevity, style]
13014-
hasPublishedDocs: false
13014+
hasPublishedDocs: true
1301513015
documentation: |-
1301613016
#### Description
1301713017
1301813018
The analyzer produces this diagnostic when an unused variable is named
13019-
with mutiple underscores (for example `__`). A single `_` wildcard variable
13019+
with multiple underscores (for example `__`). A single `_` wildcard variable
1302013020
can be used instead.
1302113021
1302213022
#### Example
@@ -13295,7 +13295,7 @@ LintCode:
1329513295
state:
1329613296
experimental: "3.7"
1329713297
categories: [errorProne]
13298-
hasPublishedDocs: false
13298+
hasPublishedDocs: true
1329913299
documentation: |-
1330013300
#### Description
1330113301

pkg/linter/tool/machine/rules.json

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,20 @@
24202420
"incompatible": [],
24212421
"sets": [],
24222422
"fixStatus": "hasFix",
2423-
"details": "Do type annotate initialized top-level or static variables when the type is\nnon-obvious.\n\nType annotations on top-level or static variables can serve as a request for\ntype inference, documenting the expected outcome of the type inference step,\nand declaratively allowing the compiler and analyzer to solve the possibly\ncomplex task of finding type arguments and annotations in the initializing\nexpression that yield the desired result.\n\nType annotations on top-level or static variables can also inform readers about\nthe type of the initializing expression, which will allow them to proceed\nreading the locations in code where this variable is used with known good\ninformation about the type of the given variable (which may not be immediately\nevident by looking at the initializing expression).\n\nAn expression is considered to have a non-obvious type when it does not\nhave an obvious type.\n\nAn expression e has an obvious type in the following cases:\n\n- e is a non-collection literal. For instance, 1, true, 'Hello, $name!'.\n- e is a collection literal with actual type arguments. For instance,\n <int, bool>{}.\n- e is a list literal or a set literal where at least one element has an\n obvious type, and all elements have the same type. For instance, [1, 2] and\n { [true, false], [] }, but not [1, 1.5].\n- e is a map literal where all key-value pair have a key with an obvious type\n and a value with an obvious type, and all keys have the same type, and all\n values have the same type. For instance, { #a: <int>[] }, but not\n {1: 1, 2: true}.\n- e is an instance creation expression whose class part is not raw. For\n instance C(14) if C is a non-generic class, or C<int>(14) if C accepts one\n type argument, but not C(14) if C accepts one or more type arguments.\n- e is a cascade whose target has an obvious type. For instance,\n 1..isEven..isEven has an obvious type because 1 has an obvious type.\n- e is a type cast. For instance, myComplexpression as int.\n\n**BAD:**\n```dart\nfinal myTopLevelVariable =\n genericFunctionWrittenByOtherFolks(with, args);\n\nclass A {\n static var myStaticVariable =\n myTopLevelVariable.update('foo', null);\n}\n```\n\n**GOOD:**\n```dart\nfinal Map<String, Widget?> myTopLevelVariable =\n genericFunctionWrittenByOtherFolks(with, args);\n\nclass A {\n static Map<String, Widget?> myStaticVariable =\n myTopLevelVariable.update('foo', null);\n}\n```\n\n**This rule is experimental.** It is being evaluated, and it may be changed\nor removed. Feedback on its behavior is welcome! The main issue is here:\nhttps://github.com/dart-lang/linter/issues/5101.",
2423+
"details": "Do type annotate initialized top-level or static variables when the type is\nnon-obvious.\n\nType annotations on top-level or static variables can serve as a request for\ntype inference, documenting the expected outcome of the type inference step,\nand declaratively allowing the compiler and analyzer to solve the possibly\ncomplex task of finding type arguments and annotations in the initializing\nexpression that yield the desired result.\n\nType annotations on top-level or static variables can also inform readers about\nthe type of the initializing expression, which will allow them to proceed\nreading the locations in code where this variable is used with known good\ninformation about the type of the given variable (which may not be immediately\nevident by looking at the initializing expression).\n\nAn expression is considered to have a non-obvious type when it does not\nhave an obvious type.\n\nAn expression e has an obvious type in the following cases:\n\n- e is a non-collection literal. For instance, 1, true, 'Hello, $name!'.\n- e is a collection literal with actual type arguments. For instance,\n <int, bool>{}.\n- e is a list literal or a set literal where at least one element has an\n obvious type, and all elements have the same type. For instance, [1, 2] and\n { [true, false], [] }, but not [1, 1.5].\n- e is a map literal where all key-value pair have a key with an obvious type\n and a value with an obvious type, and all keys have the same type, and all\n values have the same type. For instance, { #a: <int>[] }, but not\n {1: 1, 2: true}.\n- e is an instance creation expression whose class part is not raw. For\n instance C(14) if C is a non-generic class, or C<int>(14) if C accepts one\n type argument, but not C(14) if C accepts one or more type arguments.\n- e is a cascade whose target has an obvious type. For instance,\n 1..isEven..isEven has an obvious type because 1 has an obvious type.\n- e is a type cast. For instance, `myComplexExpression as int`.\n\n**BAD:**\n```dart\nfinal myTopLevelVariable =\n genericFunctionWrittenByOtherFolks(with, args);\n\nclass A {\n static var myStaticVariable =\n myTopLevelVariable.update('foo', null);\n}\n```\n\n**GOOD:**\n```dart\nfinal Map<String, Widget?> myTopLevelVariable =\n genericFunctionWrittenByOtherFolks(with, args);\n\nclass A {\n static Map<String, Widget?> myStaticVariable =\n myTopLevelVariable.update('foo', null);\n}\n```\n\n**This rule is experimental.** It is being evaluated, and it may be changed\nor removed. Feedback on its behavior is welcome! The main issue is here:\nhttps://github.com/dart-lang/linter/issues/5101.",
2424+
"sinceDartSdk": "3.7"
2425+
},
2426+
{
2427+
"name": "strict_top_level_inference",
2428+
"description": "Specify type annotations.",
2429+
"categories": [
2430+
"style"
2431+
],
2432+
"state": "stable",
2433+
"incompatible": [],
2434+
"sets": [],
2435+
"fixStatus": "hasFix",
2436+
"details": "Do type annotate top-level and class-like member declarations, where types\nare not inferred from super-interfaces or initializers.\n\nThe lint warns about every omitted return type, parameter type, and\nvariable type of a top-level declaration or class-like-namespace-level\ndeclaration (static or instance member or constructor declaration), which\nis not given a type by inference, and which therefore defaults to dynamic.\n\nThe only omitted types that can be given a type by top-level inference,\nare those of variable declarations with initializer expressions, and\nreturn and parameter types of instance members that override a consistent\ncombined super-interface signature.\n\nSetters do not need a return type, as it is always assumed to be `void`.\n\n**BAD:**\n```dart\nvar _zeroPointCache;\nclass Point {\n get zero => ...;\n final x, y;\n Point(x, y) {}\n closest(b, c) => distance(b) <= distance(c) ? b : c;\n distance(other) => ...;\n}\n_sq(v) => v * v;\n```\n\n**GOOD:**\n```dart\nPoint? _zeroPointCache;\nclass Point {\n Point get zero => ...;\n final int x, y;\n Point(int x, int y) {}\n closest(Point b, Point c) =>\n distance(b) <= distance(c) ? b : c;\n distance(Point other) => ...;\n}\nint _sq(int v) => v * v;\n```",
24242437
"sinceDartSdk": "3.7"
24252438
},
24262439
{
@@ -2889,6 +2902,20 @@
28892902
"details": "Unnecessary `toList()` in spreads.\n\n**BAD:**\n```dart\nchildren: <Widget>[\n ...['foo', 'bar', 'baz'].map((String s) => Text(s)).toList(),\n]\n```\n\n**GOOD:**\n```dart\nchildren: <Widget>[\n ...['foo', 'bar', 'baz'].map((String s) => Text(s)),\n]\n```",
28902903
"sinceDartSdk": "2.18"
28912904
},
2905+
{
2906+
"name": "unnecessary_underscores",
2907+
"description": "Unnecessary underscores can be removed.",
2908+
"categories": [
2909+
"brevity",
2910+
"style"
2911+
],
2912+
"state": "stable",
2913+
"incompatible": [],
2914+
"sets": [],
2915+
"fixStatus": "hasFix",
2916+
"details": "**AVOID** using multiple underscores when a single wildcard will do.\n\n**BAD:**\n```dart\nvoid function(int __) { }\n```\n\n**GOOD:**\n```dart\nvoid function(int _) { }\n```",
2917+
"sinceDartSdk": "3.7"
2918+
},
28922919
{
28932920
"name": "unreachable_from_main",
28942921
"description": "Unreachable top-level members in executable libraries.",

0 commit comments

Comments
 (0)