quick fix for DUPLICATE_RULE

Change-Id: I49c75bcaa12eefc06b1e906983b482a51466c134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/367740
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
pq 2024-05-22 19:56:24 +00:00 committed by Commit Queue
parent 286715bda3
commit af7355d34b
3 changed files with 19 additions and 6 deletions

View file

@ -45,8 +45,8 @@
#
# Stats:
# - 42 "needsEvaluation"
# - 365 "needsFix"
# - 386 "hasFix"
# - 364 "needsFix"
# - 387 "hasFix"
# - 516 "noFix"
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
@ -65,9 +65,7 @@ AnalysisOptionsHintCode.DEPRECATED_LINT_WITH_REPLACEMENT:
notes: |-
We should be able to replace the deprecated lint rule with its replacement.
AnalysisOptionsHintCode.DUPLICATE_RULE:
status: needsFix
notes: |-
We could offer to remove the duplicate rule.
status: hasFix
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED:
status: needsFix
notes: |-

View file

@ -28,6 +28,7 @@ class AnalysisOptionsFixGenerator {
static const List<ErrorCode> codesWithFixes = [
AnalysisOptionsHintCode.DEPRECATED_LINT,
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT,
AnalysisOptionsHintCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
];
@ -97,7 +98,8 @@ class AnalysisOptionsFixGenerator {
await _addFix_replaceWithStrictRawTypes(
coveringNodePath, analyzerMap, strongModeMap);
}
} else if (errorCode == AnalysisOptionsHintCode.DEPRECATED_LINT) {
} else if (errorCode == AnalysisOptionsHintCode.DEPRECATED_LINT ||
errorCode == AnalysisOptionsHintCode.DUPLICATE_RULE) {
await _addFix_removeLint(coveringNodePath);
} else if (errorCode ==
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES) {

View file

@ -94,6 +94,19 @@ analyzer:
exclude:
- test/data/**
linter:
rules:
- camel_case_types
''');
}
Future<void> test_duplicated() async {
await assertHasFix('''
linter:
rules:
- camel_case_types
- camel_case_types
''', '''
linter:
rules:
- camel_case_types