Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 102 additions & 31 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# Specify analysis options.
#
# This file is a copy of analysis_options_repo.yaml from flutter repo
# as of 2018-05-30, but with:
# This file is a copy of analysis_options.yaml from flutter repo
# as of 2021-03-19, but with:
# - "always_require_non_null_named_parameters" disabled (because we
# can't import the meta package from the SDK), and
# can't import the meta package from the SDK),
# - "avoid_equals_and_hash_code_on_mutable_classes" disabled (same reason),
# - "missing_whitespace_between_adjacent_strings" disabled (too many false
# positives),
# - "sort_constructors_first" disabled (because we have private fake
# constructors),
# - "prefer_final_fields" disabled (because we do weird things with
# private fields, especially on the PlatformDispatcher object):
# private fields, especially on the PlatformDispatcher object),
# - "public_member_api_docs" enabled.

analyzer:
enable-experiment:
- non-nullable
exclude: [
# this test pretends to be part of dart:ui and results in lots of false
# positives.
Expand All @@ -32,9 +34,8 @@ analyzer:
todo: ignore
# allow dart:ui to import dart:_internal
import_internal_library: ignore
# `flutter analyze` (without `--watch`) just ignores directories
# that contain a .dartignore file, and this file does not have any
# effect on what files are actually analyzed.
# Turned off until null-safe rollout is complete.
unnecessary_null_comparison: ignore

linter:
rules:
Expand All @@ -44,56 +45,89 @@ linter:
- always_declare_return_types
- always_put_control_body_on_new_line
# - 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 # DIFFERENT FROM FLUTTER/FLUTTER
# - always_require_non_null_named_parameters # DIFFERENT FROM FLUTTER/FLUTTER
- always_specify_types
# - always_use_package_imports # we do this commonly
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
# - avoid_as # required for implicit-casts: false
# - avoid_bool_literals_in_conditional_expressions # not yet tested
- avoid_bool_literals_in_conditional_expressions
# - avoid_catches_without_on_clauses # we do this commonly
# - avoid_catching_errors # we do this commonly
- avoid_classes_with_only_static_members # We want to avoid classes that can be instantiated but only have statics
# - avoid_double_and_int_checks # only useful when targeting JS runtime
# - avoid_dynamic_calls # not yet tested
- avoid_empty_else
# - avoid_equals_and_hash_code_on_mutable_classes # DIFFERENT FROM FLUTTER/FLUTTER
# - avoid_escaping_inner_quotes # not yet tested
- avoid_field_initializers_in_const_classes
- avoid_function_literals_in_foreach_calls
# - avoid_implementing_value_types # not yet tested
- avoid_init_to_null
# - avoid_js_rounded_ints # only useful when targeting JS runtime
- avoid_null_checks_in_equality_operators
# - avoid_positional_boolean_parameters # not yet tested
# - avoid_print # not yet tested
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
# - avoid_redundant_argument_values # not yet tested
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
# - avoid_returning_null # we do this commonly
# - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
# - avoid_returning_null # there are plenty of valid reasons to return null
# - avoid_returning_null_for_future # not yet tested
- avoid_returning_null_for_void
# - avoid_returning_this # there are plenty of valid reasons to return this
# - avoid_setters_without_getters # not yet tested
# - avoid_single_cascade_in_expression_statements # not yet tested
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_slow_async_io
# - avoid_types_as_parameter_names # https://github.com/dart-lang/linter/pull/954/files
- avoid_type_to_string
- avoid_types_as_parameter_names
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
# - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
- avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- avoid_void_async
# - avoid_web_libraries_in_flutter # not yet tested
- await_only_futures
- camel_case_extensions
- 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
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough
# - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
# - curly_braces_in_flow_control_structures # not required by flutter style
- deprecated_consistency
# - diagnostic_describe_all_properties # not yet tested
- directives_ordering
# - do_not_use_environment # we do this commonly
- empty_catches
- empty_constructor_bodies
- empty_statements
- exhaustive_cases
- file_names
- flutter_style_todos
- hash_and_equals
- implementation_imports
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
- iterable_contains_unrelated_type
# - join_return_with_assignment # not yet tested
# - join_return_with_assignment # not required by flutter style
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
# - lines_longer_than_80_chars # not required by flutter style
- list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
# - missing_whitespace_between_adjacent_strings # DIFFERENT FROM FLUTTER/FLUTTER
- no_adjacent_strings_in_list
# - no_default_cases # too many false positives
- no_duplicate_case_values
- no_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
- non_constant_identifier_names
- null_check_on_nullable_type_parameter
- null_closures
# - 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
Expand All @@ -104,51 +138,88 @@ linter:
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
- prefer_asserts_in_initializer_lists
# - prefer_asserts_with_message # not required by flutter style
- prefer_collection_literals
- prefer_conditional_assignment
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # not yet tested
# - prefer_constructors_over_static_methods # far too many false positives
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
- prefer_equal_for_default_values
# - 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 # DIFFERENT FROM FLUTTER/FLUTTER
- prefer_final_in_for_each
- prefer_final_locals
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
# - prefer_function_declarations_over_variables # not yet tested
- prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
- prefer_inlined_adds
# - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
# - prefer_interpolation_to_compose_strings # doesn't work with raw strings, see https://github.com/dart-lang/linter/issues/2490
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
- prefer_null_aware_operators
# - prefer_relative_imports # incompatible with sub-package imports
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- public_member_api_docs # this is the only difference from analysis_options.yaml
- prefer_void_to_null
- provide_deprecation_message
- public_member_api_docs # DIFFERENT FROM FLUTTER/FLUTTER
- recursive_getters
- sized_box_for_whitespace
- slash_for_doc_comments
# - sort_child_properties_last # not yet tested
# - sort_constructors_first # DIFFERENT FROM FLUTTER/FLUTTER
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
- sort_unnamed_constructors_first
- test_types_in_equals
- throw_in_finally
- tighten_type_of_initializing_formals
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
# - unawaited_futures # too many false positives
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
# - unnecessary_final # conflicts with prefer_final_locals
- unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
- unnecessary_new
- unnecessary_null_aware_assignments
# - unnecessary_null_checks # not yet tested
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
- unnecessary_parenthesis
# - unnecessary_statements # not yet tested
# - unnecessary_raw_strings # not yet tested
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
# - unsafe_html # not yet tested
- use_full_hex_values_for_flutter_colors
- use_function_type_syntax_for_parameters
# - use_if_null_to_convert_nulls_to_bools # not yet tested
- use_is_even_rather_than_modulo
- use_key_in_widget_constructors
# - use_late_for_private_fields_and_variables # not yet tested
# - use_named_constants # not yet tested
- use_raw_strings
- use_rethrow_when_possible
# - use_setters_to_change_properties # not yet tested
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
- valid_regexps
- void_checks
2 changes: 1 addition & 1 deletion flutter_frontend_server/bin/starter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dart:io';

import 'package:flutter_frontend_server/server.dart';

void main(List<String> args) async {
Future<void> main(List<String> args) async {
final int exitCode = await starter(args);
if (exitCode != 0) {
exit(exitCode);
Expand Down
6 changes: 3 additions & 3 deletions flutter_frontend_server/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface {
}

@override
Future<Null> recompileDelta({String entryPoint}) async {
Future<Null> recompileDelta({String entryPoint}) async { // ignore: prefer_void_to_null
return _compiler.recompileDelta(entryPoint: entryPoint);
}

Expand All @@ -64,7 +64,7 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface {
}

@override
Future<Null> compileExpression(
Future<Null> compileExpression( // ignore: prefer_void_to_null
String expression,
List<String> definitions,
List<String> typeDefinitions,
Expand All @@ -76,7 +76,7 @@ class _FlutterFrontendCompiler implements frontend.CompilerInterface {
}

@override
Future<Null> compileExpressionToJs(
Future<Null> compileExpressionToJs( // ignore: prefer_void_to_null
String libraryUri,
int line,
int column,
Expand Down
2 changes: 1 addition & 1 deletion flutter_frontend_server/test/to_string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:path/path.dart' as path;

import 'package:test/test.dart';

void main(List<String> args) async {
Future<void> main(List<String> args) async {
if (args.length != 2) {
stderr.writeln('The first argument must be the path to the forntend server dill.');
stderr.writeln('The second argument must be the path to the flutter_patched_sdk');
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/hash_codes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int hashValues(
int hashList(Iterable<Object?>? arguments) {
int result = 0;
if (arguments != null) {
for (Object? argument in arguments)
for (final Object? argument in arguments)
result = _Jenkins.combine(result, argument);
}
return _Jenkins.finish(result);
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/natives.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ List<int> saveCompilationTrace() {

dynamic _saveCompilationTrace() native 'SaveCompilationTrace';

void _scheduleMicrotask(void callback()) native 'ScheduleMicrotask';
void _scheduleMicrotask(void Function() callback) native 'ScheduleMicrotask';

int? _getCallbackHandle(Function closure) native 'GetCallbackHandle';
Function? _getCallbackFromHandle(int handle) native 'GetCallbackFromHandle';
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ class Codec extends NativeFieldWrapperClass2 {
if (error != null) {
throw Exception(error);
}
return await completer.future;
return completer.future;
}

/// Returns an error message on failure, null on success.
Expand Down Expand Up @@ -2699,7 +2699,7 @@ class PathMetricIterator implements Iterator<PathMetric> {
if (currentMetric == null) {
throw RangeError(
'PathMetricIterator is not pointing to a PathMetric. This can happen in two situations:\n'
'- The iteration has not started yet. If so, call "moveNext" to start iteration.'
'- The iteration has not started yet. If so, call "moveNext" to start iteration.\n'
'- The iterator ran out of elements. If so, check that "moveNext" returns true prior to calling "current".'
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/platform_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class PlatformDispatcher {
void _dispatchKeyData(ByteData packet, int responseId) {
_invoke2<KeyData, _KeyDataResponseCallback>(
(KeyData data, _KeyDataResponseCallback callback) {
callback(responseId, onKeyData == null ? false : onKeyData!(data));
callback(responseId, onKeyData != null && onKeyData!(data));
},
_onKeyDataZone,
_unpackKeyData(packet),
Expand Down Expand Up @@ -644,7 +644,7 @@ class PlatformDispatcher {
/// platform specific APIs without invoking method channels.
Locale? computePlatformResolvedLocale(List<Locale> supportedLocales) {
final List<String?> supportedLocalesData = <String?>[];
for (Locale locale in supportedLocales) {
for (final Locale locale in supportedLocales) {
supportedLocalesData.add(locale.languageCode);
supportedLocalesData.add(locale.countryCode);
supportedLocalesData.add(locale.scriptCode);
Expand Down
10 changes: 5 additions & 5 deletions lib/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ class TextDecoration {
/// Creates a decoration that paints the union of all the given decorations.
factory TextDecoration.combine(List<TextDecoration> decorations) {
int mask = 0;
for (TextDecoration decoration in decorations)
for (final TextDecoration decoration in decorations)
mask |= decoration._mask;
return TextDecoration._(mask);
}
Expand Down Expand Up @@ -3335,7 +3335,7 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
if (fontFeatures != null) {
encodedFontFeatures = ByteData(fontFeatures.length * FontFeature._kEncodedSize);
int byteOffset = 0;
for (FontFeature feature in fontFeatures) {
for (final FontFeature feature in fontFeatures) {
feature._encode(ByteData.view(encodedFontFeatures.buffer, byteOffset, FontFeature._kEncodedSize));
byteOffset += FontFeature._kEncodedSize;
}
Expand Down Expand Up @@ -3449,13 +3449,13 @@ class ParagraphBuilder extends NativeFieldWrapperClass2 {
TextBaseline? baseline,
}) {
// Require a baseline to be specified if using a baseline-based alignment.
assert((alignment == PlaceholderAlignment.aboveBaseline ||
assert(!(alignment == PlaceholderAlignment.aboveBaseline ||
alignment == PlaceholderAlignment.belowBaseline ||
alignment == PlaceholderAlignment.baseline) ? baseline != null : true);
alignment == PlaceholderAlignment.baseline) || baseline != null);
// Default the baselineOffset to height if null. This will place the placeholder
// fully above the baseline, similar to [PlaceholderAlignment.aboveBaseline].
baselineOffset = baselineOffset ?? height;
_addPlaceholder(width * scale, height * scale, alignment.index, baselineOffset * scale, baseline == null ? null : baseline.index);
_addPlaceholder(width * scale, height * scale, alignment.index, baselineOffset * scale, baseline?.index);
_placeholderCount++;
_placeholderScales.add(scale);
}
Expand Down
Loading