blob: ba000aac35a4a7a44b26bc8d85df438d2adac28d [file] [log] [blame]
krisgiesing07b5f832016-05-04 10:15:15 -07001# Specify analysis options.
Dan Rubel57843852016-09-09 13:37:56 -04002#
3# Until there are meta linter rules, each desired lint must be explicitly enabled.
4# See: https://github.com/dart-lang/linter/issues/288
5#
6# For a list of lints, see: http://dart-lang.github.io/linter/lints/
7# See the configuration guide for more
8# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
9#
Ian Hicksonad1eaff2018-08-20 12:51:07 -070010# There are other similar analysis options files in the flutter repos,
11# which should be kept in sync with this file:
12#
Dan Rubel3a31c352017-08-15 08:46:42 -040013# - analysis_options.yaml (this file)
Dan Rubelea74e072017-02-13 16:39:35 -050014# - packages/flutter/lib/analysis_options_user.yaml
Dan Rubel3a31c352017-08-15 08:46:42 -040015# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
Devon Carew09dec7f2018-05-10 09:48:40 -070016# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
Dan Rubelea74e072017-02-13 16:39:35 -050017#
Chris Bracken2ae48842018-06-13 12:46:39 -070018# This file contains the analysis options used by Flutter tools, such as IntelliJ,
19# Android Studio, and the `flutter analyze` command.
krisgiesing07b5f832016-05-04 10:15:15 -070020
21analyzer:
Ian Hickson63aa1392017-01-23 01:04:31 -080022 strong-mode:
23 implicit-dynamic: false
krisgiesing07b5f832016-05-04 10:15:15 -070024 errors:
Phil Quitslund39f7d582017-02-13 14:56:56 -080025 # treat missing required parameters as a warning (not a hint)
26 missing_required_param: warning
Phil Quitslund41d99682017-03-16 14:28:18 -070027 # treat missing returns as a warning (not a hint)
Ian Hickson53b63582018-08-28 11:22:57 -070028 missing_return: warning
Dan Rubel57843852016-09-09 13:37:56 -040029 # allow having TODOs in the code
krisgiesing07b5f832016-05-04 10:15:15 -070030 todo: ignore
Sivab1109222019-01-03 10:55:50 -080031 # Ignore analyzer hints for updating pubspecs when using Future or
32 # Stream and not importing dart:async
33 # Please see https://github.com/flutter/flutter/pull/24528 for details.
Alexander Aprelevfe1a51a2018-12-27 14:55:07 -080034 sdk_version_async_exported_from_core: ignore
Devon Carew207451f2016-08-18 19:11:39 -070035 exclude:
Devon Carewf1b35232016-11-07 14:47:53 -080036 - 'bin/cache/**'
Ian Hicksoncbda2082017-01-22 16:43:24 -080037 # the following two are relative to the stocks example and the flutter package respectively
38 # see https://github.com/dart-lang/sdk/issues/28463
39 - 'lib/i18n/stock_messages_*.dart'
40 - 'lib/src/http/**'
Ian Hickson94636bd2016-05-20 14:08:46 -070041
krisgiesing07b5f832016-05-04 10:15:15 -070042linter:
43 rules:
Dan Rubel57843852016-09-09 13:37:56 -040044 # these rules are documented on and in the same order as
45 # the Dart Lint rules page to make maintenance easier
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010046 # https://github.com/dart-lang/linter/blob/master/example/all.yaml
krisgiesing07b5f832016-05-04 10:15:15 -070047 - always_declare_return_types
Alexandre Ardhuin9b56c1c2017-05-10 09:41:55 +020048 - always_put_control_body_on_new_line
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +020049 # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
Alexandre Ardhuine4546582017-05-10 08:45:36 +020050 - always_require_non_null_named_parameters
krisgiesing07b5f832016-05-04 10:15:15 -070051 - always_specify_types
52 - annotate_overrides
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020053 # - avoid_annotating_with_dynamic # conflicts with always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -070054 - avoid_as
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020055 # - avoid_bool_literals_in_conditional_expressions # not yet tested
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020056 # - avoid_catches_without_on_clauses # we do this commonly
57 # - avoid_catching_errors # we do this commonly
Alexandre Ardhuin436aa932017-11-09 07:12:36 +010058 - avoid_classes_with_only_static_members
Alexandre Ardhuin6e06fd22018-05-31 17:49:28 +020059 # - avoid_double_and_int_checks # only useful when targeting JS runtime
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010060 - avoid_empty_else
Alexandre Ardhuine45836f2018-06-13 07:20:18 +020061 - avoid_field_initializers_in_const_classes
Alexandre Ardhuin700dc9f2017-10-19 08:16:16 +020062 - avoid_function_literals_in_foreach_calls
Alexandre Ardhuin79b5e5b2018-11-19 10:37:55 +010063 # - avoid_implementing_value_types # not yet tested
krisgiesing07b5f832016-05-04 10:15:15 -070064 - avoid_init_to_null
Alexandre Ardhuin6e06fd22018-05-31 17:49:28 +020065 # - avoid_js_rounded_ints # only useful when targeting JS runtime
Alexandre Ardhuinf7502c82017-05-15 08:41:17 +020066 - avoid_null_checks_in_equality_operators
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020067 # - avoid_positional_boolean_parameters # not yet tested
Alexandre Ardhuinc103fd02018-04-16 22:43:47 +020068 # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
Alexandre Ardhuin06135292018-03-22 07:56:18 +010069 - avoid_relative_lib_imports
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020070 - avoid_renaming_method_parameters
Ian Hickson94636bd2016-05-20 14:08:46 -070071 - avoid_return_types_on_setters
Ian Hickson8c79f402018-08-18 16:44:39 -070072 # - avoid_returning_null # there are plenty of valid reasons to return null
Alexandre Ardhuin79b5e5b2018-11-19 10:37:55 +010073 - avoid_returning_null_for_void
Ian Hickson8c79f402018-08-18 16:44:39 -070074 # - avoid_returning_this # there are plenty of valid reasons to return this
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020075 # - avoid_setters_without_getters # not yet tested
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020076 # - avoid_single_cascade_in_expression_statements # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010077 - avoid_slow_async_io
Ian Hickson8c79f402018-08-18 16:44:39 -070078 - avoid_types_as_parameter_names
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010079 # - avoid_types_on_closure_parameters # conflicts with always_specify_types
Ian Hickson8c79f402018-08-18 16:44:39 -070080 - avoid_unused_constructor_parameters
Alexandre Ardhuin774ca2f2018-09-11 07:14:04 +020081 - avoid_void_async
Ian Hickson94636bd2016-05-20 14:08:46 -070082 - await_only_futures
krisgiesing07b5f832016-05-04 10:15:15 -070083 - camel_case_types
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010084 - cancel_subscriptions
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020085 # - cascade_invocations # not yet tested
Ian Hickson8c79f402018-08-18 16:44:39 -070086 # - close_sinks # not reliable enough
87 # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
88 # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010089 - control_flow_in_finally
Alexandre Ardhuinbd1e5a32018-09-10 10:27:01 +020090 # - curly_braces_in_flow_control_structures # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +020091 - directives_ordering
Ian Hicksona52c7b42017-04-05 11:28:33 -070092 - empty_catches
krisgiesing07b5f832016-05-04 10:15:15 -070093 - empty_constructor_bodies
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010094 - empty_statements
Alexandre Ardhuinbd1e5a32018-09-10 10:27:01 +020095 # - file_names # not yet tested
Alexandre Ardhuin79b5e5b2018-11-19 10:37:55 +010096 - flutter_style_todos
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010097 - hash_and_equals
Ian Hickson94636bd2016-05-20 14:08:46 -070098 - implementation_imports
Ian Hickson8c79f402018-08-18 16:44:39 -070099 # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100100 - iterable_contains_unrelated_type
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200101 # - join_return_with_assignment # not yet tested
krisgiesing07b5f832016-05-04 10:15:15 -0700102 - library_names
103 - library_prefixes
Alexandre Ardhuinbd1e5a32018-09-10 10:27:01 +0200104 # - lines_longer_than_80_chars # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100105 - list_remove_unrelated_type
Ian Hickson8c79f402018-08-18 16:44:39 -0700106 # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100107 - no_adjacent_strings_in_list
108 - no_duplicate_case_values
krisgiesing07b5f832016-05-04 10:15:15 -0700109 - non_constant_identifier_names
Alexandre Ardhuinbd1e5a32018-09-10 10:27:01 +0200110 # - null_closures # not yet tested
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200111 # - omit_local_variable_types # opposite of always_specify_types
Ian Hicksona52c7b42017-04-05 11:28:33 -0700112 # - one_member_abstracts # too many false positives
Dan Rubel7cf47ca2016-09-09 15:18:18 -0400113 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
Alexandre Ardhuinad496e12017-04-22 10:27:03 +0200114 - overridden_fields
krisgiesing07b5f832016-05-04 10:15:15 -0700115 - package_api_docs
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100116 - package_names
krisgiesing07b5f832016-05-04 10:15:15 -0700117 - package_prefixed_library_names
Ian Hicksona52c7b42017-04-05 11:28:33 -0700118 # - parameter_assignments # we do this commonly
Alexandre Ardhuinc7942212017-04-21 08:52:07 +0200119 - prefer_adjacent_string_concatenation
Alexandre Ardhuin15601fe2017-11-08 22:59:49 +0100120 - prefer_asserts_in_initializer_lists
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200121 - prefer_collection_literals
Alexandre Ardhuin872d83a2017-10-25 08:18:26 +0200122 - prefer_conditional_assignment
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +0200123 - prefer_const_constructors
Alexandre Ardhuinc9b94e12017-10-25 11:20:36 +0200124 - prefer_const_constructors_in_immutables
Alexandre Ardhuin39613062018-03-09 23:37:06 +0100125 - prefer_const_declarations
126 - prefer_const_literals_to_create_immutables
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200127 # - prefer_constructors_over_static_methods # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200128 - prefer_contains
Alexandre Ardhuin09276be2018-06-05 08:50:40 +0200129 - prefer_equal_for_default_values
Alexandre Ardhuin10099db2017-04-21 23:10:37 +0200130 # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200131 - prefer_final_fields
Chris Brackenca0201d2017-03-03 18:47:00 -0800132 - prefer_final_locals
Alexandre Ardhuin28366002017-10-25 08:25:44 +0200133 - prefer_foreach
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200134 # - prefer_function_declarations_over_variables # not yet tested
Alexandre Ardhuina07d3712018-09-14 21:06:19 +0200135 - prefer_generic_function_type_aliases
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200136 - prefer_initializing_formals
Alexandre Ardhuin79b5e5b2018-11-19 10:37:55 +0100137 # - prefer_int_literals # not yet tested
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200138 # - prefer_interpolation_to_compose_strings # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200139 - prefer_is_empty
krisgiesing07b5f832016-05-04 10:15:15 -0700140 - prefer_is_not_empty
Alexandre Ardhuinbd1e5a32018-09-10 10:27:01 +0200141 - prefer_iterable_whereType
Yegor3fbd1402018-10-17 13:10:05 -0700142 # - prefer_mixin # https://github.com/dart-lang/language/issues/32
Alexandre Ardhuin1fce14a2017-10-22 18:11:36 +0200143 - prefer_single_quotes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100144 - prefer_typing_uninitialized_variables
Alexandre Ardhuin936dea22018-10-17 08:09:29 +0200145 - prefer_void_to_null
Ian Hicksonad1eaff2018-08-20 12:51:07 -0700146 # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200147 - recursive_getters
krisgiesing07b5f832016-05-04 10:15:15 -0700148 - slash_for_doc_comments
149 - sort_constructors_first
Alexandre Ardhuin79b5e5b2018-11-19 10:37:55 +0100150 - sort_pub_dependencies
krisgiesing07b5f832016-05-04 10:15:15 -0700151 - sort_unnamed_constructors_first
152 - super_goes_last
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100153 - test_types_in_equals
154 - throw_in_finally
Ian Hickson94636bd2016-05-20 14:08:46 -0700155 # - type_annotate_public_apis # subset of always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -0700156 - type_init_formals
Ian Hickson8c79f402018-08-18 16:44:39 -0700157 # - unawaited_futures # too many false positives
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200158 - unnecessary_brace_in_string_interps
Alexandre Ardhuineda03e22018-08-02 12:02:32 +0200159 - unnecessary_const
krisgiesing07b5f832016-05-04 10:15:15 -0700160 - unnecessary_getters_setters
Ian Hickson8c79f402018-08-18 16:44:39 -0700161 # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
Alexandre Ardhuind927c932018-09-12 08:29:29 +0200162 - unnecessary_new
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200163 - unnecessary_null_aware_assignments
164 - unnecessary_null_in_if_null_operators
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200165 - unnecessary_overrides
Alexandre Ardhuin217b2bd2018-03-21 07:10:14 +0100166 - unnecessary_parenthesis
Michael R Fairhurste77b1862018-08-06 16:31:57 -0700167 - unnecessary_statements
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200168 - unnecessary_this
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100169 - unrelated_type_equality_checks
Alexandre Ardhuin26eedb82017-05-13 15:16:30 +0200170 - use_rethrow_when_possible
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200171 # - use_setters_to_change_properties # not yet tested
Ian Hickson8c79f402018-08-18 16:44:39 -0700172 # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
Alexandre Ardhuin45cef3c2017-05-15 09:44:39 +0200173 # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100174 - valid_regexps
Alexandre Ardhuinb7fd1d82018-05-31 08:33:13 +0200175 # - void_checks # not yet tested