blob: c64e20a9b8e492f527e58c5af78b1ee1e79dfd17 [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#
Michael Goderbauer435c25b2017-06-08 17:17:48 -070010# There are four similar analysis options files in the flutter repos:
Dan Rubel3a31c352017-08-15 08:46:42 -040011# - analysis_options.yaml (this file)
12# - analysis_options_repo.yaml
Dan Rubelea74e072017-02-13 16:39:35 -050013# - packages/flutter/lib/analysis_options_user.yaml
Dan Rubel3a31c352017-08-15 08:46:42 -040014# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
Dan Rubelea74e072017-02-13 16:39:35 -050015#
Michael Thomsen5ecbc922017-11-23 09:17:29 +010016# This file contains the analysis options used by Flutter tools, such as IntelliJ,
17# Android Studio, and the `flutter analyze` command.
Dan Rubel3a31c352017-08-15 08:46:42 -040018# It is very similar to the analysis_options_repo.yaml file in this same directory;
Dan Rubel3ed33902016-09-07 22:41:59 -040019# the only difference (currently) is the public_member_api_docs option,
20# which triggers too many messages to be used in editors.
Michael Goderbauer435c25b2017-06-08 17:17:48 -070021#
22# The flutter/plugins repo contains a copy of this file, which should be kept
23# in sync with this file.
krisgiesing07b5f832016-05-04 10:15:15 -070024
25analyzer:
26 language:
27 enableStrictCallChecks: true
28 enableSuperMixins: true
Ian Hickson63aa1392017-01-23 01:04:31 -080029 strong-mode:
30 implicit-dynamic: false
krisgiesing07b5f832016-05-04 10:15:15 -070031 errors:
Phil Quitslund39f7d582017-02-13 14:56:56 -080032 # treat missing required parameters as a warning (not a hint)
33 missing_required_param: warning
Phil Quitslund41d99682017-03-16 14:28:18 -070034 # treat missing returns as a warning (not a hint)
35 missing_return: warning
Dan Rubel57843852016-09-09 13:37:56 -040036 # allow having TODOs in the code
krisgiesing07b5f832016-05-04 10:15:15 -070037 todo: ignore
Devon Carew207451f2016-08-18 19:11:39 -070038 exclude:
Devon Carewf1b35232016-11-07 14:47:53 -080039 - 'bin/cache/**'
Ian Hicksoncbda2082017-01-22 16:43:24 -080040 # the following two are relative to the stocks example and the flutter package respectively
41 # see https://github.com/dart-lang/sdk/issues/28463
42 - 'lib/i18n/stock_messages_*.dart'
43 - 'lib/src/http/**'
Ian Hickson94636bd2016-05-20 14:08:46 -070044
krisgiesing07b5f832016-05-04 10:15:15 -070045linter:
46 rules:
Dan Rubel57843852016-09-09 13:37:56 -040047 # these rules are documented on and in the same order as
48 # the Dart Lint rules page to make maintenance easier
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010049 # https://github.com/dart-lang/linter/blob/master/example/all.yaml
krisgiesing07b5f832016-05-04 10:15:15 -070050 - always_declare_return_types
Alexandre Ardhuin9b56c1c2017-05-10 09:41:55 +020051 - always_put_control_body_on_new_line
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +020052 # - 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 +020053 - always_require_non_null_named_parameters
krisgiesing07b5f832016-05-04 10:15:15 -070054 - always_specify_types
55 - annotate_overrides
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020056 # - avoid_annotating_with_dynamic # conflicts with always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -070057 - avoid_as
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020058 # - avoid_catches_without_on_clauses # we do this commonly
59 # - avoid_catching_errors # we do this commonly
Alexandre Ardhuin436aa932017-11-09 07:12:36 +010060 - avoid_classes_with_only_static_members
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010061 - avoid_empty_else
Alexandre Ardhuin700dc9f2017-10-19 08:16:16 +020062 - avoid_function_literals_in_foreach_calls
krisgiesing07b5f832016-05-04 10:15:15 -070063 - avoid_init_to_null
Alexandre Ardhuinf7502c82017-05-15 08:41:17 +020064 - avoid_null_checks_in_equality_operators
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020065 # - avoid_positional_boolean_parameters # not yet tested
Alexandre Ardhuin06135292018-03-22 07:56:18 +010066 - avoid_relative_lib_imports
Ian Hickson94636bd2016-05-20 14:08:46 -070067 - avoid_return_types_on_setters
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010068 # - avoid_returning_null # we do this commonly
69 # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020070 # - avoid_setters_without_getters # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010071 - avoid_slow_async_io
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010072 # - avoid_types_on_closure_parameters # conflicts with always_specify_types
Alexandre Ardhuinc3588982017-11-30 09:20:53 +010073 # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
Ian Hickson94636bd2016-05-20 14:08:46 -070074 - await_only_futures
krisgiesing07b5f832016-05-04 10:15:15 -070075 - camel_case_types
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010076 - cancel_subscriptions
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020077 # - cascade_invocations # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010078 # - close_sinks # https://github.com/flutter/flutter/issues/5789
79 # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
Dan Rubel57843852016-09-09 13:37:56 -040080 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010081 - control_flow_in_finally
Alexandre Ardhuin610955f2017-04-08 08:43:19 +020082 - directives_ordering
Ian Hicksona52c7b42017-04-05 11:28:33 -070083 - empty_catches
krisgiesing07b5f832016-05-04 10:15:15 -070084 - empty_constructor_bodies
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010085 - empty_statements
86 - hash_and_equals
Ian Hickson94636bd2016-05-20 14:08:46 -070087 - implementation_imports
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010088 # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
89 - iterable_contains_unrelated_type
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020090 # - join_return_with_assignment # not yet tested
krisgiesing07b5f832016-05-04 10:15:15 -070091 - library_names
92 - library_prefixes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010093 - list_remove_unrelated_type
94 # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
95 - no_adjacent_strings_in_list
96 - no_duplicate_case_values
krisgiesing07b5f832016-05-04 10:15:15 -070097 - non_constant_identifier_names
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020098 # - omit_local_variable_types # opposite of always_specify_types
Ian Hicksona52c7b42017-04-05 11:28:33 -070099 # - one_member_abstracts # too many false positives
Dan Rubel7cf47ca2016-09-09 15:18:18 -0400100 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
Alexandre Ardhuinad496e12017-04-22 10:27:03 +0200101 - overridden_fields
krisgiesing07b5f832016-05-04 10:15:15 -0700102 - package_api_docs
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100103 - package_names
krisgiesing07b5f832016-05-04 10:15:15 -0700104 - package_prefixed_library_names
Ian Hicksona52c7b42017-04-05 11:28:33 -0700105 # - parameter_assignments # we do this commonly
Alexandre Ardhuinc7942212017-04-21 08:52:07 +0200106 - prefer_adjacent_string_concatenation
Alexandre Ardhuin15601fe2017-11-08 22:59:49 +0100107 - prefer_asserts_in_initializer_lists
Alexandre Ardhuinb8fcc962018-02-15 06:14:13 +0100108 - prefer_bool_in_asserts
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200109 - prefer_collection_literals
Alexandre Ardhuin872d83a2017-10-25 08:18:26 +0200110 - prefer_conditional_assignment
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +0200111 - prefer_const_constructors
Alexandre Ardhuinc9b94e12017-10-25 11:20:36 +0200112 - prefer_const_constructors_in_immutables
Alexandre Ardhuin39613062018-03-09 23:37:06 +0100113 - prefer_const_declarations
114 - prefer_const_literals_to_create_immutables
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200115 # - prefer_constructors_over_static_methods # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200116 - prefer_contains
Alexandre Ardhuin10099db2017-04-21 23:10:37 +0200117 # - 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 +0200118 - prefer_final_fields
Chris Brackenca0201d2017-03-03 18:47:00 -0800119 - prefer_final_locals
Alexandre Ardhuin28366002017-10-25 08:25:44 +0200120 - prefer_foreach
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200121 # - prefer_function_declarations_over_variables # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200122 - prefer_initializing_formals
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200123 # - prefer_interpolation_to_compose_strings # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200124 - prefer_is_empty
krisgiesing07b5f832016-05-04 10:15:15 -0700125 - prefer_is_not_empty
Alexandre Ardhuin1fce14a2017-10-22 18:11:36 +0200126 - prefer_single_quotes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100127 - prefer_typing_uninitialized_variables
Dan Rubel3a31c352017-08-15 08:46:42 -0400128 # - public_member_api_docs # this is the only difference from analysis_options_repo.yaml
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200129 - recursive_getters
krisgiesing07b5f832016-05-04 10:15:15 -0700130 - slash_for_doc_comments
131 - sort_constructors_first
132 - sort_unnamed_constructors_first
133 - super_goes_last
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100134 - test_types_in_equals
135 - throw_in_finally
Ian Hickson94636bd2016-05-20 14:08:46 -0700136 # - type_annotate_public_apis # subset of always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -0700137 - type_init_formals
Ian Hicksona52c7b42017-04-05 11:28:33 -0700138 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200139 - unnecessary_brace_in_string_interps
krisgiesing07b5f832016-05-04 10:15:15 -0700140 - unnecessary_getters_setters
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200141 # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200142 - unnecessary_null_aware_assignments
143 - unnecessary_null_in_if_null_operators
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200144 - unnecessary_overrides
Alexandre Ardhuin217b2bd2018-03-21 07:10:14 +0100145 - unnecessary_parenthesis
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100146 # - unnecessary_statements # not yet tested
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200147 - unnecessary_this
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100148 - unrelated_type_equality_checks
Alexandre Ardhuin26eedb82017-05-13 15:16:30 +0200149 - use_rethrow_when_possible
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200150 # - use_setters_to_change_properties # not yet tested
Alexandre Ardhuin5bce52d2017-05-12 19:00:55 +0200151 # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
Alexandre Ardhuin45cef3c2017-05-15 09:44:39 +0200152 # - 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 +0100153 - valid_regexps