Commit 94636bd2 authored by Ian Hickson's avatar Ian Hickson

Cleanup based on new lints (#4052)

parent 4052aa71
# Specify analysis options.
#
# Note that until there is a default "all-in" lint rule-set we need
# to opt-in to all desired lints (https://github.com/dart-lang/sdk/issues/25843).
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# This file is the .analysis_options file used by Flutter editors, such as
# Atom. It is very similar to flutter_tools/flutter_analysis_options; the only
......@@ -23,33 +19,52 @@ analyzer:
strong_mode_down_cast_composite: ignore
# we allow having TODOs in the code
todo: ignore
linter:
rules:
# these are in the same order as http://dart-lang.github.io/linter/lints/
# to make maintenance easier
# error rules
- avoid_empty_else
# - comment_references
- control_flow_in_finally
- hash_and_equals
# - iterable_contains_unrelated_type
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
# style rules
- always_declare_return_types
- always_specify_types
- annotate_overrides
- avoid_as
- avoid_init_to_null
# - avoid_return_types_on_setters # https://github.com/dart-lang/linter/issues/202
- avoid_return_types_on_setters
- await_only_futures
- camel_case_types
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 (and 203)
# - constant_identifier_names
- control_flow_in_finally
- empty_constructor_bodies
- hash_and_equals
# - implementation_imports # https://github.com/dart-lang/linter/issues/203
- implementation_imports
- library_names
- library_prefixes
- non_constant_identifier_names
# - one_member_abstracts # https://github.com/dart-lang/linter/issues/203
- one_member_abstracts
# - overriden_field
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
# - public_member_api_docs
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- type_annotate_public_apis # subset of always_specify_types
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
- unnecessary_brace_in_string_interp
- unnecessary_getters_setters
# pub rules
- package_names
......@@ -290,7 +290,7 @@ class FlutterError extends AssertionError {
}
result.add(line);
}
if (skipped == 1) {
if (skipped.length == 1) {
result.add('(elided one frame from ${skipped.single})');
} else if (skipped.length > 1) {
List<String> where = new Set<String>.from(skipped).toList()..sort();
......
......@@ -963,6 +963,11 @@ abstract class RenderBox extends RenderObject {
int _debugActivePointers = 0;
/// Override this function to handle pointer events that hit this render object.
///
/// For [RenderBox] objects, the `entry` argument is a [BoxHitTestEntry]. From this
/// object you can determine the [PointerDownEvent]'s position in local coordinates.
/// (This is useful because [PointerEvent.position] is in global coordinates.)
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
super.handleEvent(event, entry);
......
......@@ -130,8 +130,13 @@ class Focus extends StatefulWidget {
if (debugOnlyFocusedKey?.currentContext == null)
debugOnlyFocusedKey = context.widget.key;
if (debugOnlyFocusedKey != context.widget.key) {
debugPrint('Tried to focus widgets with two different keys: $debugOnlyFocusedKey and ${context.widget.key}');
assert('If you have more than one focusable widget, then you should put them inside a Focus.' == true);
throw new FlutterError(
'Missing Focus scope.\n'
'Two focusable widgets with different keys, $debugOnlyFocusedKey and ${context.widget.key}, '
'exist in the widget tree simultaneously, but they have no Focus widget ancestor.\n'
'If you have more than one focusable widget, then you should put them inside a Focus. '
'Normally, this is done for you using a Route, via Navigator, WidgetsApp, or MaterialApp.'
);
}
return true;
});
......
......@@ -183,7 +183,7 @@ void main() {
expect(callbackTracker, equals(<int>[0, 1, 2]));
callbackTracker.clear();
await tester.allWidgets.forEach(collectText);
tester.allWidgets.forEach(collectText);
expect(text, equals(<String>['0', '1', '2']));
text.clear();
......@@ -191,7 +191,7 @@ void main() {
expect(callbackTracker, equals(<int>[0, 1, 2]));
callbackTracker.clear();
await tester.allWidgets.forEach(collectText);
tester.allWidgets.forEach(collectText);
expect(text, equals(<String>['0', '1', '2']));
text.clear();
});
......
......@@ -3,11 +3,13 @@
# Note that until there is a default "all-in" lint rule-set we need
# to opt-in to all desired lints (https://github.com/dart-lang/sdk/issues/25843).
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
#
# This file is the .analysis_options file used by "flutter analyze".
# It isn't named that because otherwise editors like Atom would try
# to use it, and that wouldn't work because it enables things that
# need to be silenced, in particular, public_member_api_docs.
#
# When editing, make sure you keep /.analysis_options consistent.
analyzer:
language:
......@@ -23,26 +25,41 @@ analyzer:
strong_mode_down_cast_composite: ignore
# we allow having TODOs in the code
todo: ignore
linter:
rules:
# these are in the same order as http://dart-lang.github.io/linter/lints/
# to make maintenance easier
# # error rules
- avoid_empty_else
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
- control_flow_in_finally
- hash_and_equals
# - iterable_contains_unrelated_type # https://github.com/dart-lang/linter/issues/245
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
# style rules
- always_declare_return_types
- always_specify_types
- annotate_overrides
- avoid_as
- avoid_init_to_null
- avoid_return_types_on_setters
- await_only_futures
- camel_case_types
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 (and 203)
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
- empty_constructor_bodies
- hash_and_equals
- implementation_imports
- library_names
- library_prefixes
- non_constant_identifier_names
- one_member_abstracts
# - overriden_field # the analyzer code itself violates this right now :-)
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
- public_member_api_docs
......@@ -50,6 +67,10 @@ linter:
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
- unnecessary_brace_in_string_interp
- unnecessary_getters_setters
# pub rules
- package_names
......@@ -91,8 +91,10 @@ Future<Null> main(List<String> args) async {
if (error is UsageException) {
stderr.writeln(error.message);
stderr.writeln();
stderr.writeln("Run 'flutter -h' (or 'flutter <command> -h') for available "
"flutter commands and options.");
stderr.writeln(
"Run 'flutter -h' (or 'flutter <command> -h') for available "
"flutter commands and options."
);
// Argument error exit code.
_exit(64);
} else if (error is ProcessExit) {
......@@ -118,7 +120,8 @@ Future<Null> main(List<String> args) async {
stderr.writeln(
'Crash report written to ${file.path};\n'
'please let us know at https://github.com/flutter/flutter/issues.');
'please let us know at https://github.com/flutter/flutter/issues.'
);
}
_exit(1);
......@@ -129,21 +132,21 @@ Future<Null> main(List<String> args) async {
File _createCrashReport(List<String> args, dynamic error, Chain chain) {
File crashFile = getUniqueFile(Directory.current, 'flutter', 'log');
StringBuffer buf = new StringBuffer();
StringBuffer buffer = new StringBuffer();
buf.writeln('Flutter crash report; please file at https://github.com/flutter/flutter/issues.\n');
buffer.writeln('Flutter crash report; please file at https://github.com/flutter/flutter/issues.\n');
buf.writeln('## command\n');
buf.writeln('flutter ${args.join(' ')}\n');
buffer.writeln('## command\n');
buffer.writeln('flutter ${args.join(' ')}\n');
buf.writeln('## exception\n');
buf.writeln('$error\n');
buf.writeln('```\n${chain.terse}```\n');
buffer.writeln('## exception\n');
buffer.writeln('$error\n');
buffer.writeln('```\n${chain.terse}```\n');
buf.writeln('## flutter doctor\n');
buf.writeln('```\n${_doctorText()}```');
buffer.writeln('## flutter doctor\n');
buffer.writeln('```\n${_doctorText()}```');
crashFile.writeAsStringSync(buf.toString());
crashFile.writeAsStringSync(buffer.toString());
return crashFile;
}
......@@ -179,7 +182,7 @@ Future<Null> _exit(int code) async {
logger.flush();
// Give the task / timer queue one cycle through before we hard exit.
await Timer.run(() {
Timer.run(() {
printTrace('exiting with code $code');
exit(code);
});
......
......@@ -261,7 +261,7 @@ Future<int> startApp(DriveCommand command, BuildMode buildMode) async {
printTrace('Installing application package.');
ApplicationPackage package = command.applicationPackages
.getPackageForPlatform(command.device.platform);
await command.device.installApp(package);
command.device.installApp(package);
printTrace('Starting application.');
LaunchResult result = await command.device.startApp(
......
......@@ -205,7 +205,7 @@ Future<int> startApp(
if (install && device is AndroidDevice) {
printStatus('Installing $package to $device...');
if (!(await installApp(device, package)))
if (!(installApp(device, package)))
return 1;
}
......@@ -345,7 +345,7 @@ class _RunAndStayResident {
// TODO(devoncarew): This fails for ios devices - we haven't built yet.
if (device is AndroidDevice) {
printTrace('Running install command.');
if (!(await installApp(device, package)))
if (!(installApp(device, package)))
return 1;
}
......
......@@ -78,7 +78,7 @@ class SimControl {
bool connected = false;
int attempted = 0;
while (!connected && attempted < 20) {
connected = await _isAnyConnected();
connected = _isAnyConnected();
if (!connected) {
printStatus('Still waiting for iOS Simulator to boot...');
await new Future<Null>.delayed(new Duration(seconds: 1));
......
......@@ -24,7 +24,7 @@ Future<Null> main() async {
final Uint8List kTestBytes = new Uint8List.fromList(<int>[1, 2, 3]);
// Create a temp dir and file for the bundle.
Directory tempDir = await Directory.systemTemp.createTempSync('bundle_test');
Directory tempDir = Directory.systemTemp.createTempSync('bundle_test');
String bundlePath = tempDir.path + '/bundle.flx';
AsymmetricKeyPair<PublicKey, PrivateKey> keyPair = keyPairFromPrivateKeyBytes(kPrivateKeyDER);
......
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