[dartdevc] Bump pedantic to v1.8.0 and apply new lints

Cleanup violations of:
* `prefer_iterable_whereType`
* `unnecessary_const`
* `unnecessary_new`

Ignore violations in lib/src/js_ast to avoid additional diffs when un-forking.

Change-Id: I7333903422bbf635cd0dea82116372f305f679d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108182
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
This commit is contained in:
Nicholas Shahan 2019-07-03 23:51:51 +00:00 committed by commit-bot@chromium.org
parent 4b0c5c166a
commit ac30ab12ab
14 changed files with 28 additions and 30 deletions

2
DEPS
View file

@ -109,7 +109,7 @@ vars = {
"package_config_tag": "1.0.5",
"package_resolver_tag": "1.0.10",
"path_tag": "1.6.2",
"pedantic_tag": "v1.7.0",
"pedantic_tag": "v1.8.0",
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
"pool_tag": "1.3.6",
"protobuf_rev": "7d34c9e4e552a4f66acce32e4344ae27756a1949",

View file

@ -1,4 +1,4 @@
include: package:pedantic/analysis_options.1.7.0.yaml
include: package:pedantic/analysis_options.1.8.0.yaml
analyzer:
strong-mode:

View file

@ -23,8 +23,8 @@ Future main(List<String> args, [SendPort sendPort]) async {
if (parsedArgs.isWorker) {
var workerConnection = sendPort == null
? new StdAsyncWorkerConnection()
: new SendPortAsyncWorkerConnection(sendPort);
? StdAsyncWorkerConnection()
: SendPortAsyncWorkerConnection(sendPort);
await _CompilerWorker(parsedArgs, workerConnection).run();
} else if (parsedArgs.isBatch) {
await runBatch(parsedArgs);

View file

@ -5498,7 +5498,7 @@ class CodeGenerator extends Object
variable = forParts.loopVariable.identifier;
init = js.call('let # = #.current', [_emitVariableDef(variable), iter]);
} else {
throw new StateError('Unrecognized for loop parts');
throw StateError('Unrecognized for loop parts');
}
return js.statement(
'{'
@ -6516,7 +6516,7 @@ class CodeGenerator extends Object
} else if (forParts is ForPartsWithDeclarations) {
init = visitVariableDeclarationList(forParts.variables);
} else {
throw new StateError('Unrecognized for loop parts');
throw StateError('Unrecognized for loop parts');
}
js_ast.Expression update;
if (forParts.updaters != null && forParts.updaters.isNotEmpty) {
@ -6548,7 +6548,7 @@ class CodeGenerator extends Object
]);
}
} else {
throw new StateError('Unrecognized for loop parts');
throw StateError('Unrecognized for loop parts');
}
return js_ast.ForOf(jsLeftExpression, jsIterable, jsBody);
}
@ -6618,7 +6618,7 @@ class CodeGenerator extends Object
} else if (forParts is ForEachPartsWithDeclaration) {
variable = forParts.loopVariable.identifier;
} else {
throw new StateError('Unrecognized for loop parts');
throw StateError('Unrecognized for loop parts');
}
var castType = getImplicitCast(variable);
if (castType != null) {

View file

@ -369,7 +369,7 @@ class _NullableLocalInference extends RecursiveAstVisitor {
_nullableLocals.add(element);
}
} else {
throw new StateError('Unrecognized for loop parts');
throw StateError('Unrecognized for loop parts');
}
}
super.visitForStatement(node);

View file

@ -292,9 +292,8 @@ T _substitute<T extends Node>(
T tree, Map<MetaLetVariable, Expression> substitutions) {
var generator = InstantiatorGeneratorVisitor(/*forceCopy:*/ false);
var instantiator = generator.compile(tree);
var nodes = List<MetaLetVariable>.from(generator
.analysis.containsInterpolatedNode
.where((n) => n is MetaLetVariable));
var nodes = List<MetaLetVariable>.from(
generator.analysis.containsInterpolatedNode.whereType<MetaLetVariable>());
if (nodes.isEmpty) return tree;
return instantiator(Map.fromIterable(nodes,

View file

@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'dart:async';
import 'dart:collection';
import 'dart:io';
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
import 'package:args/args.dart';
@ -263,8 +262,8 @@ Map<String, String> _parseBazelMappings(List<String> argument) {
List<String> filterUnknownArguments(List<String> args, ArgParser parser) {
if (!args.contains('--ignore-unrecognized-flags')) return args;
var knownOptions = new HashSet<String>();
var knownAbbreviations = new HashSet<String>();
var knownOptions = <String>{};
var knownAbbreviations = <String>{};
parser.options.forEach((String name, Option option) {
knownOptions.add(name);
var abbreviation = option.abbr;

View file

@ -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: slash_for_doc_comments
// ignore_for_file: slash_for_doc_comments, unnecessary_new
// Utilities for building JS ASTs at runtime. Contains a builder class
// and a parser that parses part of the language.

View file

@ -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: slash_for_doc_comments
// ignore_for_file: slash_for_doc_comments, unnecessary_const
part of js_ast;

View file

@ -248,7 +248,7 @@ Future<CompilerResult> _compile(List<String> args,
fileSystem: fileSystem,
experiments: experiments);
} else {
doneInputSummaries = new List<Component>(summaryModules.length);
doneInputSummaries = List<Component>(summaryModules.length);
compilerState = await fe.initializeIncrementalCompiler(
oldCompilerState,
doneInputSummaries,
@ -292,7 +292,7 @@ Future<CompilerResult> _compile(List<String> args,
Component incrementalComponent = await incrementalCompiler.computeDelta(
entryPoints: inputs, fullComponent: true);
hierarchy = incrementalCompiler.userCode.loader.hierarchy;
result = new fe.DdcResult(incrementalComponent, doneInputSummaries);
result = fe.DdcResult(incrementalComponent, doneInputSummaries);
// Workaround for DDC relying on isExternal being set to true.
for (var lib in cachedSdkInput.component.libraries) {
@ -335,7 +335,7 @@ Future<CompilerResult> _compile(List<String> args,
outFiles.add(sink.flush().then((_) => sink.close()));
}
if (argResults['summarize-text'] as bool) {
StringBuffer sb = new StringBuffer();
StringBuffer sb = StringBuffer();
kernel.Printer(sb, showExternal: false).writeComponentFile(component);
outFiles.add(File(output + '.txt').writeAsString(sb.toString()));
}

View file

@ -4928,7 +4928,7 @@ class ProgramCompiler extends Object
@override
js_ast.Expression visitInstanceCreation(InstanceCreation node) {
// Only occurs inside unevaluated constants.
throw new UnsupportedError("Instance creation");
throw UnsupportedError("Instance creation");
}
@override

View file

@ -15,7 +15,7 @@ dependencies:
dev_dependencies:
sourcemap_testing:
path: ../sourcemap_testing
pedantic: ^1.7.0
pedantic: ^1.8.0
test: any
testing:
path: ../testing

View file

@ -23,16 +23,16 @@ main(List<String> args) async {
sdkRoot.resolve('tests/modular/'),
'tests/modular',
_options,
new IOPipeline([
IOPipeline([
SourceToSummaryDillStep(),
DDKStep(),
RunD8(),
], cacheSharedModules: true));
}
const dillId = const DataId("dill");
const jsId = const DataId("js");
const txtId = const DataId("txt");
const dillId = DataId("dill");
const jsId = DataId("js");
const txtId = DataId("txt");
class SourceToSummaryDillStep implements IOModularStep {
@override
@ -270,7 +270,7 @@ String get _d8executable {
} else if (Platform.isMacOS) {
return 'third_party/d8/macos/d8';
}
throw new UnsupportedError('Unsupported platform.');
throw UnsupportedError('Unsupported platform.');
}
Future<void> _createPackagesFile(
@ -287,7 +287,7 @@ Future<void> _createPackagesFile(
// TODO(sigmund): follow up with the CFE to see if we can remove the need
// for the .packages entry altogether if they won't need to read the
// sources.
var packagesContents = new StringBuffer();
var packagesContents = StringBuffer();
if (module.isPackage) {
packagesContents.write('${module.name}:${module.packageBase}\n');
}

View file

@ -227,12 +227,12 @@ class PatchApplier extends GeneralizingAstVisitor {
int importPos = unit.directives
.lastWhere((d) => d is ImportDirective, orElse: () => libDir)
.end;
for (var d in patch.unit.directives.where((d) => d is ImportDirective)) {
for (var d in patch.unit.directives.whereType<ImportDirective>()) {
_merge(d, importPos);
}
int partPos = unit.directives.last.end;
for (var d in patch.unit.directives.where((d) => d is PartDirective)) {
for (var d in patch.unit.directives.whereType<PartDirective>()) {
_merge(d, partPos);
}