Remove unnecessary const, new
diff --git a/pkgs/pubspec_parse/analysis_options.yaml b/pkgs/pubspec_parse/analysis_options.yaml index 9602469..ed170c1 100644 --- a/pkgs/pubspec_parse/analysis_options.yaml +++ b/pkgs/pubspec_parse/analysis_options.yaml
@@ -71,8 +71,10 @@ - type_init_formals - unawaited_futures - unnecessary_brace_in_string_interps + - unnecessary_const - unnecessary_getters_setters - unnecessary_lambdas + - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_statements - unnecessary_this
diff --git a/pkgs/pubspec_parse/lib/src/dependency.dart b/pkgs/pubspec_parse/lib/src/dependency.dart index 3839e54..0fb761c 100644 --- a/pkgs/pubspec_parse/lib/src/dependency.dart +++ b/pkgs/pubspec_parse/lib/src/dependency.dart
@@ -29,20 +29,20 @@ if (innerError is FormatException) { message = innerError.message; } - throw new CheckedFromJsonException(source, key, e.className, message); + throw CheckedFromJsonException(source, key, e.className, message); } rethrow; } if (value == null) { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( source, key, 'Pubspec', 'Not a valid dependency value.'); } - return new MapEntry(key, value); + return MapEntry(key, value); }) ?? {}; -const _sourceKeys = const ['sdk', 'git', 'path', 'hosted']; +const _sourceKeys = ['sdk', 'git', 'path', 'hosted']; /// Returns `null` if the data could not be parsed. Dependency _fromJson(dynamic data) { @@ -61,11 +61,11 @@ orElse: () => null); if (weirdKey != null) { - throw new InvalidKeyException( + throw InvalidKeyException( data, weirdKey, 'Unsupported dependency key.'); } if (matchedKeys.length > 1) { - throw new CheckedFromJsonException(data, matchedKeys[1], 'Dependency', + throw CheckedFromJsonException(data, matchedKeys[1], 'Dependency', 'A dependency may only have one source.'); } @@ -74,17 +74,17 @@ try { switch (key) { case 'git': - return new GitDependency.fromData(data[key]); + return GitDependency.fromData(data[key]); case 'path': - return new PathDependency.fromData(data[key]); + return PathDependency.fromData(data[key]); case 'sdk': return _$SdkDependencyFromJson(data); case 'hosted': return _$HostedDependencyFromJson(data); } - throw new StateError('There is a bug in pubspec_parse.'); + throw StateError('There is a bug in pubspec_parse.'); } on ArgumentError catch (e) { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( data, e.name, 'Dependency', e.message.toString()); } } @@ -134,7 +134,7 @@ return _$GitDependencyFromJson(data); } - throw new ArgumentError.value(data, 'git', 'Must be a String or a Map.'); + throw ArgumentError.value(data, 'git', 'Must be a String or a Map.'); } @override @@ -169,7 +169,7 @@ var user = atIndex >= 0 ? value.substring(0, atIndex) : null; var host = value.substring(atIndex + 1, colonIndex); var path = value.substring(colonIndex + 1); - return new Uri(scheme: 'ssh', userInfo: user, host: host, path: path); + return Uri(scheme: 'ssh', userInfo: user, host: host, path: path); } return null; } @@ -181,9 +181,9 @@ factory PathDependency.fromData(Object data) { if (data is String) { - return new PathDependency(data); + return PathDependency(data); } - throw new ArgumentError.value(data, 'path', 'Must be a String.'); + throw ArgumentError.value(data, 'path', 'Must be a String.'); } @override @@ -225,9 +225,9 @@ return _$HostedDetailsFromJson(data); } - throw new ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); + throw ArgumentError.value(data, 'hosted', 'Must be a Map or String.'); } } VersionConstraint _constraintFromString(String input) => - new VersionConstraint.parse(input); + VersionConstraint.parse(input);
diff --git a/pkgs/pubspec_parse/lib/src/errors.dart b/pkgs/pubspec_parse/lib/src/errors.dart index c9643b8..637c5a8 100644 --- a/pkgs/pubspec_parse/lib/src/errors.dart +++ b/pkgs/pubspec_parse/lib/src/errors.dart
@@ -6,7 +6,7 @@ import 'package:yaml/yaml.dart'; ParsedYamlException parsedYamlException(String message, YamlNode yamlNode) => - new ParsedYamlException._(message, yamlNode); + ParsedYamlException._(message, yamlNode); ParsedYamlException parsedYamlExceptionFromError( CheckedFromJsonException error, StackTrace stack) { @@ -20,7 +20,7 @@ return key.value == innerError.key; }, orElse: () => map); - return new ParsedYamlException._(innerError.message, node, + return ParsedYamlException._(innerError.message, node, innerError: error, innerStack: stack); } } else if (innerError is ParsedYamlException) { @@ -43,7 +43,7 @@ } } - return new ParsedYamlException._(message, yamlNode, + return ParsedYamlException._(message, yamlNode, innerError: error, innerStack: stack); }
diff --git a/pkgs/pubspec_parse/lib/src/pubspec.dart b/pkgs/pubspec_parse/lib/src/pubspec.dart index 59ee585..a8ef2fe 100644 --- a/pkgs/pubspec_parse/lib/src/pubspec.dart +++ b/pkgs/pubspec_parse/lib/src/pubspec.dart
@@ -71,7 +71,7 @@ devDependencies = devDependencies ?? const {}, dependencyOverrides = dependencyOverrides ?? const {} { if (name == null || name.isEmpty) { - throw new ArgumentError.value(name, 'name', '"name" cannot be empty.'); + throw ArgumentError.value(name, 'name', '"name" cannot be empty.'); } } @@ -81,7 +81,7 @@ var item = loadYaml(yaml, sourceUrl: sourceUrl); if (item == null) { - throw new ArgumentError.notNull('yaml'); + throw ArgumentError.notNull('yaml'); } if (item is! YamlMap) { @@ -89,19 +89,18 @@ throw parsedYamlException('Does not represent a YAML map.', item); } - throw new ArgumentError.value( - yaml, 'yaml', 'Does not represent a YAML map.'); + throw ArgumentError.value(yaml, 'yaml', 'Does not represent a YAML map.'); } try { - return new Pubspec.fromJson(item as YamlMap); + return Pubspec.fromJson(item as YamlMap); } on CheckedFromJsonException catch (error, stack) { throw parsedYamlExceptionFromError(error, stack); } } static List<String> _normalizeAuthors(String author, List<String> authors) { - var value = new Set<String>(); + var value = Set<String>(); if (author != null) { value.add(author); } @@ -112,7 +111,7 @@ } } -Version _versionFromString(String input) => new Version.parse(input); +Version _versionFromString(String input) => Version.parse(input); Map<String, VersionConstraint> _environmentMap(Map source) => source.map((k, value) { @@ -120,7 +119,7 @@ if (key == 'dart') { // github.com/dart-lang/pub/blob/d84173eeb03c3/lib/src/pubspec.dart#L342 // 'dart' is not allowed as a key! - throw new InvalidKeyException( + throw InvalidKeyException( source, 'dart', 'Use "sdk" to for Dart SDK constraints.'); } @@ -129,16 +128,16 @@ constraint = null; } else if (value is String) { try { - constraint = new VersionConstraint.parse(value); + constraint = VersionConstraint.parse(value); } on FormatException catch (e) { - throw new CheckedFromJsonException(source, key, 'Pubspec', e.message); + throw CheckedFromJsonException(source, key, 'Pubspec', e.message); } - return new MapEntry(key, constraint); + return MapEntry(key, constraint); } else { - throw new CheckedFromJsonException( + throw CheckedFromJsonException( source, key, 'VersionConstraint', '`$value` is not a String.'); } - return new MapEntry(key, constraint); + return MapEntry(key, constraint); });
diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart index ac67c9f..d64fa4f 100644 --- a/pkgs/pubspec_parse/test/ensure_build_test.dart +++ b/pkgs/pubspec_parse/test/ensure_build_test.dart
@@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. @TestOn('vm') -@Tags(const ['presubmit-only']) +@Tags(['presubmit-only']) import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart';
diff --git a/pkgs/pubspec_parse/test/parse_test.dart b/pkgs/pubspec_parse/test/parse_test.dart index 71c0a58..3ed73a5 100644 --- a/pkgs/pubspec_parse/test/parse_test.dart +++ b/pkgs/pubspec_parse/test/parse_test.dart
@@ -25,8 +25,8 @@ }); test('all fields set', () { - var version = new Version.parse('1.2.3'); - var sdkConstraint = new VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); + var version = Version.parse('1.2.3'); + var sdkConstraint = VersionConstraint.parse('>=2.0.0-dev.54 <3.0.0'); var value = parse({ 'name': 'sample', 'version': version.toString(),
diff --git a/pkgs/pubspec_parse/test/pub_utils.dart b/pkgs/pubspec_parse/test/pub_utils.dart index 984bb49..f9e2f0c 100644 --- a/pkgs/pubspec_parse/test/pub_utils.dart +++ b/pkgs/pubspec_parse/test/pub_utils.dart
@@ -26,7 +26,7 @@ if (result.exitCode == 0) { var lockContent = - new File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); + File(p.join(d.sandbox, 'pubspec.lock')).readAsStringSync(); printOnFailure([ '-----BEGIN pubspec.lock-----', @@ -51,20 +51,16 @@ var values = await Future.wait([ proc.exitCode, - proc - .stdoutStream() - .forEach((line) => items.add(new ProcLine(false, line))), - proc - .stderrStream() - .forEach((line) => items.add(new ProcLine(true, line))), + proc.stdoutStream().forEach((line) => items.add(ProcLine(false, line))), + proc.stderrStream().forEach((line) => items.add(ProcLine(true, line))), ]); - return new ProcResult(values[0] as int, items); + return ProcResult(values[0] as int, items); } @override String toString() { - var buffer = new StringBuffer('Exit code: $exitCode'); + var buffer = StringBuffer('Exit code: $exitCode'); for (var line in lines) { buffer.write('\n$line'); }
diff --git a/pkgs/pubspec_parse/test/test_utils.dart b/pkgs/pubspec_parse/test/test_utils.dart index 48efdf6..d5254db 100644 --- a/pkgs/pubspec_parse/test/test_utils.dart +++ b/pkgs/pubspec_parse/test/test_utils.dart
@@ -62,7 +62,7 @@ } try { - var value = new Pubspec.parse(encoded); + var value = Pubspec.parse(encoded); if (pubResult != null) { addTearDown(() {