Unverified Commit 53b63581 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Re-enable missing_return (#20844)

parent 458d0b3d
......@@ -26,9 +26,8 @@ analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# TODO(devoncarew): https://github.com/flutter/flutter/issues/20114
# treat missing returns as a warning (not a hint)
missing_return: ignore
missing_return: warning
# allow having TODOs in the code
todo: ignore
exclude:
......
......@@ -600,6 +600,7 @@ Future<Null> _verifyNoTestPackageImports(String workingDirectory) async {
}
return ' $name: uses \'package:test\' directly';
}
return null;
})
.where((String line) => line != null)
.toList()
......
......@@ -141,7 +141,7 @@ Future<Map<String, double>> _readJsonResults(Process process) {
jsonBuf.writeln(line.substring(line.indexOf(jsonPrefix) + jsonPrefix.length));
});
process.exitCode.then<int>((int code) async {
process.exitCode.then<void>((int code) async {
await Future.wait<void>(<Future<void>>[
stdoutSub.cancel(),
stderrSub.cancel(),
......
......@@ -58,6 +58,7 @@ Future<Null> main(List<String> rawArgs) async {
(String line) => line.startsWith('intl:'),
orElse: () {
exitWithError('intl dependency not found in ${dotPackagesFile.path}');
return null; // unreachable
},
)
.split(':')
......
......@@ -71,6 +71,7 @@ class CupertinoNavigationDemo extends StatelessWidget {
],
),
tabBuilder: (BuildContext context, int index) {
assert(index >= 0 && index <= 2);
switch (index) {
case 0:
return new CupertinoTabView(
......@@ -95,8 +96,8 @@ class CupertinoNavigationDemo extends StatelessWidget {
defaultTitle: 'Account',
);
break;
default:
}
return null;
},
),
),
......
......@@ -155,7 +155,8 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
controller: _controller,
isScrollable: true,
indicator: getIndicator(),
tabs: _allPages.map((_Page page) {
tabs: _allPages.map<Tab>((_Page page) {
assert(_demoStyle != null);
switch (_demoStyle) {
case TabsDemoStyle.iconsAndText:
return new Tab(text: page.text, icon: new Icon(page.icon));
......@@ -164,6 +165,7 @@ class ScrollableTabsDemoState extends State<ScrollableTabsDemo> with SingleTicke
case TabsDemoStyle.textOnly:
return new Tab(text: page.text);
}
return null;
}).toList(),
),
),
......
......@@ -156,7 +156,7 @@ Future<Null> runDemos(List<String> demos, FlutterDriver driver) async {
await driver.tap(demoItem); // Launch the demo
if (kUnsynchronizedDemos.contains(demo)) {
await driver.runUnsynchronized<Future<Null>>(() async {
await driver.runUnsynchronized<void>(() async {
await driver.tap(find.byTooltip('Back'));
});
} else {
......
......@@ -12,7 +12,7 @@ void main() {
expect(const SectorConstraints().isTight, isFalse);
});
testWidgets('Sector Sixes', (WidgetTester tester) {
tester.pumpWidget(new SectorApp());
testWidgets('Sector Sixes', (WidgetTester tester) async {
await tester.pumpWidget(new SectorApp());
});
}
......@@ -6,7 +6,7 @@ import 'package:flutter_examples_layers/main.dart' as demo;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('layers smoketest for lib/main.dart', (WidgetTester tester) {
testWidgets('layers smoketest for lib/main.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../services/isolate.dart' as demo;
void main() {
testWidgets('layers smoketest for services/isolate.dart', (WidgetTester tester) {
testWidgets('layers smoketest for services/isolate.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../services/lifecycle.dart' as demo;
void main() {
testWidgets('layers smoketest for services/lifecycle.dart', (WidgetTester tester) {
testWidgets('layers smoketest for services/lifecycle.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/custom_render_box.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/custom_render_box.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/custom_render_box.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/gestures.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/gestures.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/gestures.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/hello_world.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/hello_world.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/hello_world.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/media_query.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/media_query.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/media_query.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/sectors.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/sectors.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/sectors.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/spinning_square.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/spinning_square.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/spinning_square.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import '../../../widgets/styled_text.dart' as demo;
void main() {
testWidgets('layers smoketest for widgets/styled_text.dart', (WidgetTester tester) {
testWidgets('layers smoketest for widgets/styled_text.dart', (WidgetTester tester) async {
demo.main();
});
}
......@@ -26,9 +26,6 @@ analyzer:
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
# TODO(ianh): https://github.com/flutter/flutter/issues/20114
missing_return: ignore
# allow having TODOs in the code
todo: ignore
......
......@@ -313,6 +313,11 @@ class MethodChannel {
///
/// This is intended for testing. Method calls intercepted in this manner are
/// not sent to platform plugins.
///
/// The provided `handler` must return a `Future` that completes with the
/// return value of the call. The value will be encoded using
/// [MethodCodec.encodeSuccessEnvelope], to act as if platform plugin had
/// returned that value.
void setMockMethodCallHandler(Future<dynamic> handler(MethodCall call)) {
BinaryMessages.setMockMessageHandler(
name,
......@@ -413,6 +418,7 @@ class EventChannel {
controller.addError(e);
}
}
return null;
});
try {
await methodChannel.invokeMethod('listen', arguments);
......
......@@ -494,14 +494,14 @@ class AndroidViewController {
}
static int _getAndroidDirection(TextDirection direction) {
assert(direction != null);
switch (direction) {
case TextDirection.ltr:
return kAndroidLayoutDirectionLtr;
case TextDirection.rtl:
return kAndroidLayoutDirectionRtl;
default:
throw new UnsupportedError('Direction $direction is not supported');
}
return null;
}
/// Sends an Android [MotionEvent](https://developer.android.com/reference/android/view/MotionEvent)
......
......@@ -359,9 +359,11 @@ typedef Widget AsyncWidgetBuilder<T>(BuildContext context, AsyncSnapshot<T> snap
/// case ConnectionState.active: return new Text('\$${snapshot.data}');
/// case ConnectionState.done: return new Text('\$${snapshot.data} (closed)');
/// }
/// return null; // unreachable
/// },
/// )
/// ```
// TODO(ianh): remove unreachable code above once https://github.com/dart-lang/linter/issues/1141 is fixed
class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// Creates a new [StreamBuilder] that builds itself based on the latest
/// snapshot of interaction with the specified [stream] and whose build
......@@ -491,9 +493,11 @@ class StreamBuilder<T> extends StreamBuilderBase<T, AsyncSnapshot<T>> {
/// return new Text('Error: ${snapshot.error}');
/// return new Text('Result: ${snapshot.data}');
/// }
/// return null; // unreachable
/// },
/// )
/// ```
// TODO(ianh): remove unreachable code above once https://github.com/dart-lang/linter/issues/1141 is fixed
class FutureBuilder<T> extends StatefulWidget {
/// Creates a widget that builds itself based on the latest snapshot of
/// interaction with a [Future].
......
......@@ -321,12 +321,16 @@ class _HeroFlight {
assert(!_aborted);
assert(() {
final Animation<double> initial = initialManifest.animation;
switch (initialManifest.type) {
assert(initial != null);
final _HeroFlightType type = initialManifest.type;
assert(type != null);
switch (type) {
case _HeroFlightType.pop:
return initial.value == 1.0 && initial.status == AnimationStatus.reverse;
case _HeroFlightType.push:
return initial.value == 0.0 && initial.status == AnimationStatus.forward;
}
return null;
}());
manifest = initialManifest;
......
......@@ -71,6 +71,7 @@ void main() {
}
);
}
return null;
},
),
),
......@@ -86,6 +87,7 @@ void main() {
home: new CupertinoTabView(
onUnknownRoute: (RouteSettings settings) {
unknownForRouteCalled = settings.name;
return null;
},
),
),
......
......@@ -7,7 +7,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('debugPrintGestureArenaDiagnostics', (WidgetTester tester) {
testWidgets('debugPrintGestureArenaDiagnostics', (WidgetTester tester) async {
PointerEvent event;
debugPrintGestureArenaDiagnostics = true;
final DebugPrintCallback oldCallback = debugPrint;
......@@ -53,7 +53,7 @@ void main() {
debugPrint = oldCallback;
});
testWidgets('debugPrintRecognizerCallbacksTrace', (WidgetTester tester) {
testWidgets('debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async {
PointerEvent event;
debugPrintRecognizerCallbacksTrace = true;
final DebugPrintCallback oldCallback = debugPrint;
......@@ -95,7 +95,7 @@ void main() {
debugPrint = oldCallback;
});
testWidgets('debugPrintGestureArenaDiagnostics and debugPrintRecognizerCallbacksTrace', (WidgetTester tester) {
testWidgets('debugPrintGestureArenaDiagnostics and debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async {
PointerEvent event;
debugPrintGestureArenaDiagnostics = true;
debugPrintRecognizerCallbacksTrace = true;
......
......@@ -368,9 +368,11 @@ void main() {
new MaterialApp(
onGenerateRoute: (RouteSettings settings) {
log.add('onGenerateRoute ${settings.name}');
return null;
},
onUnknownRoute: (RouteSettings settings) {
log.add('onUnknownRoute ${settings.name}');
return null;
},
)
);
......
......@@ -250,7 +250,7 @@ void main() {
testWidgets('has semantic events', (WidgetTester tester) async {
dynamic semanticEvent;
bool checkboxValue = false;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message;
});
final SemanticsTester semanticsTester = new SemanticsTester(tester);
......
......@@ -29,7 +29,7 @@ void main () {
setUp(() {
semanticEvents = <Map<String, Object>>[];
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
final Map<dynamic, dynamic> typedMessage = message;
semanticEvents.add(typedMessage.cast<String, Object>());
});
......
......@@ -10,7 +10,7 @@ import 'package:flutter/services.dart';
/// cannot be used in combination with other classes that do the same.
class FeedbackTester {
FeedbackTester() {
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) {
SystemChannels.platform.setMockMethodCallHandler((MethodCall methodCall) async {
if (methodCall.method == 'HapticFeedback.vibrate')
_hapticCount++;
if (methodCall.method == 'SystemSound.play' &&
......
......@@ -216,7 +216,7 @@ void main() {
final Key key = new UniqueKey();
dynamic semanticEvent;
int radioValue = 2;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message;
});
......
......@@ -358,7 +358,7 @@ void main() {
home: new RefreshIndicator(
onRefresh: () {
refreshCalled = true;
// Missing a returned Future value here.
return null; // Missing a returned Future value here, should cause framework to throw.
},
child: new ListView(
physics: const AlwaysScrollableScrollPhysics(),
......
......@@ -274,7 +274,7 @@ void main() {
testWidgets('switch has semantic events', (WidgetTester tester) async {
dynamic semanticEvent;
bool value = false;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message;
});
final SemanticsTester semanticsTester = new SemanticsTester(tester);
......@@ -318,7 +318,7 @@ void main() {
testWidgets('switch sends semantic events from parent if fully merged', (WidgetTester tester) async {
dynamic semanticEvent;
bool value = false;
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvent = message;
});
final SemanticsTester semanticsTester = new SemanticsTester(tester);
......
......@@ -679,7 +679,7 @@ void main() {
testWidgets('has semantic events', (WidgetTester tester) async {
final List<dynamic> semanticEvents = <dynamic>[];
SystemChannels.accessibility.setMockMessageHandler((dynamic message) {
SystemChannels.accessibility.setMockMessageHandler((dynamic message) async {
semanticEvents.add(message);
});
final SemanticsTester semantics = new SemanticsTester(tester);
......
......@@ -13,6 +13,7 @@ void main() {
BinaryMessages.setMockMessageHandler('test1', (ByteData message) async {
log.add(message);
return null;
});
final ByteData message = new ByteData(2)..setUint16(0, 0xABCD);
......
......@@ -98,7 +98,7 @@ void main() {
await tester.pumpWidget(
new TestWidget((BuildContext context) {
disposeCalled = true;
context.visitAncestorElements((Element element) { });
context.visitAncestorElements((Element element) => true);
}),
);
await tester.pumpWidget(new Container());
......
......@@ -788,7 +788,7 @@ void main() {
// Verify TextInput.setEditingState is fired with updated text when controller is replaced.
final List<MethodCall> log = <MethodCall>[];
SystemChannels.textInput.setMockMethodCallHandler((MethodCall methodCall) {
SystemChannels.textInput.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
});
setState(() {
......
......@@ -1027,9 +1027,9 @@ void main() {
textDirection: TextDirection.ltr,
child: new NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
if (notification is ScrollUpdateNotification) {
if (notification is ScrollUpdateNotification)
scrolledPositions.add(notification.metrics.pixels);
}
return false;
},
child: new ListWheelScrollView(
controller: controller,
......@@ -1078,9 +1078,9 @@ void main() {
textDirection: TextDirection.ltr,
child: new NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
if (notification is ScrollUpdateNotification) {
if (notification is ScrollUpdateNotification)
scrolledPositions.add(notification.metrics.pixels);
}
return false;
},
child: new ListWheelScrollView(
controller: controller,
......
......@@ -232,6 +232,7 @@ void main() {
},
);
}
return null;
},
),
),
......
......@@ -66,9 +66,10 @@ void main() {
await tester.pumpWidget(new NotificationListener<MyNotification>(
onNotification: (MyNotification value) {
log.add(value.runtimeType);
return false;
},
child: new NotificationListener<MyNotification>(
onNotification: (MyNotification value) { },
onNotification: (MyNotification value) => false,
child: new Container(key: key),
),
));
......
......@@ -108,6 +108,7 @@ void main() {
case '/3': return new TestRoute<Null>(settings: settings, child: const Text('F'));
case '/4': return new TestRoute<Null>(settings: settings, child: const Text('G'));
}
return null;
}
)
);
......@@ -192,6 +193,7 @@ void main() {
case '/': return new TestRoute<Null>(settings: settings, child: const Text('A'));
case '/1': return new TestRoute<Null>(settings: settings, barrierColor: const Color(0xFFFFFF00), child: const Text('B'));
}
return null;
}
)
);
......
......@@ -21,6 +21,7 @@ void main() {
(TextEditingValue oldValue, TextEditingValue newValue) {
calledOldValue = oldValue;
calledNewValue = newValue;
return null;
}
);
......
......@@ -281,7 +281,7 @@ void main() {
});
test('without clearing timeline', () async {
final Timeline timeline = await driver.traceAction(() {
final Timeline timeline = await driver.traceAction(() async {
log.add('action');
}, retainPriorEvents: true);
......@@ -295,7 +295,7 @@ void main() {
});
test('with clearing timeline', () async {
final Timeline timeline = await driver.traceAction(() {
final Timeline timeline = await driver.traceAction(() async {
log.add('action');
});
......@@ -338,7 +338,7 @@ void main() {
};
});
final Timeline timeline = await driver.traceAction(() {
final Timeline timeline = await driver.traceAction(() async {
actionCalled = true;
},
streams: const <TimelineStream>[
......
......@@ -74,7 +74,7 @@ void main() {
group('getSemanticsId', () {
FlutterDriverExtension extension;
setUp(() {
extension = new FlutterDriverExtension((String arg) async {}, true);
extension = new FlutterDriverExtension((String arg) async => '', true);
});
testWidgets('works when semantics are enabled', (WidgetTester tester) async {
......
......@@ -1531,13 +1531,13 @@ class _MatchesGoldenFile extends AsyncMatcher {
return 'Failed to generate screenshot from engine within the 10,000ms timeout.';
if (autoUpdateGoldenFiles) {
await goldenFileComparator.update(key, bytes.buffer.asUint8List());
} else {
try {
final bool success = await goldenFileComparator.compare(bytes.buffer.asUint8List(), key);
return success ? null : 'does not match';
} on TestFailure catch (ex) {
return ex.message;
}
return null;
}
try {
final bool success = await goldenFileComparator.compare(bytes.buffer.asUint8List(), key);
return success ? null : 'does not match';
} on TestFailure catch (ex) {
return ex.message;
}
}, additionalTime: const Duration(seconds: 11));
}
......
......@@ -500,7 +500,7 @@ void main() {
final Object key = new Object();
await runZoned(() {
expect(Zone.current[key], 'abczed');
return tester.runAsync<String>(() async {
return tester.runAsync<void>(() async {
expect(Zone.current[key], 'abczed');
});
}, zoneValues: <dynamic, dynamic>{
......
......@@ -369,7 +369,7 @@ Future<Null> _recompile(StreamController<List<int>> streamController,
String mockCompilerOutput) async {
// Put content into the output stream after generator.recompile gets
// going few lines below, resets completer.
new Future<List<int>>(() {
scheduleMicrotask(() {
streamController.add(utf8.encode(mockCompilerOutput));
});
final CompilerOutput output = await generator.recompile(null /* mainPath */, <String>['/path/to/main.dart']);
......
......@@ -125,8 +125,12 @@ void main() {
// Crash if called a third time which is unexpected.
mockTimes = <int>[1000, 2000];
final DummyFlutterCommand flutterCommand =
new DummyFlutterCommand(commandFunction: () async { throwToolExit('fail'); });
final DummyFlutterCommand flutterCommand = new DummyFlutterCommand(
commandFunction: () async {
throwToolExit('fail');
return null; // unreachable
},
);
try {
await flutterCommand.run();
......
......@@ -130,7 +130,7 @@ baz=qux
test('fires at start', () async {
bool called = false;
poller = new Poller(() {
poller = new Poller(() async {
called = true;
}, const Duration(seconds: 1));
expect(called, false);
......@@ -141,7 +141,7 @@ baz=qux
test('runs periodically', () async {
// Ensure we get the first (no-delay) callback, and one of the periodic callbacks.
int callCount = 0;
poller = new Poller(() {
poller = new Poller(() async {
callCount++;
}, new Duration(milliseconds: kShortDelay.inMilliseconds ~/ 2));
expect(callCount, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment