Skip to content

Commit

Permalink
Unnecessary new (flutter#20138)
Browse files Browse the repository at this point in the history
* enable lint unnecessary_new

* fix tests

* fix tests

* fix tests
  • Loading branch information
a14n authored Sep 12, 2018
1 parent d7a0dca commit d927c93
Show file tree
Hide file tree
Showing 1,285 changed files with 26,524 additions and 26,524 deletions.
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ linter:
- unnecessary_const
- unnecessary_getters_setters
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
# - unnecessary_new # not yet tested
- unnecessary_new
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
- unnecessary_overrides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The following message was thrown running a test:
Who lives, who dies, who tells your story\?

When the exception was thrown, this was the stack:
#[0-9]+ +main.<anonymous closure> \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:16:9\)
#[0-9]+ +main.<anonymous closure> \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:105\)
#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\)
#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\)
#[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\)
Expand Down
4 changes: 2 additions & 2 deletions dev/automated_tests/flutter_test/exception_handling_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ void main() {
throw 'Who lives, who dies, who tells your story?';
});
testWidgets('Exception handling in test harness - FlutterError', (WidgetTester tester) async {
throw new FlutterError('Who lives, who dies, who tells your story?');
throw FlutterError('Who lives, who dies, who tells your story?');
});
testWidgets('Exception handling in test harness - uncaught Future error', (WidgetTester tester) async {
new Future<Null>.error('Who lives, who dies, who tells your story?');
Future<Null>.error('Who lives, who dies, who tells your story?');
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Future<Null> guardedHelper(WidgetTester tester) {
}

void main() {
new TestTestBinding();
TestTestBinding();
testWidgets('TestAsyncUtils - custom guarded sections', (WidgetTester tester) async {
await tester.pumpWidget(new Container());
await tester.pumpWidget(Container());
expect(find.byElementType(Container), isNotNull);
guardedHelper(tester);
expect(find.byElementType(Container), isNull);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<Null> helperFunction(WidgetTester tester) async {
}

void main() {
new TestTestBinding();
TestTestBinding();
testWidgets('TestAsyncUtils - handling unguarded async helper functions', (WidgetTester tester) async {
helperFunction(tester);
helperFunction(tester);
Expand Down
2 changes: 1 addition & 1 deletion dev/automated_tests/flutter_test/ticker_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('Does flutter_test catch leaking tickers?', (WidgetTester tester) async {
new Ticker((Duration duration) { })..start();
Ticker((Duration duration) { })..start();

final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused');
await BinaryMessages.handlePlatformMessage('flutter/lifecycle', message, (_) {});
Expand Down
2 changes: 1 addition & 1 deletion dev/automated_tests/test_smoke_test/timeout_fail_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('flutter_test timeout logic - addTime - negative', (WidgetTester tester) async {
await tester.runAsync(() async {
await new Future<void>.delayed(const Duration(milliseconds: 3500));
await Future<void>.delayed(const Duration(milliseconds: 3500));
}, additionalTime: const Duration(milliseconds: 200));
});
}
2 changes: 1 addition & 1 deletion dev/automated_tests/test_smoke_test/timeout_pass_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('flutter_test timeout logic - addTime - positive', (WidgetTester tester) async {
await tester.runAsync(() async {
await new Future<void>.delayed(const Duration(milliseconds: 2500)); // must be longer than default timeout.
await Future<void>.delayed(const Duration(milliseconds: 2500)); // must be longer than default timeout.
}, additionalTime: const Duration(milliseconds: 2000)); // default timeout is 2s, so this makes it 4s.
});
}
Loading

0 comments on commit d927c93

Please sign in to comment.