Skip to content

Commit e5cd02c

Browse files
lrhnCommit Queue
authored and
Commit Queue
committed
Make lint descriptions more consistently use code-quotes.
Use markdown code quotes for keywords and types. Rephrase some descriptions as drive-by-fixups. Change-Id: I9a54b19c00b8076c7999b21d209f92c2a4191644 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365460 Commit-Queue: Lasse Nielsen <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 059624e commit e5cd02c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+115
-114
lines changed

pkg/linter/lib/src/rules/avoid_annotating_with_dynamic.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import 'package:analyzer/dart/element/type.dart';
99
import '../analyzer.dart';
1010
import '../extensions.dart';
1111

12-
const _desc = r'Avoid annotating with dynamic when not required.';
12+
const _desc = r'Avoid annotating with `dynamic` when not required.';
1313

1414
const _details = r'''
15-
**AVOID** annotating with dynamic when not required.
15+
**AVOID** annotating with `dynamic` when not required.
1616
1717
As `dynamic` is the assumed return value of a function or method, it is usually
1818
not necessary to annotate it.

pkg/linter/lib/src/rules/avoid_bool_literals_in_conditional_expressions.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import 'package:analyzer/dart/ast/visitor.dart';
77

88
import '../analyzer.dart';
99

10-
const _desc = r'Avoid bool literals in conditional expressions.';
10+
const _desc = r'Avoid `bool` literals in conditional expressions.';
1111

1212
const _details = r'''
13-
**AVOID** bool literals in conditional expressions.
13+
**AVOID** `bool` literals in conditional expressions.
1414
1515
**BAD:**
1616
```dart

pkg/linter/lib/src/rules/avoid_catching_errors.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import 'package:analyzer/dart/ast/visitor.dart';
88
import '../analyzer.dart';
99
import '../extensions.dart';
1010

11-
const _desc = r"Don't explicitly catch Error or types that implement it.";
11+
const _desc = r"Don't explicitly catch `Error` or types that implement it.";
1212

1313
const _details = r'''
14-
**DON'T** explicitly catch Error or types that implement it.
14+
**DON'T** explicitly catch `Error` or types that implement it.
1515
1616
Errors differ from Exceptions in that Errors can be analyzed and prevented prior
1717
to runtime. It should almost never be necessary to catch an error at runtime.

pkg/linter/lib/src/rules/avoid_double_and_int_checks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import 'package:analyzer/dart/element/element.dart';
88

99
import '../analyzer.dart';
1010

11-
const _desc = r'Avoid double and int checks.';
11+
const _desc = r'Avoid `double` and `int` checks.';
1212

1313
const _details = r'''
14-
**AVOID** to check if type is double or int.
14+
**AVOID** to check if type is `double` or `int`.
1515
1616
When compiled to JS, integer values are represented as floats. That can lead to
1717
some unexpected behavior when using either `is` or `is!` where the type is

pkg/linter/lib/src/rules/avoid_dynamic_calls.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,31 @@ import 'package:analyzer/dart/element/type.dart';
99

1010
import '../analyzer.dart';
1111

12-
const _desc = r'Avoid method calls or property accesses on a "dynamic" target.';
12+
const _desc = r'Avoid method calls or property accesses on a `dynamic` target.';
1313

1414
const _details = r'''
1515
**DO** avoid method calls or accessing properties on an object that is either
16-
explicitly or implicitly statically typed "dynamic". Dynamic calls are treated
16+
explicitly or implicitly statically typed `dynamic`. Dynamic calls are treated
1717
slightly different in every runtime environment and compiler, but most
1818
production modes (and even some development modes) have both compile size and
1919
runtime performance penalties associated with dynamic calls.
2020
21-
Additionally, targets typed "dynamic" disables most static analysis, meaning it
22-
is easier to lead to a runtime "NoSuchMethodError" or "NullError" than properly
21+
Additionally, targets typed `dynamic` disables most static analysis, meaning it
22+
is easier to lead to a runtime `NoSuchMethodError` or `TypeError` than properly
2323
statically typed Dart code.
2424
25-
There is an exception to methods and properties that exist on "Object?":
26-
- a.hashCode
27-
- a.runtimeType
28-
- a.noSuchMethod(someInvocation)
29-
- a.toString()
25+
There is an exception to methods and properties that exist on `Object?`:
26+
- `a.hashCode`
27+
- `a.runtimeType`
28+
- `a.noSuchMethod(someInvocation)`
29+
- `a.toString()`
3030
3131
... these members are dynamically dispatched in the web-based runtimes, but not
3232
in the VM-based ones. Additionally, they are so common that it would be very
3333
punishing to disallow `any.toString()` or `any == true`, for example.
3434
35-
Note that despite "Function" being a type, the semantics are close to identical
36-
to "dynamic", and calls to an object that is typed "Function" will also trigger
35+
Note that despite `Function` being a type, the semantics are close to identical
36+
to `dynamic`, and calls to an object that is typed `Function` will also trigger
3737
this lint.
3838
3939
Dynamic calls are allowed on cast expressions (`as dynamic` or `as Function`).

pkg/linter/lib/src/rules/avoid_final_parameters.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import 'package:analyzer/dart/ast/visitor.dart';
77

88
import '../analyzer.dart';
99

10-
const _desc = r'Avoid final for parameter declarations.';
10+
const _desc = r'Avoid `final` for parameter declarations.';
1111

1212
const _details = r'''
13-
**AVOID** declaring parameters as final.
13+
**AVOID** declaring parameters as `final`.
1414
15-
Declaring parameters as final can lead to unnecessarily verbose code, especially
16-
when using the "parameter_assignments" rule.
15+
Declaring parameters as `final` can lead to unnecessarily verbose code,
16+
especially when using the "parameter_assignments" rule.
1717
1818
**BAD:**
1919
```dart

pkg/linter/lib/src/rules/avoid_init_to_null.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@ import 'package:analyzer/dart/element/type.dart';
1010
import '../analyzer.dart';
1111
import '../extensions.dart';
1212

13-
const _desc = r"Don't explicitly initialize variables to null.";
13+
const _desc = r"Don't explicitly initialize variables to `null`.";
1414

1515
const _details = r'''
1616
From [Effective Dart](https://dart.dev/effective-dart/usage#dont-explicitly-initialize-variables-to-null):
1717
1818
**DON'T** explicitly initialize variables to `null`.
1919
20-
If a variable has a non-nullable type or is `final`,
20+
If a variable has a non-nullable type or is `final`,
2121
Dart reports a compile error if you try to use it
22-
before it has been definitely initialized.
23-
If the variable is nullable and not `const` or `final`,
24-
then it is implicitly initialized to `null` for you.
25-
There's no concept of "uninitialized memory" in Dart
22+
before it has been definitely initialized.
23+
If the variable is nullable and not `const` or `final`,
24+
then it is implicitly initialized to `null` for you.
25+
There's no concept of "uninitialized memory" in Dart
2626
and no need to explicitly initialize a variable to `null` to be "safe".
2727
Adding `= null` is redundant and unneeded.
2828

pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import 'package:analyzer/dart/element/nullability_suffix.dart';
1111
import '../analyzer.dart';
1212
import '../extensions.dart';
1313

14-
const _desc = r"Don't check for null in custom == operators.";
14+
const _desc = r"Don't check for `null` in custom `==` operators.";
1515

1616
const _details = r'''
17-
**DON'T** check for null in custom == operators.
17+
**DON'T** check for `null` in custom `==` operators.
1818
19-
As null is a special value, no instance of any class (other than `Null`) can be
20-
equivalent to it. Thus, it is redundant to check whether the other instance is
21-
null.
19+
As `null` is a special value, no instance of any class (other than `Null`) can
20+
be equivalent to it. Thus, it is redundant to check whether the other instance
21+
is `null`.
2222
2323
**BAD:**
2424
```dart

pkg/linter/lib/src/rules/avoid_returning_null_for_void.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import 'package:analyzer/dart/element/type.dart';
88

99
import '../analyzer.dart';
1010

11-
const _desc = r'Avoid returning null for void.';
11+
const _desc = r'Avoid returning `null` for `void`.';
1212

1313
const _details = r'''
14-
**AVOID** returning null for void.
14+
**AVOID** returning `null` for `void`.
1515
1616
In a large variety of languages `void` as return type is used to indicate that
1717
a function doesn't return anything. Dart allows returning `null` in functions

pkg/linter/lib/src/rules/avoid_slow_async_io.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:analyzer/dart/element/type.dart';
1010
import '../analyzer.dart';
1111
import '../extensions.dart';
1212

13-
const _desc = r'Avoid slow async `dart:io` methods.';
13+
const _desc = r'Avoid slow asynchronous `dart:io` methods.';
1414

1515
const _details = r'''
1616
**AVOID** using the following asynchronous file I/O methods because they are

pkg/linter/lib/src/rules/avoid_void_async.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import 'package:analyzer/dart/element/type.dart';
1010

1111
import '../analyzer.dart';
1212

13-
const _desc = r'Avoid async functions that return void.';
13+
const _desc = r'Avoid `async` functions that return `void`.';
1414

1515
const _details = r'''
16-
**DO** mark async functions as returning `Future<void>`.
16+
**DO** mark `async` functions as returning `Future<void>`.
1717
18-
When declaring an async method or function which does not return a value,
18+
When declaring an `async` method or function which does not return a value,
1919
declare that it returns `Future<void>` and not just `void`.
2020
2121
**BAD:**

pkg/linter/lib/src/rules/cancel_subscriptions.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import '../analyzer.dart';
88
import '../extensions.dart';
99
import '../util/leak_detector_visitor.dart';
1010

11-
const _desc = r'Cancel instances of dart.async.StreamSubscription.';
11+
const _desc = r'Cancel instances of `dart:async` `StreamSubscription`.';
1212

1313
const _details = r'''
14-
**DO** invoke `cancel` on instances of `dart.async.StreamSubscription`.
14+
**DO** invoke `cancel` on instances of `dart:async` `StreamSubscription`.
1515
1616
Cancelling instances of StreamSubscription prevents memory leaks and unexpected
1717
behavior.

pkg/linter/lib/src/rules/close_sinks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import '../analyzer.dart';
88
import '../extensions.dart';
99
import '../util/leak_detector_visitor.dart';
1010

11-
const _desc = r'Close instances of `dart.core.Sink`.';
11+
const _desc = r'Close instances of `dart:core` `Sink`.';
1212

1313
const _details = r'''
14-
**DO** invoke `close` on instances of `dart.core.Sink`.
14+
**DO** invoke `close` on instances of `dart:core` `Sink`.
1515
1616
Closing instances of Sink prevents memory leaks and unexpected behavior.
1717

pkg/linter/lib/src/rules/control_flow_in_finally.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import 'package:analyzer/dart/ast/visitor.dart';
77

88
import '../analyzer.dart';
99

10-
const _desc = r'Avoid control flow in finally blocks.';
10+
const _desc = r'Avoid control flow in `finally` blocks.';
1111

1212
const _details = r'''
13-
**AVOID** control flow leaving finally blocks.
13+
**AVOID** control flow leaving `finally` blocks.
1414
15-
Using control flow in finally blocks will inevitably cause unexpected behavior
15+
Using control flow in `finally` blocks will inevitably cause unexpected behavior
1616
that is hard to debug.
1717
1818
**BAD:**

pkg/linter/lib/src/rules/discarded_futures.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:analyzer/dart/element/type.dart';
99

1010
import '../analyzer.dart';
1111

12-
const _desc = r"Don't invoke asynchronous functions in non-async blocks.";
12+
const _desc = r"Don't invoke asynchronous functions in non-`async` blocks.";
1313

1414
const _details = r'''
1515
Making asynchronous calls in non-`async` functions is usually the sign of a

pkg/linter/lib/src/rules/iterable_contains_unrelated_type.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import '../analyzer.dart';
66

7-
const _desc = r'Invocation of Iterable<E>.contains with references of unrelated'
8-
r' types.';
7+
const _desc = r'Invocation of `Iterable<E>.contains` with references of'
8+
r' unrelated types.';
99

1010
const _details = r'''
1111
NOTE: This rule is removed in Dart 3.3.0; it is no longer functional.

pkg/linter/lib/src/rules/no_runtimeType_toString.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:analyzer/dart/element/type.dart';
1010

1111
import '../analyzer.dart';
1212

13-
const _desc = r'Avoid calling toString() on runtimeType.';
13+
const _desc = r'Avoid calling `toString()` on `runtimeType`.';
1414

1515
const _details = r'''
1616
Calling `toString` on a runtime type is a non-trivial operation that can

pkg/linter/lib/src/rules/null_check_on_nullable_type_parameter.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ import 'package:analyzer/dart/element/type.dart';
1010
import '../analyzer.dart';
1111
import 'unnecessary_null_checks.dart';
1212

13-
const _desc = r"Don't use null check on a potentially nullable type parameter.";
13+
const _desc =
14+
r"Don't use `null` check on a potentially nullable type parameter.";
1415

1516
const _details = r'''
16-
**DON'T** use null check on a potentially nullable type parameter.
17+
**DON'T** use `null` check on a potentially nullable type parameter.
1718
18-
Given a generic type parameter `T` which has a nullable bound (e.g. the default
19-
bound of `Object?`), it is very easy to introduce erroneous null checks when
19+
Given a generic type parameter `T` which has a nullable bound (e.g., the default
20+
bound of `Object?`), it is very easy to introduce erroneous `null` checks when
2021
working with a variable of type `T?`. Specifically, it is not uncommon to have
2122
`T? x;` and want to assert that `x` has been set to a valid value of type `T`.
2223
A common mistake is to do so using `x!`. This is almost always incorrect, since
@@ -26,7 +27,7 @@ if `T` is a nullable type, `x` may validly hold `null` as a value of type `T`.
2627
```dart
2728
T run<T>(T callback()) {
2829
T? result;
29-
(() { result = callback(); })();
30+
(() { result = callback(); })();
3031
return result!;
3132
}
3233
```
@@ -35,7 +36,7 @@ T run<T>(T callback()) {
3536
```dart
3637
T run<T>(T callback()) {
3738
T? result;
38-
(() { result = callback(); })();
39+
(() { result = callback(); })();
3940
return result as T;
4041
}
4142
```

pkg/linter/lib/src/rules/prefer_conditional_assignment.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import '../analyzer.dart';
1010
import '../extensions.dart';
1111
import '../util/dart_type_utilities.dart' as type_utils;
1212

13-
const _desc = r'Prefer using `??=` over testing for null.';
13+
const _desc = r'Prefer using `??=` over testing for `null`.';
1414

1515
const _details = r'''
16-
**PREFER** using `??=` over testing for null.
16+
**PREFER** using `??=` over testing for `null`.
1717
1818
As Dart has the `??=` operator, it is advisable to use it where applicable to
1919
improve the brevity of your code.

pkg/linter/lib/src/rules/prefer_const_constructors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_import
1111
import '../analyzer.dart';
1212
import '../extensions.dart';
1313

14-
const _desc = r'Prefer const with constant constructors.';
14+
const _desc = r'Prefer `const` with constant constructors.';
1515

1616
const _details = r'''
1717
**PREFER** using `const` for instantiating constant constructors.

pkg/linter/lib/src/rules/prefer_const_constructors_in_immutables.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import 'package:collection/collection.dart' show IterableExtension;
1010

1111
import '../analyzer.dart';
1212

13-
const _desc = r'Prefer declaring const constructors on `@immutable` classes.';
13+
const _desc = r'Prefer declaring `const` constructors on `@immutable` classes.';
1414

1515
const _details = r'''
16-
**PREFER** declaring const constructors on `@immutable` classes.
16+
**PREFER** declaring `const` constructors on `@immutable` classes.
1717
1818
If a class is immutable, it is usually a good idea to make its constructor a
19-
const constructor.
19+
`const` constructor.
2020
2121
**BAD:**
2222
```dart

pkg/linter/lib/src/rules/prefer_const_declarations.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import 'package:analyzer/dart/ast/visitor.dart';
99
import '../analyzer.dart';
1010
import '../ast.dart';
1111

12-
const _desc = r'Prefer const over final for declarations.';
12+
const _desc = r'Prefer `const` over `final` for declarations.';
1313

1414
const _details = r'''
15-
**PREFER** using `const` for const declarations.
15+
**PREFER** using `const` for constant-valued declarations.
1616
17-
Const declarations are more hot-reload friendly and allow to use const
18-
constructors if an instantiation references this declaration.
17+
Constant declarations are more hot-reload friendly and allows
18+
the value to be used in other constant expressions.
1919
2020
**BAD:**
2121
```dart

pkg/linter/lib/src/rules/prefer_final_fields.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import 'package:analyzer/dart/element/element.dart';
1010
import '../analyzer.dart';
1111
import '../extensions.dart';
1212

13-
const _desc = r'Private field could be final.';
13+
const _desc = r'Private field could be `final`.';
1414

1515
const _details = r'''
16-
**DO** prefer declaring private fields as final if they are not reassigned later
17-
in the library.
16+
**DO** prefer declaring private fields as `final` if they are not reassigned
17+
later in the library.
1818
19-
Declaring fields as final when possible is a good practice because it helps
19+
Declaring fields as `final` when possible is a good practice because it helps
2020
avoid accidental reassignments and allows the compiler to do optimizations.
2121
2222
**BAD:**

pkg/linter/lib/src/rules/prefer_for_elements_to_map_fromIterable.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import 'package:analyzer/dart/ast/visitor.dart';
88

99
import '../analyzer.dart';
1010

11-
const _desc = r"Prefer 'for' elements when building maps from iterables.";
11+
const _desc = r'Prefer `for` elements when building maps from iterables.';
1212

1313
const _details = r'''
14-
When building maps from iterables, it is preferable to use 'for' elements.
14+
When building maps from iterables, it is preferable to use `for` elements.
1515
1616
Using 'for' elements brings several benefits including:
1717

0 commit comments

Comments
 (0)