Skip to content

Commit 5962908

Browse files
authored
Run dartfmt --fix to drop new and const (#1962)
Enable the `unnecessary_new` lint to prevent regressions.
1 parent 8028f64 commit 5962908

File tree

137 files changed

+889
-935
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+889
-935
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ linter:
4949
- type_init_formals
5050
- unnecessary_brace_in_string_interps
5151
- unnecessary_getters_setters
52+
- unnecessary_new
5253
- unnecessary_null_aware_assignments
5354
- unnecessary_statements
5455
- unnecessary_this

bin/pub.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
import 'package:pub/src/command_runner.dart';
66

77
void main(List<String> arguments) {
8-
new PubCommandRunner().run(arguments);
8+
PubCommandRunner().run(arguments);
99
}

lib/src/ascii_tree.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ String fromFiles(List<String> files, {String baseDir, bool showAllChildren}) {
9999
/// If [showAllChildren] is `false`, then directories with more than ten items
100100
/// will have their contents truncated. Defaults to `false`.
101101
String fromMap(Map<String, Map> map, {bool showAllChildren}) {
102-
var buffer = new StringBuffer();
102+
var buffer = StringBuffer();
103103
_draw(buffer, "", null, map, showAllChildren: showAllChildren);
104104
return buffer.toString();
105105
}

lib/src/command.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ import 'system_cache.dart';
1616
/// of subcommands. Only leaf commands are ever actually invoked. If a command
1717
/// has subcommands, then one of those must always be chosen.
1818
abstract class PubCommand extends Command {
19-
SystemCache get cache => _cache ??= new SystemCache(isOffline: isOffline);
19+
SystemCache get cache => _cache ??= SystemCache(isOffline: isOffline);
2020

2121
SystemCache _cache;
2222

23-
GlobalPackages get globals => _globals ??= new GlobalPackages(cache);
23+
GlobalPackages get globals => _globals ??= GlobalPackages(cache);
2424

2525
GlobalPackages _globals;
2626

2727
/// Gets the [Entrypoint] package for the current working directory.
2828
///
2929
/// This will load the pubspec and fail with an error if the current directory
3030
/// is not a package.
31-
Entrypoint get entrypoint => _entrypoint ??= new Entrypoint.current(cache);
31+
Entrypoint get entrypoint => _entrypoint ??= Entrypoint.current(cache);
3232

3333
Entrypoint _entrypoint;
3434

@@ -42,7 +42,7 @@ abstract class PubCommand extends Command {
4242
// Lazily initialize the parser because the superclass constructor requires
4343
// it but we want to initialize it based on [allowTrailingOptions].
4444
ArgParser get argParser =>
45-
_argParser ??= new ArgParser(allowTrailingOptions: allowTrailingOptions);
45+
_argParser ??= ArgParser(allowTrailingOptions: allowTrailingOptions);
4646

4747
ArgParser _argParser;
4848

lib/src/command/cache.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class CacheCommand extends PubCommand {
1515
String get docUrl => "http://dartlang.org/tools/pub/cmd/pub-cache.html";
1616

1717
CacheCommand() {
18-
addSubcommand(new CacheAddCommand());
19-
addSubcommand(new CacheListCommand());
20-
addSubcommand(new CacheRepairCommand());
18+
addSubcommand(CacheAddCommand());
19+
addSubcommand(CacheListCommand());
20+
addSubcommand(CacheRepairCommand());
2121
}
2222
}

lib/src/command/cache_add.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class CacheAddCommand extends PubCommand {
4444
var constraint = VersionConstraint.any;
4545
if (argResults["version"] != null) {
4646
try {
47-
constraint = new VersionConstraint.parse(argResults["version"]);
47+
constraint = VersionConstraint.parse(argResults["version"]);
4848
} on FormatException catch (error) {
4949
usageException(error.message);
5050
}

lib/src/command/cache_repair.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class CacheRepairCommand extends PubCommand {
3939

4040
if (failures.isNotEmpty) {
4141
var packages = pluralize("package", failures.length);
42-
var buffer = new StringBuffer(
42+
var buffer = StringBuffer(
4343
"Failed to reinstall ${log.red(failures.length)} $packages:\n");
4444

4545
for (var id in failures) {

lib/src/command/deps.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DepsCommand extends PubCommand {
2424
bool get takesArguments => false;
2525

2626
final AnalysisContextManager analysisContextManager =
27-
new AnalysisContextManager();
27+
AnalysisContextManager();
2828

2929
/// The [StringBuffer] used to accumulate the output.
3030
StringBuffer _buffer;
@@ -52,7 +52,7 @@ class DepsCommand extends PubCommand {
5252
// Explicitly run this in case we don't access `entrypoint.packageGraph`.
5353
entrypoint.assertUpToDate();
5454

55-
_buffer = new StringBuffer();
55+
_buffer = StringBuffer();
5656

5757
if (argResults['executables']) {
5858
_outputExecutables();
@@ -166,8 +166,8 @@ class DepsCommand extends PubCommand {
166166
// The work list for the breadth-first traversal. It contains the package
167167
// being added to the tree, and the parent map that will receive that
168168
// package.
169-
var toWalk = new Queue<Pair<Package, Map<String, Map>>>();
170-
var visited = new Set<String>.from([entrypoint.root.name]);
169+
var toWalk = Queue<Pair<Package, Map<String, Map>>>();
170+
var visited = Set<String>.from([entrypoint.root.name]);
171171

172172
// Start with the root dependencies.
173173
var packageTree = <String, Map>{};
@@ -177,7 +177,7 @@ class DepsCommand extends PubCommand {
177177
immediateDependencies.removeAll(entrypoint.root.devDependencies.keys);
178178
}
179179
for (var name in immediateDependencies) {
180-
toWalk.add(new Pair(_getPackage(name), packageTree));
180+
toWalk.add(Pair(_getPackage(name), packageTree));
181181
}
182182

183183
// Do a breadth-first walk to the dependency graph.
@@ -198,7 +198,7 @@ class DepsCommand extends PubCommand {
198198
map[_labelPackage(package)] = childMap;
199199

200200
for (var dep in package.dependencies.values) {
201-
toWalk.add(new Pair(_getPackage(dep.name), childMap));
201+
toWalk.add(Pair(_getPackage(dep.name), childMap));
202202
}
203203
}
204204

lib/src/command/global.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class GlobalCommand extends PubCommand {
1515
String get invocation => "pub global <subcommand>";
1616

1717
GlobalCommand() {
18-
addSubcommand(new GlobalActivateCommand());
19-
addSubcommand(new GlobalDeactivateCommand());
20-
addSubcommand(new GlobalListCommand());
21-
addSubcommand(new GlobalRunCommand());
18+
addSubcommand(GlobalActivateCommand());
19+
addSubcommand(GlobalDeactivateCommand());
20+
addSubcommand(GlobalListCommand());
21+
addSubcommand(GlobalRunCommand());
2222
}
2323
}

lib/src/command/global_activate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class GlobalActivateCommand extends PubCommand {
9898
var constraint = VersionConstraint.any;
9999
if (args.isNotEmpty) {
100100
try {
101-
constraint = new VersionConstraint.parse(readArg());
101+
constraint = VersionConstraint.parse(readArg());
102102
} on FormatException catch (error) {
103103
usageException(error.message);
104104
}

0 commit comments

Comments
 (0)