Skip to content

Commit 6c6b104

Browse files
srawlinsCommit Queue
authored andcommitted
linter: Allow each LintRule multiple categories
Spelled out at https://github.com/dart-lang/linter/issues/1020 Fixes https://github.com/dart-lang/linter/issues/1020 This CL does not change the categories/groups that any rule has. We can add/change categories in later CLs. Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try Change-Id: Ief2856a6c472492bbad19fc95df172ef8d19fe7b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369861 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Commit-Queue: Sam Rawlins <[email protected]>
1 parent 63d6e6f commit 6c6b104

File tree

252 files changed

+274
-297
lines changed

Some content is hidden

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

252 files changed

+274
-297
lines changed

pkg/analysis_server/test/lsp/code_actions_fixes_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DeprecatedCamelCaseTypes extends LintRule {
2727
DeprecatedCamelCaseTypes()
2828
: super(
2929
name: 'camel_case_types',
30-
group: Group.style,
30+
categories: {Category.style},
3131
state: State.deprecated(),
3232
description: '',
3333
details: '',

pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ class InternalLint extends LintRule {
259259
InternalLint()
260260
: super(
261261
name: 'internal_lint',
262-
group: Group.style,
262+
categories: {Category.style},
263263
state: State.internal(),
264264
description: '',
265265
details: '',

pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class DeprecatedRule extends LintRule {
2121
name: 'deprecated_rule',
2222
description: '',
2323
details: '...',
24-
group: Group.errors,
24+
categories: {Category.errors},
2525
state: State.deprecated(since: dart2_12),
2626
);
2727
}
@@ -32,7 +32,7 @@ class RemovedRule extends LintRule {
3232
name: 'removed_rule',
3333
description: '',
3434
details: '...',
35-
group: Group.errors,
35+
categories: {Category.errors},
3636
state: State.removed());
3737
}
3838

pkg/analyzer/lib/src/lint/linter.dart

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,18 @@ export 'package:analyzer/src/lint/linter_visitor.dart' show NodeLintRegistry;
3535
export 'package:analyzer/src/lint/state.dart'
3636
show dart2_12, dart3, dart3_3, State;
3737

38-
abstract class Group {
39-
/// A group representing possible coding errors.
38+
final class Category {
39+
/// A category representing possible coding errors.
4040
static const String errors = 'errors';
4141

42-
/// A group representing Pub-related rules.
42+
/// A category representing Pub-related rules.
4343
static const String pub = 'pub';
4444

45-
/// A group representing matters of style, largely derived from Effective
45+
/// A category representing matters of style, largely derived from Effective
4646
/// Dart.
4747
static const String style = 'style';
4848
}
4949

50-
@visibleForTesting
51-
class Hyperlink {
52-
final String _label;
53-
final String _href;
54-
final bool _bold;
55-
56-
const Hyperlink(this._label, this._href, {bool bold = false}) : _bold = bold;
57-
58-
String get html => '<a href="$_href">${_emph(_label)}</a>';
59-
60-
String _emph(String msg) => _bold ? '<strong>$msg</strong>' : msg;
61-
}
62-
6350
/// The result of attempting to evaluate an expression.
6451
class LinterConstantEvaluationResult {
6552
/// The value of the expression, or `null` if has [errors].
@@ -213,8 +200,8 @@ abstract class LintRule {
213200
/// Short description suitable for display in console output.
214201
final String description;
215202

216-
/// Lint group (for example, 'style').
217-
final String group;
203+
/// Lint groups (for example, 'style', 'errors', 'pub').
204+
final Set<String> categories;
218205

219206
/// Lint name.
220207
final String name;
@@ -233,7 +220,7 @@ abstract class LintRule {
233220

234221
LintRule({
235222
required this.name,
236-
required this.group,
223+
required this.categories,
237224
required this.description,
238225
required this.details,
239226
State? state,

pkg/analyzer/test/src/diagnostics/removed_lint_use_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RemovedLint extends LintRule {
1919
RemovedLint()
2020
: super(
2121
name: 'removed_lint',
22-
group: Group.style,
22+
categories: {Category.style},
2323
state: State.removed(since: dart3),
2424
description: '',
2525
details: '',

pkg/analyzer/test/src/diagnostics/replaced_lint_use_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RemovedLint extends LintRule {
1919
RemovedLint()
2020
: super(
2121
name: 'removed_lint',
22-
group: Group.style,
22+
categories: {Category.style},
2323
state: State.removed(since: dart3, replacedBy: 'replacing_lint'),
2424
description: '',
2525
details: '',
@@ -65,7 +65,7 @@ class ReplacingLint extends LintRule {
6565
ReplacingLint()
6666
: super(
6767
name: 'replacing_lint',
68-
group: Group.style,
68+
categories: {Category.style},
6969
state: State.removed(since: dart3),
7070
description: '',
7171
details: '',

pkg/analyzer/test/src/diagnostics/unignorable_ignore_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class _AvoidIntRule extends LintRule {
7777
name: 'avoid_int',
7878
description: '',
7979
details: '',
80-
group: Group.errors,
80+
categories: {Category.errors},
8181
);
8282

8383
@override

pkg/analyzer/test/src/lint/lint_rule_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class TestRule extends LintRule {
139139
name: 'test_rule',
140140
description: '',
141141
details: '... tl;dr ...',
142-
group: Group.errors,
142+
categories: {Category.errors},
143143
);
144144
}
145145

pkg/analyzer/test/src/options/apply_options_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,14 @@ class TestRule extends LintRule {
375375
name: 'fantastic_test_rule',
376376
description: '',
377377
details: '',
378-
group: Group.style,
378+
categories: {Category.style},
379379
);
380380

381381
TestRule.withName(String name)
382382
: super(
383383
name: name,
384384
description: '',
385385
details: '',
386-
group: Group.style,
386+
categories: {Category.style},
387387
);
388388
}

pkg/analyzer/test/src/options/options_rule_validator_test.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DeprecatedLint extends LintRule {
2727
DeprecatedLint()
2828
: super(
2929
name: 'deprecated_lint',
30-
group: Group.style,
30+
categories: {Category.style},
3131
state: State.deprecated(),
3232
description: '',
3333
details: '',
@@ -38,7 +38,7 @@ class DeprecatedLintWithReplacement extends LintRule {
3838
DeprecatedLintWithReplacement()
3939
: super(
4040
name: 'deprecated_lint_with_replacement',
41-
group: Group.style,
41+
categories: {Category.style},
4242
state: State.deprecated(replacedBy: 'replacing_lint'),
4343
description: '',
4444
details: '',
@@ -49,7 +49,7 @@ class DeprecatedSince3Lint extends LintRule {
4949
DeprecatedSince3Lint()
5050
: super(
5151
name: 'deprecated_since_3_lint',
52-
group: Group.style,
52+
categories: {Category.style},
5353
state: State.deprecated(since: dart3),
5454
description: '',
5555
details: '',
@@ -293,7 +293,7 @@ class RemovedIn2_12Lint extends LintRule {
293293
RemovedIn2_12Lint()
294294
: super(
295295
name: 'removed_in_2_12_lint',
296-
group: Group.style,
296+
categories: {Category.style},
297297
state: State.removed(since: dart2_12),
298298
description: '',
299299
details: '',
@@ -304,7 +304,7 @@ class ReplacedLint extends LintRule {
304304
ReplacedLint()
305305
: super(
306306
name: 'replaced_lint',
307-
group: Group.style,
307+
categories: {Category.style},
308308
state: State.removed(since: dart3, replacedBy: 'replacing_lint'),
309309
description: '',
310310
details: '',
@@ -315,7 +315,7 @@ class ReplacingLint extends LintRule {
315315
ReplacingLint()
316316
: super(
317317
name: 'replacing_lint',
318-
group: Group.style,
318+
categories: {Category.style},
319319
description: '',
320320
details: '',
321321
);
@@ -325,7 +325,7 @@ class RuleNeg extends LintRule {
325325
RuleNeg()
326326
: super(
327327
name: 'rule_neg',
328-
group: Group.style,
328+
categories: {Category.style},
329329
description: '',
330330
details: '',
331331
);
@@ -338,7 +338,7 @@ class RulePos extends LintRule {
338338
RulePos()
339339
: super(
340340
name: 'rule_pos',
341-
group: Group.style,
341+
categories: {Category.style},
342342
description: '',
343343
details: '',
344344
);
@@ -351,7 +351,7 @@ class StableLint extends LintRule {
351351
StableLint()
352352
: super(
353353
name: 'stable_lint',
354-
group: Group.style,
354+
categories: {Category.style},
355355
state: State.stable(),
356356
description: '',
357357
details: '',

0 commit comments

Comments
 (0)