Skip to content

Commit

Permalink
Enable 'unnecessary_breaks' in analyzer/.
Browse files Browse the repository at this point in the history
Change-Id: I46615f08175db25f24abf341376d571f270756cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/336831
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Nov 19, 2023
1 parent 24c368b commit 8b564e0
Show file tree
Hide file tree
Showing 11 changed files with 1 addition and 47 deletions.
1 change: 1 addition & 0 deletions pkg/analyzer/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ linter:
- flutter_style_todos
- library_annotations
- unawaited_futures
- unnecessary_breaks
- unnecessary_library_directive
- unnecessary_parenthesis
3 changes: 0 additions & 3 deletions pkg/analyzer/lib/src/dart/analysis/driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1265,16 +1265,13 @@ class AnalysisDriver implements AnalysisDriverGeneric {
switch (fileChange.kind) {
case _FileChangeKind.add:
_fileTracker.addFile(path);
break;
case _FileChangeKind.change:
_fileTracker.changeFile(path);
break;
case _FileChangeKind.remove:
_fileTracker.removeFile(path);
// TODO(scheglov): We have to do this because we discard files.
// But this is not right, we need to handle removing better.
clearLibraryContext();
break;
}
}
_pendingFileChanges.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ class SharedTypeAnalyzerErrors
WarningCode.UNNECESSARY_WILDCARD_PATTERN,
pattern,
);
break;
}
}
}
4 changes: 0 additions & 4 deletions pkg/analyzer/lib/src/fasta/ast_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,6 @@ class AstBuilder extends StackListener {
),
),
);
break;
case Assert.Initializer:
push(
AssertInitializerImpl(
Expand All @@ -926,7 +925,6 @@ class AstBuilder extends StackListener {
rightParenthesis: leftParenthesis.endGroup!,
),
);
break;
case Assert.Statement:
push(
AssertStatementImpl(
Expand All @@ -939,7 +937,6 @@ class AstBuilder extends StackListener {
semicolon: semicolon,
),
);
break;
}
}

Expand Down Expand Up @@ -2838,7 +2835,6 @@ class AstBuilder extends StackListener {
typeArguments: null,
question: null,
);
break;
}
if (firstFormalParameter.keyword case final keyword?) {
if (keyword.keyword != Keyword.CONST) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/analyzer/lib/src/lint/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ class _LintConfig implements LintConfig {
addAsListOrString(v['include'], fileIncludes);
addAsListOrString(v['exclude'], fileExcludes);
}
break;

case 'rules':

Expand Down Expand Up @@ -165,7 +164,6 @@ class _LintConfig implements LintConfig {
}
});
}
break;
}
});
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/analyzer/lib/src/lint/pub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,16 +378,12 @@ class _PSDependency extends PSDependency {
switch (key.toString()) {
case 'path':
dep.path = _processScalar(key, v, resourceProvider);
break;
case 'version':
dep.version = _processScalar(key, v, resourceProvider);
break;
case 'hosted':
dep.host = _processHost(key, v, resourceProvider);
break;
case 'git':
dep.git = _processGitRepo(key, v, resourceProvider);
break;
}
});
}
Expand Down Expand Up @@ -648,43 +644,30 @@ class _Pubspec implements Pubspec {
switch (key.toString()) {
case 'author':
author = _processScalar(key, v, resourceProvider);
break;
case 'authors':
authors = _processScalarList(key, v, resourceProvider);
break;
case 'homepage':
homepage = _processScalar(key, v, resourceProvider);
break;
case 'repository':
repository = _processScalar(key, v, resourceProvider);
break;
case 'issue_tracker':
issueTracker = _processScalar(key, v, resourceProvider);
break;
case 'name':
name = _processScalar(key, v, resourceProvider);
break;
case 'description':
description = _processScalar(key, v, resourceProvider);
break;
case 'documentation':
documentation = _processScalar(key, v, resourceProvider);
break;
case 'dependencies':
dependencies = _processDependencies(key, v, resourceProvider);
break;
case 'dev_dependencies':
devDependencies = _processDependencies(key, v, resourceProvider);
break;
case 'dependency_overrides':
dependencyOverrides = _processDependencies(key, v, resourceProvider);
break;
case 'environment':
environment = _processEnvironment(key, v, resourceProvider);
break;
case 'version':
version = _processScalar(key, v, resourceProvider);
break;
}
});
}
Expand Down
1 change: 0 additions & 1 deletion pkg/analyzer/lib/src/summary2/macro_application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ class LibraryMacroApplier {
case macro.DeclarationDiagnosticTarget macroTarget:
final element = (macroTarget.declaration as HasElement).element;
target = ElementMacroDiagnosticTarget(element: element);
break;
default:
target = ApplicationMacroDiagnosticTarget(
annotationIndex: application.annotationIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,13 @@ void f(e) {
error(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
128, 6),
];
break;
case _Variants.nullSafe:
expectedErrors = [
error(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
150, 10),
];
break;
case _Variants.patterns:
expectedErrors = [];
break;
}

await assertErrorsInCode(r'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,8 @@ mixin CaseExpressionTypeIsNotSwitchExpressionSubtypeTestCases
error(CompileTimeErrorCode.CASE_EXPRESSION_TYPE_IMPLEMENTS_EQUALS,
206, 10),
];
break;
case _Variant.patterns:
expectedErrors = [];
break;
}

await assertErrorsInCode('''
Expand Down Expand Up @@ -104,13 +102,11 @@ void f(A e) {
171,
10),
];
break;
case _Variant.patterns:
expectedErrors = [
error(WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE, 145, 2),
error(WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE, 171, 10),
];
break;
}

await assertErrorsInCode('''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ const int c = 0;
case _Variant.nullSafe:
expectedErrorCode = CompileTimeErrorCode
.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY;
break;
case _Variant.patterns:
expectedErrorCode =
CompileTimeErrorCode.PATTERN_CONSTANT_FROM_DEFERRED_LIBRARY;
break;
}

await assertErrorsInCode('''
Expand All @@ -121,11 +119,9 @@ class A {}
case _Variant.nullSafe:
expectedErrorCode = CompileTimeErrorCode
.NON_CONSTANT_CASE_EXPRESSION_FROM_DEFERRED_LIBRARY;
break;
case _Variant.patterns:
expectedErrorCode =
CompileTimeErrorCode.PATTERN_CONSTANT_FROM_DEFERRED_LIBRARY;
break;
}

await assertErrorsInCode('''
Expand Down
8 changes: 0 additions & 8 deletions pkg/analyzer/tool/summary/generate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,25 +458,21 @@ class _BuilderGenerator extends _BaseGenerator {
ref += " ?? ''";
}
out("signatureSink.addString($ref);");
break;
case 'int':
if (couldBeNull) {
ref += ' ?? 0';
}
out('signatureSink.addInt($ref);');
break;
case 'bool':
if (couldBeNull) {
ref += ' == true';
}
out('signatureSink.addBool($ref);');
break;
case 'double':
if (couldBeNull) {
ref += ' ?? 0.0';
}
out('signatureSink.addDouble($ref);');
break;
default:
throw "Don't know how to generate signature call for $typeName";
}
Expand Down Expand Up @@ -895,16 +891,12 @@ class _FlatBufferSchemaGenerator extends _BaseGenerator {
switch (type.typeName) {
case 'bool':
typeStr = 'bool';
break;
case 'double':
typeStr = 'double';
break;
case 'int':
typeStr = 'uint';
break;
case 'String':
typeStr = 'string';
break;
default:
typeStr = type.typeName;
break;
Expand Down

0 comments on commit 8b564e0

Please sign in to comment.