Skip to content

Commit a8331cd

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Remove the STRONG_MODE_ prefix from error codes
Change-Id: Id8bacbd52f13030dc614952576e8576368e44b28 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108688 Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 4c5028d commit a8331cd

File tree

4 files changed

+41
-57
lines changed

4 files changed

+41
-57
lines changed

pkg/analyzer/lib/src/error/codes.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4978,8 +4978,6 @@ class StaticWarningCode extends ErrorCode {
49784978
*
49794979
* These error codes tend to use the same message across different severity
49804980
* levels, so they are grouped for clarity.
4981-
*
4982-
* All of these error codes also use the "STRONG_MODE_" prefix in their name.
49834981
*/
49844982
class StrongModeCode extends ErrorCode {
49854983
static const String _implicitCastMessage =
@@ -5233,7 +5231,7 @@ class StrongModeCode extends ErrorCode {
52335231
const StrongModeCode(ErrorType type, String name, String message,
52345232
{String correction, bool hasPublishedDocs})
52355233
: type = type,
5236-
super.temporary('STRONG_MODE_$name', message,
5234+
super.temporary(name, message,
52375235
correction: correction, hasPublishedDocs: hasPublishedDocs);
52385236

52395237
@override

pkg/analyzer/lib/src/task/strong/checker.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ class CodeChecker extends RecursiveAstVisitor {
12781278
_failure = true;
12791279
}
12801280
if (errorCode.type == ErrorType.HINT &&
1281-
errorCode.name.startsWith('STRONG_MODE_TOP_LEVEL_')) {
1281+
errorCode.name.startsWith('TOP_LEVEL_')) {
12821282
severity = ErrorSeverity.ERROR;
12831283
}
12841284
if (severity != ErrorSeverity.INFO || _options.strongModeHints) {

pkg/analyzer/test/src/task/options_test.dart

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@ class ContextConfigurationTest {
4949
YamlMap parseOptions(String source) =>
5050
optionsProvider.getOptionsFromString(source);
5151

52+
test_configure_chromeos_checks() {
53+
configureContext('''
54+
analyzer:
55+
optional-checks:
56+
chrome-os-manifest-checks
57+
''');
58+
expect(true, analysisOptions.chromeOsManifestChecks);
59+
}
60+
61+
test_configure_chromeos_checks_map() {
62+
configureContext('''
63+
analyzer:
64+
optional-checks:
65+
chrome-os-manifest-checks : true
66+
''');
67+
expect(true, analysisOptions.chromeOsManifestChecks);
68+
}
69+
5270
test_configure_error_processors() {
5371
configureContext('''
5472
analyzer:
@@ -126,24 +144,6 @@ analyzer:
126144
List<String> names = analysisOptions.enabledPluginNames;
127145
expect(names, ['angular2']);
128146
}
129-
130-
test_configure_chromeos_checks() {
131-
configureContext('''
132-
analyzer:
133-
optional-checks:
134-
chrome-os-manifest-checks
135-
''');
136-
expect(true, analysisOptions.chromeOsManifestChecks);
137-
}
138-
139-
test_configure_chromeos_checks_map() {
140-
configureContext('''
141-
analyzer:
142-
optional-checks:
143-
chrome-os-manifest-checks : true
144-
''');
145-
expect(true, analysisOptions.chromeOsManifestChecks);
146-
}
147147
}
148148

149149
@reflectiveTest
@@ -188,11 +188,7 @@ class ErrorCodeValuesTest {
188188
'_PLUS');
189189
} else if (errorType == StrongModeCode) {
190190
void removeCode(StrongModeCode code) {
191-
String name = code.name;
192-
declaredNames.remove(name);
193-
if (name.startsWith('STRONG_MODE_')) {
194-
declaredNames.remove(name.substring(12));
195-
}
191+
declaredNames.remove(code.name);
196192
}
197193

198194
removeCode(StrongModeCode.DOWN_CAST_COMPOSITE);
@@ -430,7 +426,7 @@ analyzer:
430426
validate('''
431427
analyzer:
432428
errors:
433-
strong_mode_assignment_cast: ignore
429+
assignment_cast: ignore
434430
''', []);
435431
}
436432

@@ -479,22 +475,6 @@ analyzer:
479475
''', [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUES]);
480476
}
481477

482-
test_linter_supported_rules() {
483-
Registry.ruleRegistry.register(new TestRule());
484-
validate('''
485-
linter:
486-
rules:
487-
- fantastic_test_rule
488-
''', []);
489-
}
490-
491-
test_linter_unsupported_option() {
492-
validate('''
493-
linter:
494-
unsupported: true
495-
''', [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
496-
}
497-
498478
test_chromeos_manifest_checks() {
499479
validate('''
500480
analyzer:
@@ -511,6 +491,22 @@ analyzer:
511491
''', [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
512492
}
513493

494+
test_linter_supported_rules() {
495+
Registry.ruleRegistry.register(new TestRule());
496+
validate('''
497+
linter:
498+
rules:
499+
- fantastic_test_rule
500+
''', []);
501+
}
502+
503+
test_linter_unsupported_option() {
504+
validate('''
505+
linter:
506+
unsupported: true
507+
''', [AnalysisOptionsWarningCode.UNSUPPORTED_OPTION_WITH_LEGAL_VALUE]);
508+
}
509+
514510
void validate(String source, List<ErrorCode> expected) {
515511
var options = optionsProvider.getOptionsFromString(source);
516512
var errors = validator.validate(options);

pkg/analyzer/test/src/task/strong/strong_test_helper.dart

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,11 @@ SourceSpanWithContext _createSpanHelper(
5555
return new SourceSpanWithContext(startLoc, endLoc, text, lineText);
5656
}
5757

58-
String _errorCodeName(ErrorCode errorCode) {
59-
var name = errorCode.name;
60-
final prefix = 'STRONG_MODE_';
61-
if (name.startsWith(prefix)) {
62-
return name.substring(prefix.length);
63-
} else {
64-
return name;
65-
}
66-
}
67-
6858
ErrorSeverity _errorSeverity(
6959
AnalysisOptions analysisOptions, AnalysisError error) {
7060
// TODO(brianwilkerson) Remove the if when top-level inference is made an
7161
// error again.
72-
if (error.errorCode.name.startsWith('STRONG_MODE_TOP_LEVEL_')) {
62+
if (error.errorCode.name.startsWith('TOP_LEVEL_')) {
7363
return ErrorSeverity.ERROR;
7464
}
7565
return ErrorProcessor.getProcessor(analysisOptions, error)?.severity ??
@@ -192,7 +182,7 @@ void _reportFailure(
192182
resolutionMap.elementDeclaredByCompilationUnit(unit).source, sourceCode,
193183
end: offset + length);
194184
var levelName = _errorSeverity(analysisOptions, error).displayName;
195-
return '@$offset $levelName:${_errorCodeName(error.errorCode)}\n' +
185+
return '@$offset $levelName:${error.errorCode.name}\n' +
196186
span.message(error.message);
197187
}
198188

@@ -411,7 +401,7 @@ class _ErrorExpectation {
411401

412402
bool matches(AnalysisOptions options, AnalysisError e) {
413403
return _errorSeverity(options, e) == severity &&
414-
_errorCodeName(e.errorCode) == typeName;
404+
e.errorCode.name == typeName;
415405
}
416406

417407
String toString() => '@$offset ${severity.displayName}: [$typeName]';

0 commit comments

Comments
 (0)