Skip to content

Commit

Permalink
Analysis cleanup of the Dart in the Engine repo (flutter#4554)
Browse files Browse the repository at this point in the history
* Analysis cleanup of the Dart in the Engine repo

* Update painting.dart

* Update painting.dart
  • Loading branch information
Hixie authored Jan 17, 2018
1 parent 6de9931 commit f3f005c
Show file tree
Hide file tree
Showing 23 changed files with 728 additions and 439 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: dart
dart:
- "dev/release/1.25.0-dev.11.0"
- dev
sudo: false
before_script:
- ./travis/setup.sh
Expand Down
99 changes: 53 additions & 46 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# Specify analysis options.
#
# This file is a copy of analysis_options_repo.yaml from flutter repo:
# https://github.com/flutter/flutter/blob/master/analysis_options_repo.yaml
# This file is a copy of analysis_options_repo.yaml from flutter repo
# as of 2018-01-07, but with "sort_constructors_first" disabled
# (because we have private fake constructors), with
# "always_require_non_null_named_parameters" disabled (because we
# can't import the meta package from the SDK), and with
# "prefer_final_fields" disabled (because we do weird things with
# private fields, especially on the Window object):
# https://github.com/lfutter/flutter/blob/master/analysis_options_repo.yaml

analyzer:
language:
enableStrictCallChecks: true
enableSuperMixins: true
enableAssertInitializer: true
strong-mode:
implicit-dynamic: false
errors:
Expand All @@ -22,88 +27,90 @@ linter:
rules:
# these rules are documented on and in the same order as
# the Dart Lint rules page to make maintenance easier
# http://dart-lang.github.io/linter/lints/

# === error rules ===
- avoid_empty_else
- avoid_slow_async_io
- cancel_subscriptions
# - close_sinks # https://github.com/flutter/flutter/issues/5789
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
- control_flow_in_finally
- empty_statements
- hash_and_equals
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
- iterable_contains_unrelated_type
- list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
- valid_regexps

# === style rules ===
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
- always_declare_return_types
- always_put_control_body_on_new_line
- always_require_non_null_named_parameters
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
# always_require_non_null_named_parameters
- always_specify_types
- annotate_overrides
# - avoid_annotating_with_dynamic # not yet tested
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
- avoid_as
# - avoid_catches_without_on_clauses # not yet tested
# - avoid_catching_errors # not yet tested
# - avoid_classes_with_only_static_members # not yet tested
# - avoid_function_literals_in_foreach_calls # not yet tested
# - avoid_catches_without_on_clauses # we do this commonly
# - avoid_catching_errors # we do this commonly
- avoid_classes_with_only_static_members
- avoid_empty_else
- avoid_function_literals_in_foreach_calls
- avoid_init_to_null
- avoid_null_checks_in_equality_operators
# - avoid_positional_boolean_parameters # not yet tested
- avoid_return_types_on_setters
# - avoid_returning_null # not yet tested
# - avoid_returning_this # not yet tested
# - avoid_returning_null # we do this commonly
# - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
# - avoid_setters_without_getters # not yet tested
# - avoid_types_on_closure_parameters # not yet tested
- avoid_slow_async_io
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
# - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
- await_only_futures
- camel_case_types
- cancel_subscriptions
# - cascade_invocations # not yet tested
# - close_sinks # https://github.com/flutter/flutter/issues/5789
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
- directives_ordering
- empty_catches
- empty_constructor_bodies
- empty_statements
- hash_and_equals
- implementation_imports
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
- iterable_contains_unrelated_type
# - join_return_with_assignment # not yet tested
- library_names
- library_prefixes
- list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
- overridden_fields
- package_api_docs
- package_names
- package_prefixed_library_names
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
# - prefer_bool_in_asserts # not yet tested
- prefer_collection_literals
# - prefer_conditional_assignment # not yet tested
# - prefer_const_constructors # https://github.com/dart-lang/linter/issues/752
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
# - prefer_constructors_over_static_methods # not yet tested
- prefer_contains
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
# - prefer_final_fields
- prefer_final_locals
# - prefer_foreach # not yet tested
- prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
- prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty
- prefer_is_not_empty
- public_member_api_docs # this is the only difference from analysis_options_repo.yaml
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
- prefer_single_quotes
- prefer_typing_uninitialized_variables
- public_member_api_docs # this is the only difference from analysis_options.yaml
- recursive_getters
- slash_for_doc_comments
- sort_constructors_first
# - sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals
- throw_in_finally
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
Expand All @@ -112,12 +119,12 @@ linter:
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
# - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
- unnecessary_overrides
# - unnecessary_statements # not yet tested
- unnecessary_this
- unrelated_type_equality_checks
- use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review

# === pub rules ===
- package_names
- valid_regexps
3 changes: 3 additions & 0 deletions frontend_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.dill
pubspec.lock
.packages
52 changes: 0 additions & 52 deletions frontend_server/.packages

This file was deleted.

14 changes: 7 additions & 7 deletions frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class _FrontendCompiler implements CompilerInterface {
IncrementalKernelGenerator generator,
}) async {
final Uri filenameUri = Uri.base.resolveUri(new Uri.file(filename));
_kernelBinaryFilename = "$filename.dill";
_kernelBinaryFilename = '$filename.dill';
final String boundaryKey = new Uuid().generateV4();
_outputStream.writeln("result $boundaryKey");
_outputStream.writeln('result $boundaryKey');
final Uri sdkRoot = _ensureFolderPath(options['sdk-root']);
final String byteStorePath = options['byte-store'];
final CompilerOptions compilerOptions = new CompilerOptions()
Expand Down Expand Up @@ -182,7 +182,7 @@ class _FrontendCompiler implements CompilerInterface {
final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink);
printer.writeProgramFile(program);
await sink.close();
_outputStream.writeln("$boundaryKey $_kernelBinaryFilename");
_outputStream.writeln('$boundaryKey $_kernelBinaryFilename');
} else
_outputStream.writeln(boundaryKey);
return null;
Expand All @@ -191,13 +191,13 @@ class _FrontendCompiler implements CompilerInterface {
@override
Future<Null> recompileDelta() async {
final String boundaryKey = new Uuid().generateV4();
_outputStream.writeln("result $boundaryKey");
_outputStream.writeln('result $boundaryKey');
final DeltaProgram deltaProgram = await _generator.computeDelta();
final IOSink sink = new File(_kernelBinaryFilename).openWrite();
final BinaryPrinter printer = printerFactory.newBinaryPrinter(sink);
printer.writeProgramFile(deltaProgram.newProgram);
await sink.close();
_outputStream.writeln("$boundaryKey $_kernelBinaryFilename");
_outputStream.writeln('$boundaryKey $_kernelBinaryFilename');
return null;
}

Expand Down Expand Up @@ -282,7 +282,7 @@ Future<int> starter(
// Has to be a directory, that won't have any of the compiled application
// sources, so that no relative paths could show up in the kernel file.
Directory.current = Directory.systemTemp;
final Directory workingDirectory = new Directory("flutter_frontend_server");
final Directory workingDirectory = new Directory('flutter_frontend_server');
workingDirectory.createSync();
Directory.current = workingDirectory;

Expand All @@ -295,7 +295,7 @@ Future<int> starter(
String boundaryKey;
input
.transform(UTF8.decoder)
.transform(new LineSplitter())
.transform(const LineSplitter())
.listen((String string) async {
switch (state) {
case _State.READY_FOR_INSTRUCTION:
Expand Down
4 changes: 2 additions & 2 deletions frontend_server/test/server_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ Future<int> main() async {
String boundaryKey;
stdoutStreamController.stream
.transform(UTF8.decoder)
.transform(new LineSplitter())
.transform(const LineSplitter())
.listen((String s) {
const String RESULT_OUTPUT_SPACE = 'result ';
if (boundaryKey == null) {
Expand All @@ -387,7 +387,7 @@ Future<int> main() async {
final _MockedIncrementalKernelGenerator generator =
new _MockedIncrementalKernelGenerator();
when(generator.computeDelta()).thenReturn(new Future<DeltaProgram>.value(
new DeltaProgram("", null /* program stub */)
new DeltaProgram('', null /* program stub */)
));
final _MockedBinaryPrinterFactory printerFactory =
new _MockedBinaryPrinterFactory();
Expand Down
Loading

0 comments on commit f3f005c

Please sign in to comment.