Skip to content

Commit d992f55

Browse files
nshahancommit-bot@chromium.org
authored andcommitted
[dartfix] Bump pedantic dep to v1.8.0 and cleanup lint violations
This version added three new lints: * prefer_iterable_whereType * unnecessary_const * unnecessary_new Change-Id: I99b5f3df86a0243091699cd2f3e1d38b5c5a9216 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108381 Reviewed-by: Dan Rubel <[email protected]> Commit-Queue: Nicholas Shahan <[email protected]>
1 parent 41330f3 commit d992f55

16 files changed

+53
-53
lines changed

pkg/dartfix/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:pedantic/analysis_options.1.7.0.yaml
1+
include: package:pedantic/analysis_options.1.8.0.yaml
22

33
linter:
44
rules:

pkg/dartfix/bin/dartfix.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:dartfix/src/driver.dart';
77

88
/// The entry point for dartfix.
99
void main(List<String> args) async {
10-
Driver starter = new Driver();
10+
Driver starter = Driver();
1111

1212
// Wait for the starter to complete.
1313
await starter.start(args);

pkg/dartfix/lib/handler/analysis_complete_handler.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mixin AnalysisCompleteHandler on NotificationHandler {
2525
}
2626

2727
Future<void> analysisComplete() {
28-
_analysisComplete ??= new Completer<void>();
28+
_analysisComplete ??= Completer<void>();
2929
return _analysisComplete.future;
3030
}
3131
}

pkg/dartfix/lib/listener/bad_message_listener.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ mixin BadMessageListener on ServerListener {
1616
_receivedBadDataFromServer = true;
1717
// Give the server 1 second to continue outputting bad data
1818
// such as outputting a stacktrace.
19-
new Future.delayed(new Duration(seconds: 1), () {
19+
Future.delayed(Duration(seconds: 1), () {
2020
throw '$prefix $details';
2121
});
2222
}

pkg/dartfix/lib/listener/timed_listener.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:analysis_server_client/listener/server_listener.dart';
88
/// to each logged interaction with the server.
99
mixin TimedListener on ServerListener {
1010
/// Stopwatch that we use to generate timing information for debug output.
11-
Stopwatch _time = new Stopwatch();
11+
Stopwatch _time = Stopwatch();
1212

1313
/// The [currentElapseTime] at which the last communication was received from
1414
/// the server or `null` if no communication has been received.

pkg/dartfix/lib/src/driver.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Driver {
5050
}
5151
if (checkIfChangesShouldBeApplied(result)) {
5252
for (SourceFileEdit fileEdit in result.edits) {
53-
final file = new File(fileEdit.file);
53+
final file = File(fileEdit.file);
5454
String code = file.existsSync() ? file.readAsStringSync() : '';
5555
code = SourceEdit.applySequence(code, fileEdit.edits);
5656
await file.writeAsString(code);
@@ -80,7 +80,7 @@ class Driver {
8080
/// server being run and return `true` if they are.
8181
/// Display an error message and return `false` if not.
8282
bool checkIfSelectedOptionsAreSupported(Options options) {
83-
if (handler.serverProtocolVersion.compareTo(new Version(1, 22, 2)) >= 0) {
83+
if (handler.serverProtocolVersion.compareTo(Version(1, 22, 2)) >= 0) {
8484
return true;
8585
}
8686
if (options.excludeFixes.isNotEmpty) {
@@ -108,7 +108,7 @@ class Driver {
108108
logger.trace('Requesting fixes');
109109
Future isAnalysisComplete = handler.analysisComplete();
110110

111-
final params = new EditDartfixParams(options.targets);
111+
final params = EditDartfixParams(options.targets);
112112
if (options.excludeFixes.isNotEmpty) {
113113
params.excludedFixes = options.excludeFixes;
114114
}
@@ -128,18 +128,18 @@ class Driver {
128128
await isAnalysisComplete;
129129

130130
progress.finish(showTiming: true);
131-
ResponseDecoder decoder = new ResponseDecoder(null);
131+
ResponseDecoder decoder = ResponseDecoder(null);
132132
return EditDartfixResult.fromJson(decoder, 'result', json);
133133
}
134134

135135
void showDescriptions(String title, List<DartFixSuggestion> suggestions) {
136136
if (suggestions.isNotEmpty) {
137137
logger.stdout('');
138138
logger.stdout(ansi.emphasized('$title:'));
139-
List<DartFixSuggestion> sorted = new List.from(suggestions)
139+
List<DartFixSuggestion> sorted = List.from(suggestions)
140140
..sort(compareSuggestions);
141141
for (DartFixSuggestion suggestion in sorted) {
142-
final msg = new StringBuffer();
142+
final msg = StringBuffer();
143143
msg.write(' ${toSentenceFragment(suggestion.description)}');
144144
final loc = suggestion.location;
145145
if (loc != null) {
@@ -179,12 +179,12 @@ Analysis Details:
179179

180180
Future<EditGetDartfixInfoResult> showFixes({Progress progress}) async {
181181
Map<String, dynamic> json = await server.send(
182-
EDIT_REQUEST_GET_DARTFIX_INFO, new EditGetDartfixInfoParams().toJson());
182+
EDIT_REQUEST_GET_DARTFIX_INFO, EditGetDartfixInfoParams().toJson());
183183
progress?.finish(showTiming: true);
184-
ResponseDecoder decoder = new ResponseDecoder(null);
184+
ResponseDecoder decoder = ResponseDecoder(null);
185185
final result = EditGetDartfixInfoResult.fromJson(decoder, 'result', json);
186186

187-
final fixes = new List<DartFix>.from(result.fixes)
187+
final fixes = List<DartFix>.from(result.fixes)
188188
..sort((f1, f2) => f1.name.compareTo(f2.name));
189189

190190
logger.stdout('''
@@ -216,8 +216,8 @@ These fixes are NOT automatically applied, but may be enabled using --$includeOp
216216
targets = options.targets;
217217
context = testContext ?? options.context;
218218
logger = testLogger ?? options.logger;
219-
server = new Server(listener: new _Listener(logger));
220-
handler = new _Handler(this);
219+
server = Server(listener: _Listener(logger));
220+
handler = _Handler(this);
221221

222222
// Start showing progress before we start the analysis server.
223223
Progress progress;
@@ -291,10 +291,10 @@ analysis server
291291
logger.trace('');
292292
logger.trace('Setup analysis');
293293
await server.send(SERVER_REQUEST_SET_SUBSCRIPTIONS,
294-
new ServerSetSubscriptionsParams([ServerService.STATUS]).toJson());
294+
ServerSetSubscriptionsParams([ServerService.STATUS]).toJson());
295295
await server.send(
296296
ANALYSIS_REQUEST_SET_ANALYSIS_ROOTS,
297-
new AnalysisSetAnalysisRootsParams(
297+
AnalysisSetAnalysisRootsParams(
298298
options.targets,
299299
const [],
300300
).toJson());

pkg/dartfix/lib/src/options.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class Options {
6767
}
6868

6969
static Options parse(List<String> args, Context context, Logger logger) {
70-
final parser = new ArgParser(allowTrailingOptions: true)
70+
final parser = ArgParser(allowTrailingOptions: true)
7171
..addSeparator('Choosing fixes to be applied:')
7272
..addMultiOption(includeOption,
7373
abbr: 'i', help: 'Include a specific fix.', valueHelp: 'name-of-fix')
@@ -106,26 +106,26 @@ class Options {
106106
help: 'Use ansi colors when printing messages.',
107107
defaultsTo: Ansi.terminalSupportsAnsi);
108108

109-
context ??= new Context();
109+
context ??= Context();
110110

111111
ArgResults results;
112112
try {
113113
results = parser.parse(args);
114114
} on FormatException catch (e) {
115-
logger ??= new Logger.standard(ansi: new Ansi(Ansi.terminalSupportsAnsi));
115+
logger ??= Logger.standard(ansi: Ansi(Ansi.terminalSupportsAnsi));
116116
logger.stderr(e.message);
117117
_showUsage(parser, logger);
118118
context.exit(15);
119119
}
120120

121-
Options options = new Options._fromArgs(context, results);
121+
Options options = Options._fromArgs(context, results);
122122

123123
if (logger == null) {
124124
if (options.verbose) {
125-
logger = new Logger.verbose();
125+
logger = Logger.verbose();
126126
} else {
127-
logger = new Logger.standard(
128-
ansi: new Ansi(
127+
logger = Logger.standard(
128+
ansi: Ansi(
129129
options.useColor != null
130130
? options.useColor
131131
: Ansi.terminalSupportsAnsi,

pkg/dartfix/lib/src/util.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ String findServerPath() {
2828
}
2929
String serverPath =
3030
path.join(parent, 'pkg', 'analysis_server', 'bin', 'server.dart');
31-
if (new File(serverPath).existsSync()) {
31+
if (File(serverPath).existsSync()) {
3232
return serverPath;
3333
}
3434
pathname = parent;

pkg/dartfix/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ dependencies:
2323

2424
dev_dependencies:
2525
analyzer: ^0.33.0
26-
pedantic: ^1.7.0
26+
pedantic: ^1.8.0
2727
test: ^1.3.0

pkg/dartfix/test/src/driver_exclude_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ main() {
1919
exampleFile = findFile('pkg/dartfix/example/example.dart');
2020
exampleDir = exampleFile.parent;
2121

22-
final driver = new Driver();
23-
final testContext = new TestContext();
24-
final testLogger = new TestLogger(debug: _debug);
22+
final driver = Driver();
23+
final testContext = TestContext();
24+
final testLogger = TestLogger(debug: _debug);
2525
String exampleSource = await exampleFile.readAsString();
2626

2727
var args = ['-xuse-mixin', exampleDir.path];

0 commit comments

Comments
 (0)