Skip to content

Commit f87dd91

Browse files
pqcommit-bot@chromium.org
authored andcommitted
remove defaults from the lint rule registry
Fixes: #35708 Change-Id: I619a3ec5533f85c8f0b1e5c017c5cd8f1b422fbd Reviewed-on: https://dart-review.googlesource.com/c/90360 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 16bcfbb commit f87dd91

File tree

3 files changed

+4
-42
lines changed

3 files changed

+4
-42
lines changed

pkg/analyzer/lib/src/context/builder.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,6 @@ class ContextBuilder {
483483
if (builderOptions.argResults != null) {
484484
applyAnalysisOptionFlags(options, builderOptions.argResults,
485485
verbosePrint: verbosePrint);
486-
// If lints turned on but none specified, then enable default lints
487-
if (options.lint && options.lintRules.isEmpty) {
488-
options.lintRules = Registry.ruleRegistry.defaultRules;
489-
verbose('Using default lint rules');
490-
}
491486
}
492487
} else {
493488
verbose('Using default analysis options');

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ class Registry with IterableMixin<LintRule> {
2121
*/
2222
Map<String, LintRule> _ruleMap = <String, LintRule>{};
2323

24-
/**
25-
* A list of the default lint rules.
26-
*/
27-
List<LintRule> _defaultRules = <LintRule>[];
28-
29-
/**
30-
* Return a list of the default lint rules.
31-
*/
32-
List<LintRule> get defaultRules => _defaultRules;
33-
3424
@override
3525
Iterator<LintRule> get iterator => _ruleMap.values.iterator;
3626

@@ -69,12 +59,9 @@ class Registry with IterableMixin<LintRule> {
6959
_ruleMap[rule.name] = rule;
7060
}
7161

72-
/**
73-
* Add the given lint [rule] to this registry and mark it as being a default
74-
* lint (one that will be run if lints are requested but no rules are enabled.
75-
*/
62+
// todo (pq): remove once linter-0.1.79 is in DEPS.
63+
@deprecated
7664
void registerDefault(LintRule rule) {
7765
register(rule);
78-
_defaultRules.add(rule);
7966
}
8067
}

pkg/analyzer/test/src/context/builder_test.dart

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -111,26 +111,6 @@ const Map<String, LibraryInfo> libraries = const {
111111
fail('Incomplete test');
112112
}
113113

114-
void test_cmdline_lint_default() {
115-
_defineMockLintRules();
116-
ArgParser argParser = new ArgParser();
117-
defineAnalysisArguments(argParser);
118-
ArgResults argResults = argParser.parse(['--$lintsFlag']);
119-
var builder = new ContextBuilder(resourceProvider, sdkManager, contentCache,
120-
options: createContextBuilderOptions(argResults));
121-
122-
AnalysisOptionsImpl expected = new AnalysisOptionsImpl();
123-
expected.lint = true;
124-
expected.lintRules = Registry.ruleRegistry.defaultRules;
125-
126-
String path = convertPath('/some/directory/path');
127-
String filePath = join(path, AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE);
128-
newFile(filePath);
129-
130-
AnalysisOptions options = builder.getAnalysisOptions(path);
131-
_expectEqualOptions(options, expected);
132-
}
133-
134114
void test_cmdline_lint_defined() {
135115
_defineMockLintRules();
136116
ArgParser argParser = new ArgParser();
@@ -941,9 +921,9 @@ environment:
941921

942922
_defineMockLintRules() {
943923
_mockLintRule = new _MockLintRule('mock_lint_rule');
944-
Registry.ruleRegistry.registerDefault(_mockLintRule);
924+
Registry.ruleRegistry.register(_mockLintRule);
945925
_mockLintRule2 = new _MockLintRule('mock_lint_rule2');
946-
Registry.ruleRegistry.registerDefault(_mockLintRule2);
926+
Registry.ruleRegistry.register(_mockLintRule2);
947927
_mockLintRule3 = new _MockLintRule('mock_lint_rule3');
948928
Registry.ruleRegistry.register(_mockLintRule3);
949929
_mockPublicMemberApiDocs = new _MockLintRule('public_member_api_docs');

0 commit comments

Comments
 (0)