Migrate the last AnalysisOptionsHintCodes to be Warnings
Change-Id: I8f9826a57e434a185d6c0d68e2ccbd1c2610885d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425157
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
index 6dfbf63..f5dd1da 100644
--- a/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
+++ b/pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml
@@ -58,20 +58,20 @@
notes: |-
Because of the way the YAML parser works, there isn't enough information to
be able to provide a fix.
-AnalysisOptionsHintCode.DEPRECATED_LINT:
- status: hasFix
-AnalysisOptionsHintCode.DEPRECATED_LINT_WITH_REPLACEMENT:
- status: needsFix
- notes: |-
- We should be able to replace the deprecated lint rule with its replacement.
-AnalysisOptionsHintCode.DUPLICATE_RULE:
- status: hasFix
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED:
status: needsFix
notes: |-
The fix is to remove the deprecated option.
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT:
status: hasFix
+AnalysisOptionsWarningCode.DEPRECATED_LINT:
+ status: hasFix
+AnalysisOptionsWarningCode.DEPRECATED_LINT_WITH_REPLACEMENT:
+ status: needsFix
+ notes: |-
+ We should be able to replace the deprecated lint rule with its replacement.
+AnalysisOptionsWarningCode.DUPLICATE_RULE:
+ status: hasFix
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND:
status: noFix
notes: |-
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/analysis_options/fix_generator.dart b/pkg/analysis_server/lib/src/services/correction/fix/analysis_options/fix_generator.dart
index 1053fdd..fa71095 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/analysis_options/fix_generator.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/analysis_options/fix_generator.dart
@@ -30,9 +30,9 @@
/// The generator used to generate fixes in analysis options files.
class AnalysisOptionsFixGenerator {
static const List<ErrorCode> codesWithFixes = [
- AnalysisOptionsHintCode.DEPRECATED_LINT,
+ AnalysisOptionsWarningCode.DEPRECATED_LINT,
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT,
- AnalysisOptionsHintCode.DUPLICATE_RULE,
+ AnalysisOptionsWarningCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.REMOVED_LINT,
AnalysisOptionsWarningCode.UNDEFINED_LINT,
AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITHOUT_VALUES,
@@ -115,8 +115,8 @@
strongModeMap,
);
}
- } else if (errorCode == AnalysisOptionsHintCode.DEPRECATED_LINT ||
- errorCode == AnalysisOptionsHintCode.DUPLICATE_RULE ||
+ } else if (errorCode == AnalysisOptionsWarningCode.DEPRECATED_LINT ||
+ errorCode == AnalysisOptionsWarningCode.DUPLICATE_RULE ||
errorCode == AnalysisOptionsWarningCode.REMOVED_LINT ||
errorCode == AnalysisOptionsWarningCode.UNDEFINED_LINT) {
await _addFix_removeLint(coveringNodePath);
diff --git a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
index b2372df..ca31e06 100644
--- a/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
+++ b/pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart
@@ -65,61 +65,6 @@
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
}
-class AnalysisOptionsHintCode extends ErrorCode {
- /// A hint code indicating reference to a deprecated lint.
- ///
- /// Parameters:
- /// 0: the rule name
- static const AnalysisOptionsHintCode DEPRECATED_LINT =
- AnalysisOptionsHintCode(
- 'DEPRECATED_LINT',
- "'{0}' is a deprecated lint rule and should not be used.",
- correctionMessage: "Try removing '{0}'.",
- );
-
- /// A hint code indicating reference to a deprecated lint.
- ///
- /// Parameters:
- /// 0: the deprecated lint name
- /// 1: the replacing rule name
- static const AnalysisOptionsHintCode DEPRECATED_LINT_WITH_REPLACEMENT =
- AnalysisOptionsHintCode(
- 'DEPRECATED_LINT_WITH_REPLACEMENT',
- "'{0}' is deprecated and should be replaced by '{1}'.",
- correctionMessage: "Try replacing '{0}' with '{1}'.",
- );
-
- /// Duplicate rules.
- ///
- /// Parameters:
- /// 0: the rule name
- static const AnalysisOptionsHintCode DUPLICATE_RULE = AnalysisOptionsHintCode(
- 'DUPLICATE_RULE',
- "The rule {0} is already specified and doesn't need to be specified again.",
- correctionMessage: "Try removing all but one specification of the rule.",
- );
-
- /// Initialize a newly created error code to have the given [name].
- const AnalysisOptionsHintCode(
- String name,
- String problemMessage, {
- super.correctionMessage,
- super.hasPublishedDocs = false,
- super.isUnresolvedIdentifier = false,
- String? uniqueName,
- }) : super(
- name: name,
- problemMessage: problemMessage,
- uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
- );
-
- @override
- ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
-
- @override
- ErrorType get type => ErrorType.HINT;
-}
-
class AnalysisOptionsWarningCode extends ErrorCode {
/// An error code indicating that the given option is deprecated.
///
@@ -145,6 +90,40 @@
uniqueName: 'ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT',
);
+ /// A hint code indicating reference to a deprecated lint.
+ ///
+ /// Parameters:
+ /// 0: the rule name
+ static const AnalysisOptionsWarningCode DEPRECATED_LINT =
+ AnalysisOptionsWarningCode(
+ 'DEPRECATED_LINT',
+ "'{0}' is a deprecated lint rule and should not be used.",
+ correctionMessage: "Try removing '{0}'.",
+ );
+
+ /// A hint code indicating reference to a deprecated lint.
+ ///
+ /// Parameters:
+ /// 0: the deprecated lint name
+ /// 1: the replacing rule name
+ static const AnalysisOptionsWarningCode DEPRECATED_LINT_WITH_REPLACEMENT =
+ AnalysisOptionsWarningCode(
+ 'DEPRECATED_LINT_WITH_REPLACEMENT',
+ "'{0}' is deprecated and should be replaced by '{1}'.",
+ correctionMessage: "Try replacing '{0}' with '{1}'.",
+ );
+
+ /// Duplicate rules.
+ ///
+ /// Parameters:
+ /// 0: the rule name
+ static const AnalysisOptionsWarningCode
+ DUPLICATE_RULE = AnalysisOptionsWarningCode(
+ 'DUPLICATE_RULE',
+ "The rule {0} is already specified and doesn't need to be specified again.",
+ correctionMessage: "Try removing all but one specification of the rule.",
+ );
+
/// An error code indicating a specified include file has a warning.
///
/// Parameters:
diff --git a/pkg/analyzer/lib/src/error/error_code_values.g.dart b/pkg/analyzer/lib/src/error/error_code_values.g.dart
index 4776ed0..f668306 100644
--- a/pkg/analyzer/lib/src/error/error_code_values.g.dart
+++ b/pkg/analyzer/lib/src/error/error_code_values.g.dart
@@ -27,11 +27,11 @@
const List<ErrorCode> errorCodeValues = [
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR,
AnalysisOptionsErrorCode.PARSE_ERROR,
- AnalysisOptionsHintCode.DEPRECATED_LINT,
- AnalysisOptionsHintCode.DEPRECATED_LINT_WITH_REPLACEMENT,
- AnalysisOptionsHintCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED,
AnalysisOptionsWarningCode.ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT,
+ AnalysisOptionsWarningCode.DEPRECATED_LINT,
+ AnalysisOptionsWarningCode.DEPRECATED_LINT_WITH_REPLACEMENT,
+ AnalysisOptionsWarningCode.DUPLICATE_RULE,
AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING,
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
AnalysisOptionsWarningCode.INCOMPATIBLE_LINT,
diff --git a/pkg/analyzer/lib/src/lint/options_rule_validator.dart b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
index b2d5378..ad54f35 100644
--- a/pkg/analyzer/lib/src/lint/options_rule_validator.dart
+++ b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
@@ -92,7 +92,7 @@
} else if (!seenRules.add(rule.name)) {
reporter.atSourceSpan(
node.span,
- AnalysisOptionsHintCode.DUPLICATE_RULE,
+ AnalysisOptionsWarningCode.DUPLICATE_RULE,
arguments: [value],
);
}
@@ -106,13 +106,13 @@
if (replacedBy != null) {
reporter.atSourceSpan(
node.span,
- AnalysisOptionsHintCode.DEPRECATED_LINT_WITH_REPLACEMENT,
+ AnalysisOptionsWarningCode.DEPRECATED_LINT_WITH_REPLACEMENT,
arguments: [value, replacedBy],
);
} else {
reporter.atSourceSpan(
node.span,
- AnalysisOptionsHintCode.DEPRECATED_LINT,
+ AnalysisOptionsWarningCode.DEPRECATED_LINT,
arguments: [value],
);
}
diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml
index ece392e..2c4ad52 100644
--- a/pkg/analyzer/messages.yaml
+++ b/pkg/analyzer/messages.yaml
@@ -61,7 +61,26 @@
Parameters:
0: the error message from the parse error
-AnalysisOptionsHintCode:
+AnalysisOptionsWarningCode:
+ ANALYSIS_OPTION_DEPRECATED:
+ problemMessage: "The option '{0}' is no longer supported."
+ hasPublishedDocs: false
+ comment: |
+ An error code indicating that the given option is deprecated.
+
+ Parameters:
+ 0: the option name
+ ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT:
+ sharedName: ANALYSIS_OPTION_DEPRECATED
+ problemMessage: "The option '{0}' is no longer supported."
+ correctionMessage: "Try using the new '{1}' option."
+ hasPublishedDocs: false
+ comment: |-
+ An error code indicating that the given option is deprecated.
+
+ Parameters:
+ 0: the option name
+ 1: the replacement option name
DEPRECATED_LINT:
problemMessage: "'{0}' is a deprecated lint rule and should not be used."
correctionMessage: Try removing '{0}'.
@@ -90,26 +109,6 @@
Parameters:
0: the rule name
-AnalysisOptionsWarningCode:
- ANALYSIS_OPTION_DEPRECATED:
- problemMessage: "The option '{0}' is no longer supported."
- hasPublishedDocs: false
- comment: |
- An error code indicating that the given option is deprecated.
-
- Parameters:
- 0: the option name
- ANALYSIS_OPTION_DEPRECATED_WITH_REPLACEMENT:
- sharedName: ANALYSIS_OPTION_DEPRECATED
- problemMessage: "The option '{0}' is no longer supported."
- correctionMessage: "Try using the new '{1}' option."
- hasPublishedDocs: false
- comment: |-
- An error code indicating that the given option is deprecated.
-
- Parameters:
- 0: the option name
- 1: the replacement option name
INCLUDED_FILE_WARNING:
problemMessage: "Warning in the included options file {0}({1}..{2}): {3}"
hasPublishedDocs: false
diff --git a/pkg/analyzer/test/src/options/options_rule_validator_test.dart b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
index c427e48..797181c 100644
--- a/pkg/analyzer/test/src/options/options_rule_validator_test.dart
+++ b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
@@ -80,7 +80,7 @@
rules:
- deprecated_lint_with_replacement
''',
- [AnalysisOptionsHintCode.DEPRECATED_LINT_WITH_REPLACEMENT],
+ [AnalysisOptionsWarningCode.DEPRECATED_LINT_WITH_REPLACEMENT],
);
}
@@ -91,7 +91,7 @@
rules:
deprecated_lint: false
''',
- [AnalysisOptionsHintCode.DEPRECATED_LINT],
+ [AnalysisOptionsWarningCode.DEPRECATED_LINT],
);
}
@@ -102,7 +102,7 @@
rules:
- deprecated_lint
''',
- [AnalysisOptionsHintCode.DEPRECATED_LINT],
+ [AnalysisOptionsWarningCode.DEPRECATED_LINT],
);
}
@@ -113,7 +113,7 @@
rules:
- deprecated_since_3_lint
''',
- [AnalysisOptionsHintCode.DEPRECATED_LINT],
+ [AnalysisOptionsWarningCode.DEPRECATED_LINT],
sdk: dart3,
);
}
@@ -150,7 +150,7 @@
- stable_lint
- stable_lint
''',
- [AnalysisOptionsHintCode.DUPLICATE_RULE],
+ [AnalysisOptionsWarningCode.DUPLICATE_RULE],
);
}
diff --git a/pkg/analyzer/tool/messages/error_code_info.dart b/pkg/analyzer/tool/messages/error_code_info.dart
index 14b5e48..b2f42b8 100644
--- a/pkg/analyzer/tool/messages/error_code_info.dart
+++ b/pkg/analyzer/tool/messages/error_code_info.dart
@@ -21,12 +21,6 @@
),
ErrorClassInfo(
filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
- name: 'AnalysisOptionsHintCode',
- type: 'HINT',
- severity: 'INFO',
- ),
- ErrorClassInfo(
- filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
name: 'AnalysisOptionsWarningCode',
type: 'STATIC_WARNING',
severity: 'WARNING',