2016-05-04 17:15:15 +00:00
# Specify analysis options.
2016-09-09 17:37:56 +00:00
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
2018-08-20 19:51:07 +00:00
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
2017-08-15 12:46:42 +00:00
# - analysis_options.yaml (this file)
2017-02-13 21:39:35 +00:00
# - packages/flutter/lib/analysis_options_user.yaml
2017-08-15 12:46:42 +00:00
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
2018-05-10 16:48:40 +00:00
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
2017-02-13 21:39:35 +00:00
#
2018-06-13 19:46:39 +00:00
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
2016-05-04 17:15:15 +00:00
analyzer :
2017-01-23 09:04:31 +00:00
strong-mode :
implicit-dynamic : false
2016-05-04 17:15:15 +00:00
errors :
2017-02-13 22:56:56 +00:00
# treat missing required parameters as a warning (not a hint)
missing_required_param : warning
2017-03-16 21:28:18 +00:00
# treat missing returns as a warning (not a hint)
2018-08-28 18:22:57 +00:00
missing_return : warning
2016-09-09 17:37:56 +00:00
# allow having TODOs in the code
2016-05-04 17:15:15 +00:00
todo : ignore
2019-01-03 18:55:50 +00:00
# Ignore analyzer hints for updating pubspecs when using Future or
# Stream and not importing dart:async
# Please see https://github.com/flutter/flutter/pull/24528 for details.
2018-12-27 22:55:07 +00:00
sdk_version_async_exported_from_core : ignore
2016-08-19 02:11:39 +00:00
exclude :
2016-11-07 22:47:53 +00:00
- 'bin/cache/**'
2017-01-23 00:43:24 +00:00
# the following two are relative to the stocks example and the flutter package respectively
# see https://github.com/dart-lang/sdk/issues/28463
- 'lib/i18n/stock_messages_*.dart'
- 'lib/src/http/**'
2016-05-20 21:08:46 +00:00
2016-05-04 17:15:15 +00:00
linter :
rules :
2016-09-09 17:37:56 +00:00
# these rules are documented on and in the same order as
# the Dart Lint rules page to make maintenance easier
2017-11-29 06:54:44 +00:00
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
2016-05-04 17:15:15 +00:00
- always_declare_return_types
2017-05-10 07:41:55 +00:00
- always_put_control_body_on_new_line
2017-08-31 06:55:21 +00:00
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
2017-05-10 06:45:36 +00:00
- always_require_non_null_named_parameters
2016-05-04 17:15:15 +00:00
- always_specify_types
- annotate_overrides
2017-10-19 06:33:01 +00:00
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
2016-05-04 17:15:15 +00:00
- avoid_as
2018-04-03 06:51:23 +00:00
# - avoid_bool_literals_in_conditional_expressions # not yet tested
2017-10-19 06:33:01 +00:00
# - avoid_catches_without_on_clauses # we do this commonly
# - avoid_catching_errors # we do this commonly
2017-11-09 06:12:36 +00:00
- avoid_classes_with_only_static_members
2018-05-31 15:49:28 +00:00
# - avoid_double_and_int_checks # only useful when targeting JS runtime
2017-11-29 06:54:44 +00:00
- avoid_empty_else
2018-06-13 05:20:18 +00:00
- avoid_field_initializers_in_const_classes
2017-10-19 06:16:16 +00:00
- avoid_function_literals_in_foreach_calls
2018-11-19 09:37:55 +00:00
# - avoid_implementing_value_types # not yet tested
2016-05-04 17:15:15 +00:00
- avoid_init_to_null
2018-05-31 15:49:28 +00:00
# - avoid_js_rounded_ints # only useful when targeting JS runtime
2017-05-15 06:41:17 +00:00
- avoid_null_checks_in_equality_operators
2017-05-10 06:20:13 +00:00
# - avoid_positional_boolean_parameters # not yet tested
2018-04-16 20:43:47 +00:00
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
2018-03-22 06:56:18 +00:00
- avoid_relative_lib_imports
2018-04-03 06:51:23 +00:00
- avoid_renaming_method_parameters
2016-05-20 21:08:46 +00:00
- avoid_return_types_on_setters
2018-08-18 23:44:39 +00:00
# - avoid_returning_null # there are plenty of valid reasons to return null
2019-01-06 20:07:41 +00:00
# - avoid_returning_null_for_future # not yet tested
2018-11-19 09:37:55 +00:00
- avoid_returning_null_for_void
2018-08-18 23:44:39 +00:00
# - avoid_returning_this # there are plenty of valid reasons to return this
2017-05-10 06:20:13 +00:00
# - avoid_setters_without_getters # not yet tested
2019-01-06 20:07:41 +00:00
# - avoid_shadowing_type_parameters # not yet tested
2018-04-03 06:51:23 +00:00
# - avoid_single_cascade_in_expression_statements # not yet tested
2017-11-29 06:54:44 +00:00
- avoid_slow_async_io
2018-08-18 23:44:39 +00:00
- avoid_types_as_parameter_names
2017-11-10 06:49:44 +00:00
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
2018-08-18 23:44:39 +00:00
- avoid_unused_constructor_parameters
2018-09-11 05:14:04 +00:00
- avoid_void_async
2016-05-20 21:08:46 +00:00
- await_only_futures
2016-05-04 17:15:15 +00:00
- camel_case_types
2017-11-29 06:54:44 +00:00
- cancel_subscriptions
2017-04-20 07:38:57 +00:00
# - cascade_invocations # not yet tested
2018-08-18 23:44:39 +00:00
# - close_sinks # not reliable enough
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
2017-11-29 06:54:44 +00:00
- control_flow_in_finally
2018-09-10 08:27:01 +00:00
# - curly_braces_in_flow_control_structures # not yet tested
2017-04-08 06:43:19 +00:00
- directives_ordering
2017-04-05 18:28:33 +00:00
- empty_catches
2016-05-04 17:15:15 +00:00
- empty_constructor_bodies
2017-11-29 06:54:44 +00:00
- empty_statements
2018-09-10 08:27:01 +00:00
# - file_names # not yet tested
2018-11-19 09:37:55 +00:00
- flutter_style_todos
2017-11-29 06:54:44 +00:00
- hash_and_equals
2016-05-20 21:08:46 +00:00
- implementation_imports
2018-08-18 23:44:39 +00:00
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
2017-11-29 06:54:44 +00:00
- iterable_contains_unrelated_type
2017-05-10 06:20:13 +00:00
# - join_return_with_assignment # not yet tested
2016-05-04 17:15:15 +00:00
- library_names
- library_prefixes
2018-09-10 08:27:01 +00:00
# - lines_longer_than_80_chars # not yet tested
2017-11-29 06:54:44 +00:00
- list_remove_unrelated_type
2018-08-18 23:44:39 +00:00
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
2017-11-29 06:54:44 +00:00
- no_adjacent_strings_in_list
- no_duplicate_case_values
2016-05-04 17:15:15 +00:00
- non_constant_identifier_names
2018-09-10 08:27:01 +00:00
# - null_closures # not yet tested
2017-04-20 07:38:57 +00:00
# - omit_local_variable_types # opposite of always_specify_types
2017-04-05 18:28:33 +00:00
# - one_member_abstracts # too many false positives
2016-09-09 19:18:18 +00:00
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
2017-04-22 08:27:03 +00:00
- overridden_fields
2016-05-04 17:15:15 +00:00
- package_api_docs
2017-11-29 06:54:44 +00:00
- package_names
2016-05-04 17:15:15 +00:00
- package_prefixed_library_names
2017-04-05 18:28:33 +00:00
# - parameter_assignments # we do this commonly
2017-04-21 06:52:07 +00:00
- prefer_adjacent_string_concatenation
2017-11-08 21:59:49 +00:00
- prefer_asserts_in_initializer_lists
2017-04-08 06:43:19 +00:00
- prefer_collection_literals
2017-10-25 06:18:26 +00:00
- prefer_conditional_assignment
2017-08-31 06:55:21 +00:00
- prefer_const_constructors
2017-10-25 09:20:36 +00:00
- prefer_const_constructors_in_immutables
2018-03-09 22:37:06 +00:00
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
2017-05-10 06:20:13 +00:00
# - prefer_constructors_over_static_methods # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_contains
2018-06-05 06:50:40 +00:00
- prefer_equal_for_default_values
2017-04-21 21:10:37 +00:00
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
2017-09-01 20:18:51 +00:00
- prefer_final_fields
2017-03-04 02:47:00 +00:00
- prefer_final_locals
2017-10-25 06:25:44 +00:00
- prefer_foreach
2017-04-20 07:38:57 +00:00
# - prefer_function_declarations_over_variables # not yet tested
2018-09-14 19:06:19 +00:00
- prefer_generic_function_type_aliases
2017-04-08 06:43:19 +00:00
- prefer_initializing_formals
2018-11-19 09:37:55 +00:00
# - prefer_int_literals # not yet tested
2017-04-20 07:38:57 +00:00
# - prefer_interpolation_to_compose_strings # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_is_empty
2016-05-04 17:15:15 +00:00
- prefer_is_not_empty
2018-09-10 08:27:01 +00:00
- prefer_iterable_whereType
2018-10-17 20:10:05 +00:00
# - prefer_mixin # https://github.com/dart-lang/language/issues/32
2017-10-22 16:11:36 +00:00
- prefer_single_quotes
2017-11-29 06:54:44 +00:00
- prefer_typing_uninitialized_variables
2018-10-17 06:09:29 +00:00
- prefer_void_to_null
2018-08-20 19:51:07 +00:00
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
2017-09-01 20:18:51 +00:00
- recursive_getters
2016-05-04 17:15:15 +00:00
- slash_for_doc_comments
- sort_constructors_first
2018-11-19 09:37:55 +00:00
- sort_pub_dependencies
2016-05-04 17:15:15 +00:00
- sort_unnamed_constructors_first
- super_goes_last
2017-11-29 06:54:44 +00:00
- test_types_in_equals
- throw_in_finally
2016-05-20 21:08:46 +00:00
# - type_annotate_public_apis # subset of always_specify_types
2016-05-04 17:15:15 +00:00
- type_init_formals
2018-08-18 23:44:39 +00:00
# - unawaited_futures # too many false positives
2019-01-06 20:07:41 +00:00
# - unnecessary_await_in_return # not yet tested
2017-04-20 07:38:57 +00:00
- unnecessary_brace_in_string_interps
2018-08-02 10:02:32 +00:00
- unnecessary_const
2016-05-04 17:15:15 +00:00
- unnecessary_getters_setters
2018-08-18 23:44:39 +00:00
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
2018-09-12 06:29:29 +00:00
- unnecessary_new
2017-04-08 06:43:19 +00:00
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
2017-09-01 20:18:51 +00:00
- unnecessary_overrides
2018-03-21 06:10:14 +00:00
- unnecessary_parenthesis
2018-08-06 23:31:57 +00:00
- unnecessary_statements
2017-04-20 07:38:57 +00:00
- unnecessary_this
2017-11-29 06:54:44 +00:00
- unrelated_type_equality_checks
2019-01-06 20:07:41 +00:00
# - use_function_type_syntax_for_parameters # not yet tested
2017-05-13 13:16:30 +00:00
- use_rethrow_when_possible
2017-05-10 06:20:13 +00:00
# - use_setters_to_change_properties # not yet tested
2018-08-18 23:44:39 +00:00
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
2017-05-15 07:44:39 +00:00
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
2017-11-29 06:54:44 +00:00
- valid_regexps
2018-05-31 06:33:13 +00:00
# - void_checks # not yet tested