blob: e83d88044a68e336510b8879297200ac3cec3dbf [file] [log] [blame]
Dan Rubel3ed33902016-09-07 22:41:59 -04001# 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#
Dan Rubelea74e072017-02-13 16:39:35 -050010# There are three similar analysis options files in the flutter repo:
Dan Rubel3a31c352017-08-15 08:46:42 -040011# - analysis_options.yaml
12# - analysis_options_repo.yaml (this file)
Dan Rubelea74e072017-02-13 16:39:35 -050013# - packages/flutter/lib/analysis_options_user.yaml
14#
Dan Rubel57843852016-09-09 13:37:56 -040015# This file contains the analysis options used by 'flutter analyze' when analyzing
Dan Rubel3a31c352017-08-15 08:46:42 -040016# the flutter repository. It is very similar to analysis_options.yaml;
Dan Rubel3ed33902016-09-07 22:41:59 -040017# the only difference (currently) is the public_member_api_docs option,
18# which is turned on and programmatically reduced to a single output line
19# indicating the # of violations for that rule.
20
21analyzer:
22 language:
23 enableStrictCallChecks: true
24 enableSuperMixins: true
Ian Hickson63aa1392017-01-23 01:04:31 -080025 strong-mode:
26 implicit-dynamic: false
Dan Rubel3ed33902016-09-07 22:41:59 -040027 errors:
Phil Quitslund39f7d582017-02-13 14:56:56 -080028 # treat missing required parameters as a warning (not a hint)
29 missing_required_param: warning
Phil Quitslund41d99682017-03-16 14:28:18 -070030 # treat missing returns as a warning (not a hint)
Ian Hicksona52c7b42017-04-05 11:28:33 -070031 missing_return: warning
Dan Rubel57843852016-09-09 13:37:56 -040032 # allow having TODOs in the code
Dan Rubel3ed33902016-09-07 22:41:59 -040033 todo: ignore
Ian Hicksoncbda2082017-01-22 16:43:24 -080034 # `flutter analyze` (without `--watch`) just ignores directories
35 # that contain a .dartignore file, and this file does not have any
36 # effect on what files are actually analyzed.
Dan Rubel3ed33902016-09-07 22:41:59 -040037
38linter:
39 rules:
Dan Rubel57843852016-09-09 13:37:56 -040040 # these rules are documented on and in the same order as
41 # the Dart Lint rules page to make maintenance easier
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010042 # https://github.com/dart-lang/linter/blob/master/example/all.yaml
Dan Rubel3ed33902016-09-07 22:41:59 -040043 - always_declare_return_types
Alexandre Ardhuin9b56c1c2017-05-10 09:41:55 +020044 - always_put_control_body_on_new_line
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +020045 # - 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 +020046 - always_require_non_null_named_parameters
Dan Rubel3ed33902016-09-07 22:41:59 -040047 - always_specify_types
48 - annotate_overrides
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020049 # - avoid_annotating_with_dynamic # conflicts with always_specify_types
Dan Rubel3ed33902016-09-07 22:41:59 -040050 - avoid_as
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020051 # - avoid_catches_without_on_clauses # we do this commonly
52 # - avoid_catching_errors # we do this commonly
Alexandre Ardhuin436aa932017-11-09 07:12:36 +010053 - avoid_classes_with_only_static_members
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010054 - avoid_empty_else
Alexandre Ardhuin700dc9f2017-10-19 08:16:16 +020055 - avoid_function_literals_in_foreach_calls
Dan Rubel3ed33902016-09-07 22:41:59 -040056 - avoid_init_to_null
Alexandre Ardhuinf7502c82017-05-15 08:41:17 +020057 - avoid_null_checks_in_equality_operators
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020058 # - avoid_positional_boolean_parameters # not yet tested
Alexandre Ardhuin217b2bd2018-03-21 07:10:14 +010059 # - avoid_relative_lib_imports # not yet tested
Dan Rubel3ed33902016-09-07 22:41:59 -040060 - avoid_return_types_on_setters
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010061 # - avoid_returning_null # we do this commonly
62 # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020063 # - avoid_setters_without_getters # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010064 - avoid_slow_async_io
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010065 # - avoid_types_on_closure_parameters # conflicts with always_specify_types
Alexandre Ardhuinc3588982017-11-30 09:20:53 +010066 # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
Dan Rubel3ed33902016-09-07 22:41:59 -040067 - await_only_futures
68 - camel_case_types
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010069 - cancel_subscriptions
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020070 # - cascade_invocations # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010071 # - close_sinks # https://github.com/flutter/flutter/issues/5789
72 # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
Dan Rubel57843852016-09-09 13:37:56 -040073 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010074 - control_flow_in_finally
Alexandre Ardhuin610955f2017-04-08 08:43:19 +020075 - directives_ordering
Ian Hicksona52c7b42017-04-05 11:28:33 -070076 - empty_catches
Dan Rubel3ed33902016-09-07 22:41:59 -040077 - empty_constructor_bodies
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010078 - empty_statements
79 - hash_and_equals
Dan Rubel3ed33902016-09-07 22:41:59 -040080 - implementation_imports
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010081 # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
82 - iterable_contains_unrelated_type
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020083 # - join_return_with_assignment # not yet tested
Dan Rubel3ed33902016-09-07 22:41:59 -040084 - library_names
85 - library_prefixes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010086 - list_remove_unrelated_type
87 # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
88 - no_adjacent_strings_in_list
89 - no_duplicate_case_values
Dan Rubel3ed33902016-09-07 22:41:59 -040090 - non_constant_identifier_names
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020091 # - omit_local_variable_types # opposite of always_specify_types
Ian Hicksona52c7b42017-04-05 11:28:33 -070092 # - one_member_abstracts # too many false positives
Dan Rubel7cf47ca2016-09-09 15:18:18 -040093 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
Alexandre Ardhuinad496e12017-04-22 10:27:03 +020094 - overridden_fields
Dan Rubel3ed33902016-09-07 22:41:59 -040095 - package_api_docs
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010096 - package_names
Dan Rubel3ed33902016-09-07 22:41:59 -040097 - package_prefixed_library_names
Ian Hicksona52c7b42017-04-05 11:28:33 -070098 # - parameter_assignments # we do this commonly
Alexandre Ardhuinc7942212017-04-21 08:52:07 +020099 - prefer_adjacent_string_concatenation
Alexandre Ardhuin15601fe2017-11-08 22:59:49 +0100100 - prefer_asserts_in_initializer_lists
Alexandre Ardhuinb8fcc962018-02-15 06:14:13 +0100101 - prefer_bool_in_asserts
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200102 - prefer_collection_literals
Alexandre Ardhuin872d83a2017-10-25 08:18:26 +0200103 - prefer_conditional_assignment
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +0200104 - prefer_const_constructors
Alexandre Ardhuinc9b94e12017-10-25 11:20:36 +0200105 - prefer_const_constructors_in_immutables
Alexandre Ardhuin39613062018-03-09 23:37:06 +0100106 - prefer_const_declarations
107 - prefer_const_literals_to_create_immutables
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200108 # - prefer_constructors_over_static_methods # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200109 - prefer_contains
Alexandre Ardhuin10099db2017-04-21 23:10:37 +0200110 # - 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 +0200111 - prefer_final_fields
Chris Brackenca0201d2017-03-03 18:47:00 -0800112 - prefer_final_locals
Alexandre Ardhuin28366002017-10-25 08:25:44 +0200113 - prefer_foreach
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200114 # - prefer_function_declarations_over_variables # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200115 - prefer_initializing_formals
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200116 # - prefer_interpolation_to_compose_strings # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200117 - prefer_is_empty
Dan Rubel3ed33902016-09-07 22:41:59 -0400118 - prefer_is_not_empty
Alexandre Ardhuin1fce14a2017-10-22 18:11:36 +0200119 - prefer_single_quotes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100120 - prefer_typing_uninitialized_variables
121 - public_member_api_docs # this is the only difference from analysis_options.yaml
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200122 - recursive_getters
Dan Rubel3ed33902016-09-07 22:41:59 -0400123 - slash_for_doc_comments
124 - sort_constructors_first
125 - sort_unnamed_constructors_first
126 - super_goes_last
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100127 - test_types_in_equals
128 - throw_in_finally
Dan Rubel3ed33902016-09-07 22:41:59 -0400129 # - type_annotate_public_apis # subset of always_specify_types
130 - type_init_formals
Dan Rubel7cf47ca2016-09-09 15:18:18 -0400131 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200132 - unnecessary_brace_in_string_interps
Dan Rubel3ed33902016-09-07 22:41:59 -0400133 - unnecessary_getters_setters
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200134 # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200135 - unnecessary_null_aware_assignments
136 - unnecessary_null_in_if_null_operators
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200137 - unnecessary_overrides
Alexandre Ardhuin217b2bd2018-03-21 07:10:14 +0100138 - unnecessary_parenthesis
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100139 # - unnecessary_statements # not yet tested
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200140 - unnecessary_this
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100141 - unrelated_type_equality_checks
Alexandre Ardhuin26eedb82017-05-13 15:16:30 +0200142 - use_rethrow_when_possible
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200143 # - use_setters_to_change_properties # not yet tested
Alexandre Ardhuin5bce52d2017-05-12 19:00:55 +0200144 # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
Alexandre Ardhuin45cef3c2017-05-15 09:44:39 +0200145 # - 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 +0100146 - valid_regexps