Enable ALL THE LINTS

Well, all the easy ones, anyway.

For some reason `// ignore:` isn't working for me so I've disabled
lints that need that. Also disabled those that require a ton of work
(which I'm doing, but not in this PR, to keep it reviewable).

This adds:
- avoid_init_to_null
- library_names
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
- sort_constructors_first
- sort_unnamed_constructors_first
- unnecessary_getters_setters
This commit is contained in:
Ian Hickson
2016-03-10 23:15:31 -08:00
parent 7544514484
commit 1b9cd52081
41 changed files with 271 additions and 264 deletions

View File

@@ -15,20 +15,30 @@ linter:
rules:
- avoid_empty_else
- always_declare_return_types
# we'll turn on avoid_as as soon as it doesn't complain about "as dynamic"
# - avoid_as
# - always_specify_types # still a lot of work to do before enabling this one
# - annotate_overrides # still a lot of work to do before enabling this one
# - avoid_as # https://github.com/dart-lang/linter/issues/195
- avoid_init_to_null
# - avoid_return_types_on_setters # still a lot of work to do before enabling this one
- camel_case_types
# sometimes we have no choice (e.g. when matching other platforms)
# - constant_identifier_names
# - constant_identifier_names # still a lot of work to do before enabling this one
- empty_constructor_bodies
- hash_and_equals
# disabled until regexp fix is pulled in (https://github.com/flutter/flutter/pull/1996)
# - library_names
# - implementation_imports # "// ignore:" isn't working yet
- library_names
- library_prefixes
- non_constant_identifier_names
# too many false-positives; code review should catch real instances
# - one_member_abstracts
# - one_member_abstracts # "// ignore:" isn't working yet
- package_api_docs
- package_names
- package_prefixed_library_names
- prefer_is_not_empty
# - public_member_api_docs # still a lot of work to do before enabling this one
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
# - type_annotate_public_apis # see always_specify_types, which this is a subset of
- type_init_formals
- unnecessary_brace_in_string_interp
- unnecessary_getters_setters

View File

@@ -329,7 +329,7 @@ class AndroidDevice extends Device {
RegExp traceRegExp = new RegExp(r'Saving trace to (\S+)', multiLine: true);
RegExp completeRegExp = new RegExp(r'Trace complete', multiLine: true);
String tracePath = null;
String tracePath;
bool isComplete = false;
while (!isComplete) {
List<String> args = <String>['logcat', '-d'];

View File

@@ -109,9 +109,6 @@ void _addFlatPackageList(String subPath, List<String> dartFiles, Set<String> pub
class FileChanged { }
class AnalyzeCommand extends FlutterCommand {
String get name => 'analyze';
String get description => 'Analyze the project\'s Dart code.';
AnalyzeCommand() {
argParser.addFlag('flutter-repo', help: 'Include all the examples and tests from the Flutter repository.', defaultsTo: false);
argParser.addFlag('current-directory', help: 'Include all the Dart files in the current directory, if any.', defaultsTo: true);
@@ -121,6 +118,8 @@ class AnalyzeCommand extends FlutterCommand {
argParser.addFlag('watch', help: 'Run analysis continuously, watching the filesystem for changes.', negatable: false);
}
String get name => 'analyze';
String get description => 'Analyze the project\'s Dart code.';
bool get requiresProjectRoot => false;
bool get isFlutterRepo {

View File

@@ -402,7 +402,7 @@ Future<int> buildAndroid({
printStatus('Building APK...');
if (!flxPath.isEmpty) {
if (flxPath.isNotEmpty) {
if (!FileSystemEntity.isFileSync(flxPath)) {
printError('FLX does not exist: $flxPath');
printError('(Omit the --flx option to build the FLX automatically)');

View File

@@ -5,7 +5,7 @@
import 'dart:async';
import 'package:path/path.dart' as path;
import 'package:test/src/executable.dart' as executable;
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports
import '../android/android_device.dart' show AndroidDevice;
import '../application_package.dart';

View File

@@ -6,7 +6,7 @@ import 'dart:async';
import 'dart:io';
import 'package:path/path.dart' as path;
import 'package:test/src/executable.dart' as executable;
import 'package:test/src/executable.dart' as executable; // ignore: implementation_imports
import '../artifacts.dart';
import '../build_configuration.dart';
@@ -15,9 +15,16 @@ import '../runner/flutter_command.dart';
import '../test/flutter_platform.dart' as loader;
class TestCommand extends FlutterCommand {
TestCommand() {
argParser.addFlag(
'flutter-repo',
help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.',
defaultsTo: false
);
}
String get name => 'test';
String get description => 'Run Flutter unit tests for the current project (Linux only).';
bool get requiresProjectRoot => false;
@override
@@ -50,14 +57,6 @@ class TestCommand extends FlutterCommand {
}
}
TestCommand() {
argParser.addFlag(
'flutter-repo',
help: 'Run tests from the \'flutter\' package in the Flutter repository instead of the current directory.',
defaultsTo: false
);
}
Iterable<String> _findTests(Directory directory) {
return directory.listSync(recursive: true, followLinks: false)
.where((FileSystemEntity entity) => entity.path.endsWith('_test.dart') &&

View File

@@ -223,43 +223,6 @@ class DeviceStore {
this.iOSSimulator
});
final AndroidDevice android;
final IOSDevice iOS;
final IOSSimulator iOSSimulator;
List<Device> get all {
List<Device> result = <Device>[];
if (android != null)
result.add(android);
if (iOS != null)
result.add(iOS);
if (iOSSimulator != null)
result.add(iOSSimulator);
return result;
}
static Device _deviceForConfig(BuildConfiguration config, List<Device> devices) {
Device device = null;
if (config.deviceId != null) {
// Step 1: If a device identifier is specified, try to find a device
// matching that specific identifier
device = devices.firstWhere(
(Device dev) => (dev.id == config.deviceId),
orElse: () => null);
} else if (devices.length == 1) {
// Step 2: If no identifier is specified and there is only one connected
// device, pick that one.
device = devices[0];
} else if (devices.length > 1) {
// Step 3: D:
printStatus('Multiple devices are connected, but no device ID was specified.');
printStatus('Attempting to launch on all connected devices.');
}
return device;
}
factory DeviceStore.forConfigs(List<BuildConfiguration> configs) {
AndroidDevice android;
IOSDevice iOS;
@@ -287,4 +250,41 @@ class DeviceStore {
return new DeviceStore(android: android, iOS: iOS, iOSSimulator: iOSSimulator);
}
final AndroidDevice android;
final IOSDevice iOS;
final IOSSimulator iOSSimulator;
List<Device> get all {
List<Device> result = <Device>[];
if (android != null)
result.add(android);
if (iOS != null)
result.add(iOS);
if (iOSSimulator != null)
result.add(iOSSimulator);
return result;
}
static Device _deviceForConfig(BuildConfiguration config, List<Device> devices) {
Device device;
if (config.deviceId != null) {
// Step 1: If a device identifier is specified, try to find a device
// matching that specific identifier
device = devices.firstWhere(
(Device dev) => (dev.id == config.deviceId),
orElse: () => null);
} else if (devices.length == 1) {
// Step 2: If no identifier is specified and there is only one connected
// device, pick that one.
device = devices[0];
} else if (devices.length > 1) {
// Step 3: D:
printStatus('Multiple devices are connected, but no device ID was specified.');
printStatus('Attempting to launch on all connected devices.');
}
return device;
}
}

View File

@@ -25,12 +25,6 @@ const String _kCopyTemplateExtension = '.copy.tmpl';
/// Files in the destination will not contain either the '.tmpl' or '.copy.tmpl'
/// extensions.
class Template {
factory Template.fromName(String name) {
// All named templates are placed in the 'templates' directory
Directory templateDir = _templateDirectoryInPackage(name);
return new Template(templateDir, templateDir);
}
Template(Directory templateSource, Directory baseDir) {
_templateFilePaths = new Map<String, String>();
@@ -58,6 +52,12 @@ class Template {
}
}
factory Template.fromName(String name) {
// All named templates are placed in the 'templates' directory
Directory templateDir = _templateDirectoryInPackage(name);
return new Template(templateDir, templateDir);
}
Map<String /* relative */, String /* absolute source */> _templateFilePaths;
void render(Directory destination, Map<String, dynamic> context,

View File

@@ -10,9 +10,9 @@ import 'package:async/async.dart';
import 'package:path/path.dart' as path;
import 'package:stream_channel/stream_channel.dart';
import 'package:test/src/backend/test_platform.dart';
import 'package:test/src/runner/plugin/platform.dart';
import 'package:test/src/runner/plugin/hack_register_platform.dart' as hack;
import 'package:test/src/backend/test_platform.dart'; // ignore: implementation_imports
import 'package:test/src/runner/plugin/platform.dart'; // ignore: implementation_imports
import 'package:test/src/runner/plugin/hack_register_platform.dart' as hack; // ignore: implementation_imports
import '../artifacts.dart';