Skip to content

Commit 6322a40

Browse files
parloughCommit Queue
authored andcommitted
[analyzer] Update messages and lint docs for downstream status
Change-Id: Ie4e057956dba0e568fa7fa6497ce42922207a382 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414440 Commit-Queue: Brian Wilkerson <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 7b28c5a commit 6322a40

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

pkg/analyzer/messages.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5137,7 +5137,8 @@ CompileTimeErrorCode:
51375137

51385138
#### Common fixes
51395139

5140-
If the value can be computed without storing it in a field, then try using a getter or a method:
5140+
If the value can be computed without storing it in a field, then try
5141+
using a getter or a method:
51415142

51425143
```dart
51435144
extension E on String {
@@ -5147,15 +5148,17 @@ CompileTimeErrorCode:
51475148
}
51485149
```
51495150

5150-
If the value must be stored, but is the same for every instance, try using a static field:
5151+
If the value must be stored, but is the same for every instance,
5152+
try using a static field:
51515153

51525154
```dart
51535155
extension E on String {
51545156
static String s = '';
51555157
}
51565158
```
51575159

5158-
If each instance needs to have its own value stored, then try using a getter and setter pair backed by a static Expando:
5160+
If each instance needs to have its own value stored, then try
5161+
using a getter and setter pair backed by a static `Expando`:
51595162

51605163
```dart
51615164
extension E on SomeType {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,7 @@ class LinterLintCode extends LintCode {
19381938
LintNames.use_null_aware_elements,
19391939
"Use the null-aware marker '?' rather than a null check via an 'if'.",
19401940
correctionMessage: "Try using '?'.",
1941+
hasPublishedDocs: true,
19411942
);
19421943

19431944
static const LintCode use_raw_strings = LinterLintCode(

pkg/linter/messages.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,7 +4527,7 @@ LintCode:
45274527
**DO** use Flutter TODO format.
45284528
45294529
From the [Flutter
4530-
docs](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#comments):
4530+
docs](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#comments):
45314531
45324532
> TODOs should include the string TODO in all caps, followed by the GitHub
45334533
username of the person with the best context about the problem referenced by the
@@ -14226,7 +14226,7 @@ LintCode:
1422614226
state:
1422714227
stable: "3.8"
1422814228
categories: [brevity, style]
14229-
hasPublishedDocs: false
14229+
hasPublishedDocs: true
1423014230
documentation: |-
1423114231
#### Description
1423214232

pkg/linter/tool/machine/rules.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@
10911091
"incompatible": [],
10921092
"sets": [],
10931093
"fixStatus": "hasFix",
1094-
"details": "**DO** use Flutter TODO format.\n\nFrom the [Flutter\ndocs](https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#comments):\n\n> TODOs should include the string TODO in all caps, followed by the GitHub\nusername of the person with the best context about the problem referenced by the\nTODO in parenthesis. A TODO is not a commitment that the person referenced will\nfix the problem, it is intended to be the person with enough context to explain\nthe problem. Thus, when you create a TODO, it is almost always your username\nthat is given.\n\n**GOOD:**\n```dart\n// TODO(username): message.\n// TODO(username): message, https://URL-to-issue.\n```",
1094+
"details": "**DO** use Flutter TODO format.\n\nFrom the [Flutter\ndocs](https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#comments):\n\n> TODOs should include the string TODO in all caps, followed by the GitHub\nusername of the person with the best context about the problem referenced by the\nTODO in parenthesis. A TODO is not a commitment that the person referenced will\nfix the problem, it is intended to be the person with enough context to explain\nthe problem. Thus, when you create a TODO, it is almost always your username\nthat is given.\n\n**GOOD:**\n```dart\n// TODO(username): message.\n// TODO(username): message, https://URL-to-issue.\n```",
10951095
"sinceDartSdk": "2.1"
10961096
},
10971097
{
@@ -2673,7 +2673,7 @@
26732673
"categories": [
26742674
"style"
26752675
],
2676-
"state": "experimental",
2676+
"state": "stable",
26772677
"incompatible": [],
26782678
"sets": [],
26792679
"fixStatus": "hasFix",
@@ -3143,6 +3143,20 @@
31433143
"details": "Where possible, use already defined const values.\n\n**BAD:**\n```dart\nconst Duration(seconds: 0);\n```\n\n**GOOD:**\n```dart\nDuration.zero;\n```",
31443144
"sinceDartSdk": "2.13"
31453145
},
3146+
{
3147+
"name": "use_null_aware_elements",
3148+
"description": "If-elements testing for null can be replaced with null-aware elements.",
3149+
"categories": [
3150+
"brevity",
3151+
"style"
3152+
],
3153+
"state": "stable",
3154+
"incompatible": [],
3155+
"sets": [],
3156+
"fixStatus": "hasFix",
3157+
"details": "Where possible, use null-aware elements in collection literals.\n\n**BAD:**\n```dart\nf(String? key) => {if (key != null) key: \"value\"};\n```\n\n**GOOD:**\n```dart\nf(String? key) => {?key: \"value\"};\n```",
3158+
"sinceDartSdk": "3.8"
3159+
},
31463160
{
31473161
"name": "use_raw_strings",
31483162
"description": "Use raw string to avoid escapes.",
@@ -3289,4 +3303,4 @@
32893303
"details": "**DON'T** assign to `void`.\n\n**BAD:**\n```dart\nclass A<T> {\n T value;\n void test(T arg) { }\n}\n\nvoid main() {\n A<void> a = A<void>();\n a.value = 1; // LINT\n a.test(1); // LINT\n}\n```",
32903304
"sinceDartSdk": "2.0"
32913305
}
3292-
]
3306+
]

0 commit comments

Comments
 (0)