krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 1 | # Specify analysis options. |
Dan Rubel | 5784385 | 2016-09-09 13:37:56 -0400 | [diff] [blame] | 2 | # |
| 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 Goderbauer | 435c25b | 2017-06-08 17:17:48 -0700 | [diff] [blame] | 10 | # There are four similar analysis options files in the flutter repos: |
Dan Rubel | 3a31c35 | 2017-08-15 08:46:42 -0400 | [diff] [blame] | 11 | # - analysis_options.yaml (this file) |
| 12 | # - analysis_options_repo.yaml |
Dan Rubel | ea74e07 | 2017-02-13 16:39:35 -0500 | [diff] [blame] | 13 | # - packages/flutter/lib/analysis_options_user.yaml |
Dan Rubel | 3a31c35 | 2017-08-15 08:46:42 -0400 | [diff] [blame] | 14 | # - https://github.com/flutter/plugins/blob/master/analysis_options.yaml |
Dan Rubel | ea74e07 | 2017-02-13 16:39:35 -0500 | [diff] [blame] | 15 | # |
Michael Thomsen | 5ecbc92 | 2017-11-23 09:17:29 +0100 | [diff] [blame] | 16 | # This file contains the analysis options used by Flutter tools, such as IntelliJ, |
| 17 | # Android Studio, and the `flutter analyze` command. |
Dan Rubel | 3a31c35 | 2017-08-15 08:46:42 -0400 | [diff] [blame] | 18 | # It is very similar to the analysis_options_repo.yaml file in this same directory; |
Dan Rubel | 3ed3390 | 2016-09-07 22:41:59 -0400 | [diff] [blame] | 19 | # the only difference (currently) is the public_member_api_docs option, |
| 20 | # which triggers too many messages to be used in editors. |
Michael Goderbauer | 435c25b | 2017-06-08 17:17:48 -0700 | [diff] [blame] | 21 | # |
| 22 | # The flutter/plugins repo contains a copy of this file, which should be kept |
| 23 | # in sync with this file. |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 24 | |
| 25 | analyzer: |
| 26 | language: |
| 27 | enableStrictCallChecks: true |
| 28 | enableSuperMixins: true |
Ian Hickson | a52c7b4 | 2017-04-05 11:28:33 -0700 | [diff] [blame] | 29 | enableAssertInitializer: true |
Ian Hickson | 63aa139 | 2017-01-23 01:04:31 -0800 | [diff] [blame] | 30 | strong-mode: |
| 31 | implicit-dynamic: false |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 32 | errors: |
Phil Quitslund | 39f7d58 | 2017-02-13 14:56:56 -0800 | [diff] [blame] | 33 | # treat missing required parameters as a warning (not a hint) |
| 34 | missing_required_param: warning |
Phil Quitslund | 41d9968 | 2017-03-16 14:28:18 -0700 | [diff] [blame] | 35 | # treat missing returns as a warning (not a hint) |
| 36 | missing_return: warning |
Dan Rubel | 5784385 | 2016-09-09 13:37:56 -0400 | [diff] [blame] | 37 | # allow having TODOs in the code |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 38 | todo: ignore |
Devon Carew | 207451f | 2016-08-18 19:11:39 -0700 | [diff] [blame] | 39 | exclude: |
Devon Carew | f1b3523 | 2016-11-07 14:47:53 -0800 | [diff] [blame] | 40 | - 'bin/cache/**' |
Ian Hickson | cbda208 | 2017-01-22 16:43:24 -0800 | [diff] [blame] | 41 | # the following two are relative to the stocks example and the flutter package respectively |
| 42 | # see https://github.com/dart-lang/sdk/issues/28463 |
| 43 | - 'lib/i18n/stock_messages_*.dart' |
| 44 | - 'lib/src/http/**' |
Ian Hickson | 94636bd | 2016-05-20 14:08:46 -0700 | [diff] [blame] | 45 | |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 46 | linter: |
| 47 | rules: |
Dan Rubel | 5784385 | 2016-09-09 13:37:56 -0400 | [diff] [blame] | 48 | # these rules are documented on and in the same order as |
| 49 | # the Dart Lint rules page to make maintenance easier |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 50 | # https://github.com/dart-lang/linter/blob/master/example/all.yaml |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 51 | - always_declare_return_types |
Alexandre Ardhuin | 9b56c1c | 2017-05-10 09:41:55 +0200 | [diff] [blame] | 52 | - always_put_control_body_on_new_line |
Alexandre Ardhuin | bb4f407 | 2017-08-31 08:55:21 +0200 | [diff] [blame] | 53 | # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219 |
Alexandre Ardhuin | e454658 | 2017-05-10 08:45:36 +0200 | [diff] [blame] | 54 | - always_require_non_null_named_parameters |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 55 | - always_specify_types |
| 56 | - annotate_overrides |
Alexandre Ardhuin | ce6f8d3 | 2017-10-19 08:33:01 +0200 | [diff] [blame] | 57 | # - avoid_annotating_with_dynamic # conflicts with always_specify_types |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 58 | - avoid_as |
Alexandre Ardhuin | ce6f8d3 | 2017-10-19 08:33:01 +0200 | [diff] [blame] | 59 | # - avoid_catches_without_on_clauses # we do this commonly |
| 60 | # - avoid_catching_errors # we do this commonly |
Alexandre Ardhuin | 436aa93 | 2017-11-09 07:12:36 +0100 | [diff] [blame] | 61 | - avoid_classes_with_only_static_members |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 62 | - avoid_empty_else |
Alexandre Ardhuin | 700dc9f | 2017-10-19 08:16:16 +0200 | [diff] [blame] | 63 | - avoid_function_literals_in_foreach_calls |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 64 | - avoid_init_to_null |
Alexandre Ardhuin | f7502c8 | 2017-05-15 08:41:17 +0200 | [diff] [blame] | 65 | - avoid_null_checks_in_equality_operators |
Alexandre Ardhuin | 1f0b2d8 | 2017-05-10 08:20:13 +0200 | [diff] [blame] | 66 | # - avoid_positional_boolean_parameters # not yet tested |
Ian Hickson | 94636bd | 2016-05-20 14:08:46 -0700 | [diff] [blame] | 67 | - avoid_return_types_on_setters |
Alexandre Ardhuin | aefc62f | 2017-11-10 07:49:44 +0100 | [diff] [blame] | 68 | # - avoid_returning_null # we do this commonly |
| 69 | # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842 |
Alexandre Ardhuin | 1f0b2d8 | 2017-05-10 08:20:13 +0200 | [diff] [blame] | 70 | # - avoid_setters_without_getters # not yet tested |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 71 | - avoid_slow_async_io |
Alexandre Ardhuin | aefc62f | 2017-11-10 07:49:44 +0100 | [diff] [blame] | 72 | # - avoid_types_on_closure_parameters # conflicts with always_specify_types |
Alexandre Ardhuin | c358898 | 2017-11-30 09:20:53 +0100 | [diff] [blame^] | 73 | # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847 |
Ian Hickson | 94636bd | 2016-05-20 14:08:46 -0700 | [diff] [blame] | 74 | - await_only_futures |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 75 | - camel_case_types |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 76 | - cancel_subscriptions |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 77 | # - cascade_invocations # not yet tested |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 78 | # - close_sinks # https://github.com/flutter/flutter/issues/5789 |
| 79 | # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153 |
Dan Rubel | 5784385 | 2016-09-09 13:37:56 -0400 | [diff] [blame] | 80 | # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 81 | - control_flow_in_finally |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 82 | - directives_ordering |
Ian Hickson | a52c7b4 | 2017-04-05 11:28:33 -0700 | [diff] [blame] | 83 | - empty_catches |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 84 | - empty_constructor_bodies |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 85 | - empty_statements |
| 86 | - hash_and_equals |
Ian Hickson | 94636bd | 2016-05-20 14:08:46 -0700 | [diff] [blame] | 87 | - implementation_imports |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 88 | # - invariant_booleans # https://github.com/flutter/flutter/issues/5790 |
| 89 | - iterable_contains_unrelated_type |
Alexandre Ardhuin | 1f0b2d8 | 2017-05-10 08:20:13 +0200 | [diff] [blame] | 90 | # - join_return_with_assignment # not yet tested |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 91 | - library_names |
| 92 | - library_prefixes |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 93 | - 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 |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 97 | - non_constant_identifier_names |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 98 | # - omit_local_variable_types # opposite of always_specify_types |
Ian Hickson | a52c7b4 | 2017-04-05 11:28:33 -0700 | [diff] [blame] | 99 | # - one_member_abstracts # too many false positives |
Dan Rubel | 7cf47ca | 2016-09-09 15:18:18 -0400 | [diff] [blame] | 100 | # - only_throw_errors # https://github.com/flutter/flutter/issues/5792 |
Alexandre Ardhuin | ad496e1 | 2017-04-22 10:27:03 +0200 | [diff] [blame] | 101 | - overridden_fields |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 102 | - package_api_docs |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 103 | - package_names |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 104 | - package_prefixed_library_names |
Ian Hickson | a52c7b4 | 2017-04-05 11:28:33 -0700 | [diff] [blame] | 105 | # - parameter_assignments # we do this commonly |
Alexandre Ardhuin | c794221 | 2017-04-21 08:52:07 +0200 | [diff] [blame] | 106 | - prefer_adjacent_string_concatenation |
Alexandre Ardhuin | 15601fe | 2017-11-08 22:59:49 +0100 | [diff] [blame] | 107 | - prefer_asserts_in_initializer_lists |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 108 | # - prefer_bool_in_asserts # not yet tested |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 109 | - prefer_collection_literals |
Alexandre Ardhuin | 872d83a | 2017-10-25 08:18:26 +0200 | [diff] [blame] | 110 | - prefer_conditional_assignment |
Alexandre Ardhuin | bb4f407 | 2017-08-31 08:55:21 +0200 | [diff] [blame] | 111 | - prefer_const_constructors |
Alexandre Ardhuin | c9b94e1 | 2017-10-25 11:20:36 +0200 | [diff] [blame] | 112 | - prefer_const_constructors_in_immutables |
Alexandre Ardhuin | 1f0b2d8 | 2017-05-10 08:20:13 +0200 | [diff] [blame] | 113 | # - prefer_constructors_over_static_methods # not yet tested |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 114 | - prefer_contains |
Alexandre Ardhuin | 10099db | 2017-04-21 23:10:37 +0200 | [diff] [blame] | 115 | # - 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 Ardhuin | 0783ec9 | 2017-09-01 22:18:51 +0200 | [diff] [blame] | 116 | - prefer_final_fields |
Chris Bracken | ca0201d | 2017-03-03 18:47:00 -0800 | [diff] [blame] | 117 | - prefer_final_locals |
Alexandre Ardhuin | 2836600 | 2017-10-25 08:25:44 +0200 | [diff] [blame] | 118 | - prefer_foreach |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 119 | # - prefer_function_declarations_over_variables # not yet tested |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 120 | - prefer_initializing_formals |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 121 | # - prefer_interpolation_to_compose_strings # not yet tested |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 122 | - prefer_is_empty |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 123 | - prefer_is_not_empty |
Alexandre Ardhuin | 1fce14a | 2017-10-22 18:11:36 +0200 | [diff] [blame] | 124 | - prefer_single_quotes |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 125 | - prefer_typing_uninitialized_variables |
Dan Rubel | 3a31c35 | 2017-08-15 08:46:42 -0400 | [diff] [blame] | 126 | # - public_member_api_docs # this is the only difference from analysis_options_repo.yaml |
Alexandre Ardhuin | 0783ec9 | 2017-09-01 22:18:51 +0200 | [diff] [blame] | 127 | - recursive_getters |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 128 | - slash_for_doc_comments |
| 129 | - sort_constructors_first |
| 130 | - sort_unnamed_constructors_first |
| 131 | - super_goes_last |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 132 | - test_types_in_equals |
| 133 | - throw_in_finally |
Ian Hickson | 94636bd | 2016-05-20 14:08:46 -0700 | [diff] [blame] | 134 | # - type_annotate_public_apis # subset of always_specify_types |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 135 | - type_init_formals |
Ian Hickson | a52c7b4 | 2017-04-05 11:28:33 -0700 | [diff] [blame] | 136 | # - unawaited_futures # https://github.com/flutter/flutter/issues/5793 |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 137 | - unnecessary_brace_in_string_interps |
krisgiesing | 07b5f83 | 2016-05-04 10:15:15 -0700 | [diff] [blame] | 138 | - unnecessary_getters_setters |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 139 | # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498 |
Alexandre Ardhuin | 610955f | 2017-04-08 08:43:19 +0200 | [diff] [blame] | 140 | - unnecessary_null_aware_assignments |
| 141 | - unnecessary_null_in_if_null_operators |
Alexandre Ardhuin | 0783ec9 | 2017-09-01 22:18:51 +0200 | [diff] [blame] | 142 | - unnecessary_overrides |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 143 | # - unnecessary_statements # not yet tested |
Alexandre Ardhuin | 35803c2 | 2017-04-20 09:38:57 +0200 | [diff] [blame] | 144 | - unnecessary_this |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 145 | - unrelated_type_equality_checks |
Alexandre Ardhuin | 26eedb8 | 2017-05-13 15:16:30 +0200 | [diff] [blame] | 146 | - use_rethrow_when_possible |
Alexandre Ardhuin | 1f0b2d8 | 2017-05-10 08:20:13 +0200 | [diff] [blame] | 147 | # - use_setters_to_change_properties # not yet tested |
Alexandre Ardhuin | 5bce52d | 2017-05-12 19:00:55 +0200 | [diff] [blame] | 148 | # - use_string_buffers # https://github.com/dart-lang/linter/pull/664 |
Alexandre Ardhuin | 45cef3c | 2017-05-15 09:44:39 +0200 | [diff] [blame] | 149 | # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review |
Alexandre Ardhuin | 1d7a22f | 2017-11-29 07:54:44 +0100 | [diff] [blame] | 150 | - valid_regexps |