From 780e4e621261d620d001f67b6372bc327fc66787 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 10 Mar 2016 13:47:20 -0800 Subject: [PATCH 1/2] move the analysis_options to a file --- .../stocks/lib/i18n/stock_messages_all.dart | 4 +- .../stocks/lib/i18n/stock_messages_en.dart | 2 +- .../stocks/lib/i18n/stock_messages_es.dart | 2 +- packages/flutter_tools/.analysis_options | 32 ++++++++++++++++ .../lib/src/commands/analyze.dart | 37 +------------------ .../test/src/ios/simulators_test.dart | 2 +- .../flutter_tools/tool/daemon_client.dart | 11 +++--- 7 files changed, 45 insertions(+), 45 deletions(-) create mode 100644 packages/flutter_tools/.analysis_options diff --git a/examples/stocks/lib/i18n/stock_messages_all.dart b/examples/stocks/lib/i18n/stock_messages_all.dart index eec8fd5675..97db352668 100644 --- a/examples/stocks/lib/i18n/stock_messages_all.dart +++ b/examples/stocks/lib/i18n/stock_messages_all.dart @@ -1,4 +1,4 @@ -/** +/* * DO NOT EDIT. This is code generated via package:intl/generate_localized.dart * This is a library that looks up messages for specific locales by * delegating to the appropriate library. @@ -28,7 +28,7 @@ MessageLookupByLibrary _findExact(localeName) { } } -/** User programs should call this before using [localeName] for messages.*/ +/// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { initializeInternalMessageLookup(() => new CompositeMessageLookup()); var lib = _deferredLibraries[Intl.canonicalizedLocale(localeName)]; diff --git a/examples/stocks/lib/i18n/stock_messages_en.dart b/examples/stocks/lib/i18n/stock_messages_en.dart index 6dd4d7b2e2..5efc9131b9 100644 --- a/examples/stocks/lib/i18n/stock_messages_en.dart +++ b/examples/stocks/lib/i18n/stock_messages_en.dart @@ -1,4 +1,4 @@ -/** +/* * DO NOT EDIT. This is code generated via package:intl/generate_localized.dart * This is a library that provides messages for a en locale. All the * messages from the main program should be duplicated here with the same diff --git a/examples/stocks/lib/i18n/stock_messages_es.dart b/examples/stocks/lib/i18n/stock_messages_es.dart index d86f146bfd..660cf3ad01 100644 --- a/examples/stocks/lib/i18n/stock_messages_es.dart +++ b/examples/stocks/lib/i18n/stock_messages_es.dart @@ -1,4 +1,4 @@ -/** +/* * DO NOT EDIT. This is code generated via package:intl/generate_localized.dart * This is a library that provides messages for a es locale. All the * messages from the main program should be duplicated here with the same diff --git a/packages/flutter_tools/.analysis_options b/packages/flutter_tools/.analysis_options new file mode 100644 index 0000000000..9f03027963 --- /dev/null +++ b/packages/flutter_tools/.analysis_options @@ -0,0 +1,32 @@ +# 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/ + +analyzer: + errors: + # we allow overriding fields (if they use super, ideally...) + strong_mode_invalid_field_override: ignore + # we allow type narrowing + strong_mode_invalid_method_override: ignore + todo: ignore +linter: + rules: + - always_declare_return_types + # we'll turn on avoid_as as soon as it doesn't complain about "as dynamic" + # - avoid_as + - camel_case_types + # sometimes we have no choice (e.g. when matching other platforms) + # - constant_identifier_names + - empty_constructor_bodies + # disabled until regexp fix is pulled in (https://github.com/flutter/flutter/pull/1996) + # - library_names + - library_prefixes + - non_constant_identifier_names + # too many false-positives; code review should catch real instances + # - one_member_abstracts + - slash_for_doc_comments + - super_goes_last + - type_init_formals + - unnecessary_brace_in_string_interp diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index c6afb1b399..8e3820db4a 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -274,43 +274,10 @@ class AnalyzeCommand extends FlutterCommand { for (String package in packages.keys) packagesBody.writeln('$package:${path.toUri(packages[package])}'); - /// 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/ - String optionsBody = ''' -analyzer: - errors: - # we allow overriding fields (if they use super, ideally...) - strong_mode_invalid_field_override: ignore - # we allow type narrowing - strong_mode_invalid_method_override: ignore - todo: ignore -linter: - rules: - - always_declare_return_types - # we'll turn on avoid_as as soon as it doesn't complain about "as dynamic" - # - avoid_as - - camel_case_types - # sometimes we have no choice (e.g. when matching other platforms) - # - constant_identifier_names - - empty_constructor_bodies - # disabled until regexp fix is pulled in (https://github.com/flutter/flutter/pull/1996) - # - library_names - - library_prefixes - - non_constant_identifier_names - # too many false-positives; code review should catch real instances - # - one_member_abstracts - - slash_for_doc_comments - - super_goes_last - - type_init_formals - - unnecessary_brace_in_string_interp -'''; - // save the Dart file and the .packages file to disk Directory host = Directory.systemTemp.createTempSync('flutter-analyze-'); File mainFile = new File(path.join(host.path, 'main.dart'))..writeAsStringSync(mainBody.toString()); - File optionsFile = new File(path.join(host.path, '_analysis.options'))..writeAsStringSync(optionsBody.toString()); + File optionsFile = new File(path.join(ArtifactStore.flutterRoot, 'packages', 'flutter_tools', '.analysis_options')); File packagesFile = new File(path.join(host.path, '.packages'))..writeAsStringSync(packagesBody.toString()); List cmd = [ @@ -648,7 +615,7 @@ class PackageDependencyTracker { result.writeln('Package "$package" has conflicts:'); packages[package].describeConflict(result); } - return result.toString(); + return result.toString(); } Map asPackageMap() { diff --git a/packages/flutter_tools/test/src/ios/simulators_test.dart b/packages/flutter_tools/test/src/ios/simulators_test.dart index 38bc1081be..1a71174b79 100644 --- a/packages/flutter_tools/test/src/ios/simulators_test.dart +++ b/packages/flutter_tools/test/src/ios/simulators_test.dart @@ -2,7 +2,7 @@ import 'package:test/test.dart'; import 'package:flutter_tools/src/ios/simulators.dart'; -main() { +void main() { group('compareIosVersions', () { test('compares correctly', () { // This list must be sorted in ascending preference order diff --git a/packages/flutter_tools/tool/daemon_client.dart b/packages/flutter_tools/tool/daemon_client.dart index e1be9ffa47..add1c4dd4c 100644 --- a/packages/flutter_tools/tool/daemon_client.dart +++ b/packages/flutter_tools/tool/daemon_client.dart @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:async'; import 'dart:convert'; import 'dart:io'; @@ -14,14 +15,14 @@ Process daemon; // stopAll: stop any running app // devices: list devices -main() async { +Future main() async { daemon = await Process.start('flutter', ['daemon']); print('daemon process started, pid: ${daemon.pid}'); daemon.stdout .transform(UTF8.decoder) .transform(const LineSplitter()) - .listen((String line) => print('<== ${line}')); + .listen((String line) => print('<== $line')); daemon.stderr.listen((data) => stderr.add(data)); stdout.write('> '); @@ -37,13 +38,13 @@ main() async { } else if (line == 'devices') { _send({'method': 'device.getDevices'}); } else { - print('command not understood: ${line}'); + print('command not understood: $line'); } stdout.write('> '); }); daemon.exitCode.then((int code) { - print('daemon exiting (${code})'); + print('daemon exiting ($code)'); exit(code); }); } @@ -54,5 +55,5 @@ void _send(Map map) { map['id'] = id++; String str = '[${JSON.encode(map)}]'; daemon.stdin.writeln(str); - print('==> ${str}'); + print('==> $str'); } From b9fafc176509ea198636ed08db4427b57c9b9af1 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Thu, 10 Mar 2016 14:21:23 -0800 Subject: [PATCH 2/2] adjust a regex for intl files --- packages/flutter_tools/lib/src/commands/analyze.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 8e3820db4a..b7fc07d4be 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -387,7 +387,7 @@ class AnalyzeCommand extends FlutterCommand { } else if (filename.endsWith('.mojom.dart')) { // autogenerated code - TODO(ianh): Fix the Dart mojom compiler shouldIgnore = true; - } else if ((sourceLines[0] == '/**') && (' * DO NOT EDIT. This is code generated'.matchAsPrefix(sourceLines[1]) != null)) { + } else if ((sourceLines[0] == '/*') && (' * DO NOT EDIT. This is code generated'.matchAsPrefix(sourceLines[1]) != null)) { // autogenerated code - TODO(ianh): Fix the intl package resource generator shouldIgnore = true; } else if (level == 'lint' && errorMessage == 'Name non-constant identifiers using lowerCamelCase.') {