blob: 58f49748900e40a7e6a5a7b349caf74bd22cfafb [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#
Greg Spencer6c56bb22018-06-11 15:51:45 -070010# There are four similar analysis options files in the flutter repo:
Dan Rubel3a31c352017-08-15 08:46:42 -040011# - analysis_options.yaml (this file)
Dan Rubelea74e072017-02-13 16:39:35 -050012# - packages/flutter/lib/analysis_options_user.yaml
Dan Rubel3a31c352017-08-15 08:46:42 -040013# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
Devon Carew09dec7f2018-05-10 09:48:40 -070014# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
Dan Rubelea74e072017-02-13 16:39:35 -050015#
Greg Spencer6c56bb22018-06-11 15:51:45 -070016# This file contains the analysis options used by Flutter tools, such as
17# IntelliJ, Android Studio, and the 'flutter analyze' command.
Michael Goderbauer435c25b2017-06-08 17:17:48 -070018#
Greg Spencer6c56bb22018-06-11 15:51:45 -070019# The flutter/plugins and flutter/engine repos contain a copy of this file,
20# which should be kept in sync with this file.
krisgiesing07b5f832016-05-04 10:15:15 -070021
22analyzer:
23 language:
krisgiesing07b5f832016-05-04 10:15:15 -070024 enableSuperMixins: true
Ian Hickson63aa1392017-01-23 01:04:31 -080025 strong-mode:
26 implicit-dynamic: false
krisgiesing07b5f832016-05-04 10:15:15 -070027 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)
31 missing_return: warning
Dan Rubel57843852016-09-09 13:37:56 -040032 # allow having TODOs in the code
krisgiesing07b5f832016-05-04 10:15:15 -070033 todo: ignore
Devon Carew207451f2016-08-18 19:11:39 -070034 exclude:
Devon Carewf1b35232016-11-07 14:47:53 -080035 - 'bin/cache/**'
Ian Hicksoncbda2082017-01-22 16:43:24 -080036 # the following two are relative to the stocks example and the flutter package respectively
37 # see https://github.com/dart-lang/sdk/issues/28463
38 - 'lib/i18n/stock_messages_*.dart'
39 - 'lib/src/http/**'
Ian Hickson94636bd2016-05-20 14:08:46 -070040
krisgiesing07b5f832016-05-04 10:15:15 -070041linter:
42 rules:
Dan Rubel57843852016-09-09 13:37:56 -040043 # these rules are documented on and in the same order as
44 # the Dart Lint rules page to make maintenance easier
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010045 # https://github.com/dart-lang/linter/blob/master/example/all.yaml
krisgiesing07b5f832016-05-04 10:15:15 -070046 - always_declare_return_types
Alexandre Ardhuin9b56c1c2017-05-10 09:41:55 +020047 - always_put_control_body_on_new_line
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +020048 # - 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 +020049 - always_require_non_null_named_parameters
krisgiesing07b5f832016-05-04 10:15:15 -070050 - always_specify_types
51 - annotate_overrides
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020052 # - avoid_annotating_with_dynamic # conflicts with always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -070053 - avoid_as
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020054 # - avoid_bool_literals_in_conditional_expressions # not yet tested
Alexandre Ardhuince6f8d32017-10-19 08:33:01 +020055 # - avoid_catches_without_on_clauses # we do this commonly
56 # - avoid_catching_errors # we do this commonly
Alexandre Ardhuin436aa932017-11-09 07:12:36 +010057 - avoid_classes_with_only_static_members
Alexandre Ardhuin6e06fd22018-05-31 17:49:28 +020058 # - avoid_double_and_int_checks # only useful when targeting JS runtime
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010059 - avoid_empty_else
Alexandre Ardhuine45836f2018-06-13 07:20:18 +020060 - avoid_field_initializers_in_const_classes
Alexandre Ardhuin700dc9f2017-10-19 08:16:16 +020061 - avoid_function_literals_in_foreach_calls
krisgiesing07b5f832016-05-04 10:15:15 -070062 - avoid_init_to_null
Alexandre Ardhuin6e06fd22018-05-31 17:49:28 +020063 # - avoid_js_rounded_ints # only useful when targeting JS runtime
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 Ardhuinc103fd02018-04-16 22:43:47 +020066 # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
Alexandre Ardhuin06135292018-03-22 07:56:18 +010067 - avoid_relative_lib_imports
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020068 - avoid_renaming_method_parameters
Ian Hickson94636bd2016-05-20 14:08:46 -070069 - avoid_return_types_on_setters
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010070 # - avoid_returning_null # we do this commonly
71 # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020072 # - avoid_setters_without_getters # not yet tested
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020073 # - avoid_single_cascade_in_expression_statements # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010074 - avoid_slow_async_io
Alexandre Ardhuinf8998092018-04-03 08:51:23 +020075 # - avoid_types_as_parameter_names # https://github.com/dart-lang/linter/pull/954/files
Alexandre Ardhuinaefc62f2017-11-10 07:49:44 +010076 # - avoid_types_on_closure_parameters # conflicts with always_specify_types
Alexandre Ardhuinc3588982017-11-30 09:20:53 +010077 # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
Ian Hickson94636bd2016-05-20 14:08:46 -070078 - await_only_futures
krisgiesing07b5f832016-05-04 10:15:15 -070079 - camel_case_types
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010080 - cancel_subscriptions
Alexandre Ardhuin35803c22017-04-20 09:38:57 +020081 # - cascade_invocations # not yet tested
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010082 # - close_sinks # https://github.com/flutter/flutter/issues/5789
83 # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
Dan Rubel57843852016-09-09 13:37:56 -040084 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010085 - control_flow_in_finally
Alexandre Ardhuin610955f2017-04-08 08:43:19 +020086 - directives_ordering
Ian Hicksona52c7b42017-04-05 11:28:33 -070087 - empty_catches
krisgiesing07b5f832016-05-04 10:15:15 -070088 - empty_constructor_bodies
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010089 - empty_statements
90 - hash_and_equals
Ian Hickson94636bd2016-05-20 14:08:46 -070091 - implementation_imports
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010092 # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
93 - iterable_contains_unrelated_type
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +020094 # - join_return_with_assignment # not yet tested
krisgiesing07b5f832016-05-04 10:15:15 -070095 - library_names
96 - library_prefixes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +010097 - list_remove_unrelated_type
98 # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
99 - no_adjacent_strings_in_list
100 - no_duplicate_case_values
krisgiesing07b5f832016-05-04 10:15:15 -0700101 - non_constant_identifier_names
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200102 # - omit_local_variable_types # opposite of always_specify_types
Ian Hicksona52c7b42017-04-05 11:28:33 -0700103 # - one_member_abstracts # too many false positives
Dan Rubel7cf47ca2016-09-09 15:18:18 -0400104 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
Alexandre Ardhuinad496e12017-04-22 10:27:03 +0200105 - overridden_fields
krisgiesing07b5f832016-05-04 10:15:15 -0700106 - package_api_docs
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100107 - package_names
krisgiesing07b5f832016-05-04 10:15:15 -0700108 - package_prefixed_library_names
Ian Hicksona52c7b42017-04-05 11:28:33 -0700109 # - parameter_assignments # we do this commonly
Alexandre Ardhuinc7942212017-04-21 08:52:07 +0200110 - prefer_adjacent_string_concatenation
Alexandre Ardhuin15601fe2017-11-08 22:59:49 +0100111 - prefer_asserts_in_initializer_lists
Alexandre Ardhuinb8fcc962018-02-15 06:14:13 +0100112 - prefer_bool_in_asserts
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200113 - prefer_collection_literals
Alexandre Ardhuin872d83a2017-10-25 08:18:26 +0200114 - prefer_conditional_assignment
Alexandre Ardhuinbb4f4072017-08-31 08:55:21 +0200115 - prefer_const_constructors
Alexandre Ardhuinc9b94e12017-10-25 11:20:36 +0200116 - prefer_const_constructors_in_immutables
Alexandre Ardhuin39613062018-03-09 23:37:06 +0100117 - prefer_const_declarations
118 - prefer_const_literals_to_create_immutables
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200119 # - prefer_constructors_over_static_methods # not yet tested
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200120 - prefer_contains
Alexandre Ardhuin09276be2018-06-05 08:50:40 +0200121 - prefer_equal_for_default_values
Alexandre Ardhuin10099db2017-04-21 23:10:37 +0200122 # - 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 +0200123 - prefer_final_fields
Chris Brackenca0201d2017-03-03 18:47:00 -0800124 - prefer_final_locals
Alexandre Ardhuin28366002017-10-25 08:25:44 +0200125 - prefer_foreach
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200126 # - prefer_function_declarations_over_variables # not yet tested
Greg Spencer6c56bb22018-06-11 15:51:45 -0700127 - prefer_generic_function_type_aliases
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200128 - prefer_initializing_formals
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200129 # - prefer_interpolation_to_compose_strings # not yet tested
Alexandre Ardhuin6e06fd22018-05-31 17:49:28 +0200130 # - prefer_iterable_whereType # https://github.com/dart-lang/sdk/issues/32463
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200131 - prefer_is_empty
krisgiesing07b5f832016-05-04 10:15:15 -0700132 - prefer_is_not_empty
Alexandre Ardhuin1fce14a2017-10-22 18:11:36 +0200133 - prefer_single_quotes
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100134 - prefer_typing_uninitialized_variables
Greg Spencer6c56bb22018-06-11 15:51:45 -0700135 - public_member_api_docs
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200136 - recursive_getters
krisgiesing07b5f832016-05-04 10:15:15 -0700137 - slash_for_doc_comments
138 - sort_constructors_first
139 - sort_unnamed_constructors_first
140 - super_goes_last
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100141 - test_types_in_equals
142 - throw_in_finally
Ian Hickson94636bd2016-05-20 14:08:46 -0700143 # - type_annotate_public_apis # subset of always_specify_types
krisgiesing07b5f832016-05-04 10:15:15 -0700144 - type_init_formals
Ian Hicksona52c7b42017-04-05 11:28:33 -0700145 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200146 - unnecessary_brace_in_string_interps
krisgiesing07b5f832016-05-04 10:15:15 -0700147 - unnecessary_getters_setters
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200148 # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
Alexandre Ardhuin610955f2017-04-08 08:43:19 +0200149 - unnecessary_null_aware_assignments
150 - unnecessary_null_in_if_null_operators
Alexandre Ardhuin0783ec92017-09-01 22:18:51 +0200151 - unnecessary_overrides
Alexandre Ardhuin217b2bd2018-03-21 07:10:14 +0100152 - unnecessary_parenthesis
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100153 # - unnecessary_statements # not yet tested
Alexandre Ardhuin35803c22017-04-20 09:38:57 +0200154 - unnecessary_this
Alexandre Ardhuin1d7a22f2017-11-29 07:54:44 +0100155 - unrelated_type_equality_checks
Alexandre Ardhuin26eedb82017-05-13 15:16:30 +0200156 - use_rethrow_when_possible
Alexandre Ardhuin1f0b2d82017-05-10 08:20:13 +0200157 # - use_setters_to_change_properties # not yet tested
Alexandre Ardhuin5bce52d2017-05-12 19:00:55 +0200158 # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
Alexandre Ardhuin45cef3c2017-05-15 09:44:39 +0200159 # - 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 +0100160 - valid_regexps
Alexandre Ardhuinb7fd1d82018-05-31 08:33:13 +0200161 # - void_checks # not yet tested