Skip to content

Commit

Permalink
[ddc] Enforce unnecessary_breaks lint
Browse files Browse the repository at this point in the history
Ignore violations in the js_ast sub-directory to avoid unnecessary diffs
with the original package.

Change-Id: Iac8c942e5e2446b8433e2073b546c28e42a8f5cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392700
Reviewed-by: Kevin Moore <[email protected]>
Commit-Queue: Nicholas Shahan <[email protected]>
  • Loading branch information
nshahan authored and Commit Queue committed Oct 30, 2024
1 parent ca0cfad commit 7d00c54
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 36 deletions.
1 change: 1 addition & 0 deletions pkg/dev_compiler/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ linter:
- prefer_single_quotes
- prefer_relative_imports
- unawaited_futures
- unnecessary_breaks
2 changes: 1 addition & 1 deletion pkg/dev_compiler/lib/src/js_ast/printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// ignore_for_file: omit_local_variable_types
// ignore_for_file: omit_local_variable_types, unnecessary_breaks

import 'characters.dart' as char_codes;
import 'nodes.dart';
Expand Down
9 changes: 0 additions & 9 deletions pkg/dev_compiler/lib/src/kernel/compiler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,8 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
switch (component.mode) {
case NonNullableByDefaultCompiledMode.Strong:
soundNullSafety = js_ast.LiteralBool(true);
break;
case NonNullableByDefaultCompiledMode.Weak:
soundNullSafety = js_ast.LiteralBool(false);
break;
default:
throw StateError('Unsupported Null Safety mode ${component.mode}, '
'in ${component.location?.file}.');
Expand Down Expand Up @@ -2952,7 +2950,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Reserved by JS, not a valid static member name.
case 'prototype':
name += '_';
break;
default:
// All trailing underscores static names are reserved for the compiler
// or SDK libraries.
Expand Down Expand Up @@ -3656,7 +3653,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
wrapBody:
_emitTopLevelNameNoExternalInterop(_asyncWrapJsFunctionMember),
bodyName: bodyName);
break;
case AsyncMarker.SyncStar:
asyncRewriter = SyncStarRewriter(
makeSyncStarIterable:
Expand All @@ -3669,7 +3665,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
yieldStarSelector: _emitMemberName('_yieldStar',
member: _syncStarIteratorYieldStarMember),
bodyName: bodyName);
break;
case AsyncMarker.AsyncStar:
asyncRewriter = AsyncStarRewriter(
asyncStarHelper:
Expand All @@ -3686,7 +3681,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
wrapBody:
_emitTopLevelNameNoExternalInterop(_asyncWrapJsFunctionMember),
bodyName: bodyName);
break;
}
if (asyncRewriter != null) {
return asyncRewriter.rewrite(fun, functionBody, functionEnd,
Expand Down Expand Up @@ -6684,7 +6678,6 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var rti = _emitType(mapType);
return js.call('new #.new(#)', [mapClass, rti]);
}
break;
case 'Set':
case 'HashSet':
case 'LinkedHashSet':
Expand All @@ -6699,12 +6692,10 @@ class ProgramCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var rti = _emitType(setType);
return js.call('new #.new(#)', [setClass, rti]);
}
break;
case 'List':
if (ctor.name.text == '') {
return _emitList(type.typeArguments[0], []);
}
break;
}
}
var rti = _requiresRtiForInstantiation(ctorClass)
Expand Down
9 changes: 0 additions & 9 deletions pkg/dev_compiler/lib/src/kernel/compiler_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,8 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
switch (_component.mode) {
case NonNullableByDefaultCompiledMode.Strong:
soundNullSafety = js_ast.LiteralBool(true);
break;
case NonNullableByDefaultCompiledMode.Weak:
soundNullSafety = js_ast.LiteralBool(false);
break;
default:
throw StateError('Unsupported Null Safety mode ${_component.mode}, '
'in ${_component.location?.file}.');
Expand Down Expand Up @@ -3125,7 +3123,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
// Reserved by JS, not a valid static member name.
case 'prototype':
name += '_';
break;
default:
// All trailing underscores static names are reserved for the compiler
// or SDK libraries.
Expand Down Expand Up @@ -3829,7 +3826,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
wrapBody:
_emitTopLevelNameNoExternalInterop(_asyncWrapJsFunctionMember),
bodyName: bodyName);
break;
case AsyncMarker.SyncStar:
asyncRewriter = SyncStarRewriter(
makeSyncStarIterable:
Expand All @@ -3842,7 +3838,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
yieldStarSelector: _emitMemberName('_yieldStar',
member: _syncStarIteratorYieldStarMember),
bodyName: bodyName);
break;
case AsyncMarker.AsyncStar:
asyncRewriter = AsyncStarRewriter(
asyncStarHelper:
Expand All @@ -3859,7 +3854,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
wrapBody:
_emitTopLevelNameNoExternalInterop(_asyncWrapJsFunctionMember),
bodyName: bodyName);
break;
}
if (asyncRewriter != null) {
return asyncRewriter.rewrite(fun, functionBody, functionEnd,
Expand Down Expand Up @@ -6856,7 +6850,6 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var rti = _emitType(mapType);
return js.call('new #.new(#)', [mapClass, rti]);
}
break;
case 'Set':
case 'HashSet':
case 'LinkedHashSet':
Expand All @@ -6871,12 +6864,10 @@ class LibraryCompiler extends ComputeOnceConstantVisitor<js_ast.Expression>
var rti = _emitType(setType);
return js.call('new #.new(#)', [setClass, rti]);
}
break;
case 'List':
if (ctor.name.text == '') {
return _emitList(type.typeArguments[0], []);
}
break;
}
}
var rti = _requiresRtiForInstantiation(ctorClass)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,9 @@ class ExpressionCompilerWorker {
case 'UpdateDeps':
sendResponse(await _updateDependencies(
UpdateDependenciesRequest.fromJson(request)));
break;
case 'CompileExpression':
sendResponse(await _compileExpression(
CompileExpressionRequest.fromJson(request)));
break;
default:
throw ArgumentError(
'Unrecognized command `$command`, full request was `$request`');
Expand Down Expand Up @@ -787,13 +785,10 @@ void Function(DiagnosticMessage) _onDiagnosticHandler(
case Severity.error:
case Severity.internalProblem:
errors.add(message.plainTextFormatted.join('\n'));
break;
case Severity.warning:
warnings.add(message.plainTextFormatted.join('\n'));
break;
case Severity.info:
infos.add(message.plainTextFormatted.join('\n'));
break;
case Severity.context:
case Severity.ignored:
throw 'Unexpected severity: ${message.severity}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ class ExpressionEvaluationTestDriver {
};
</script>
''');
break;
case ModuleFormat.amd:
var dartSdkPathNoExtension = escaped(SetupCompilerOptions.buildRoot
.resolve(p.join(
Expand Down Expand Up @@ -288,7 +287,6 @@ class ExpressionEvaluationTestDriver {
</script>
''');

break;
default:
throw Exception('Unsupported module format for SDK evaluation tests: '
'${setup.moduleFormat}');
Expand Down Expand Up @@ -841,7 +839,6 @@ class ExpressionEvaluationTestDriver {
switch (type) {
case 'function':
str = obj.description ?? '';
break;
case 'object':
if (obj.subtype == 'null') {
return 'null';
Expand All @@ -860,10 +857,8 @@ class ExpressionEvaluationTestDriver {
} catch (e, s) {
throw StateError('Failed to stringify remote object $obj: $e:$s');
}
break;
default:
str = '${obj.value}';
break;
}
return str;
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/dev_compiler/test/hot_reload_suite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ Future<void> main(List<String> args) async {
'--target=dartdevc',
];
controller = HotReloadFrontendServerController(fesArgs);
break;
case RuntimePlatforms.vm:
final vmPlatformDillFromSdkRoot = fe_shared.relativizeUri(
sdkRoot, vmPlatformDillUri, fe_shared.isWindows);
Expand All @@ -205,7 +204,6 @@ Future<void> main(List<String> args) async {
'--target=vm',
];
controller = HotReloadFrontendServerController(fesArgs);
break;
}
controller.start();

Expand Down Expand Up @@ -424,7 +422,6 @@ Future<void> main(List<String> args) async {
}
});
});
break;
case DiffMode.write:
_print('Generating source file diffs.', label: testName);
filesByGeneration.forEach((basename, filesQueue) {
Expand Down Expand Up @@ -462,7 +459,6 @@ Future<void> main(List<String> args) async {
reportDiffOutcome(file, 'diff updated for $file', true);
});
});
break;
case DiffMode.ignore:
_print('Ignoring source file diffs.', label: testName);
filesByGeneration.forEach((basename, filesQueue) {
Expand All @@ -471,7 +467,6 @@ Future<void> main(List<String> args) async {
reportDiffOutcome(file, 'Ignoring diff for $file', true);
});
});
break;
}

// Skip this test directory if this platform is excluded.
Expand Down Expand Up @@ -658,7 +653,6 @@ Future<void> main(List<String> args) async {
final d8ExitCode = await d8Suite.runTest(testName: testName);
testPassed = d8ExitCode == 0;
await d8Suite.teardownTest(testName: testName);
break;
case RuntimePlatforms.chrome:
// Run the compiled JS generations with Chrome.
_print('Creating Chrome hot reload test suite.', label: testName);
Expand All @@ -683,7 +677,6 @@ Future<void> main(List<String> args) async {
final exitCode = await suite.runTest(testName: testName);
testPassed = exitCode == 0;
await suite.teardownTest(testName: testName);
break;
case RuntimePlatforms.vm:
final firstGenerationDillUri =
tempUri.resolve('generation0/$testName.dill');
Expand Down

0 comments on commit 7d00c54

Please sign in to comment.