analysis_options.yaml 6.35 KB
Newer Older
1
# Specify analysis options.
2 3 4 5 6 7 8 9
#
# Until there are meta linter rules, each desired lint must be explicitly enabled.
# See: https://github.com/dart-lang/linter/issues/288
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
#
10
# There are four similar analysis options files in the flutter repos:
11 12
#   - analysis_options.yaml (this file)
#   - analysis_options_repo.yaml
13
#   - packages/flutter/lib/analysis_options_user.yaml
14
#   - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
15
#
16 17
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
18
# It is very similar to the analysis_options_repo.yaml file in this same directory;
19 20
# the only difference (currently) is the public_member_api_docs option,
# which triggers too many messages to be used in editors.
21 22 23
#
# The flutter/plugins repo contains a copy of this file, which should be kept
# in sync with this file.
24 25 26 27 28

analyzer:
  language:
    enableStrictCallChecks: true
    enableSuperMixins: true
29
    enableAssertInitializer: true
30 31
  strong-mode:
    implicit-dynamic: false
32
  errors:
33 34
    # treat missing required parameters as a warning (not a hint)
    missing_required_param: warning
35 36
    # treat missing returns as a warning (not a hint)
    missing_return: warning
37
    # allow having TODOs in the code
38
    todo: ignore
39
  exclude:
40
    - 'bin/cache/**'
41 42 43 44
    # the following two are relative to the stocks example and the flutter package respectively
    # see https://github.com/dart-lang/sdk/issues/28463
    - 'lib/i18n/stock_messages_*.dart'
    - 'lib/src/http/**'
45

46 47
linter:
  rules:
48 49
    # these rules are documented on and in the same order as
    # the Dart Lint rules page to make maintenance easier
50
    # https://github.com/dart-lang/linter/blob/master/example/all.yaml
51
    - always_declare_return_types
52
    - always_put_control_body_on_new_line
53
    # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
54
    - always_require_non_null_named_parameters
55 56
    - always_specify_types
    - annotate_overrides
57
    # - avoid_annotating_with_dynamic # conflicts with always_specify_types
58
    - avoid_as
59 60
    # - avoid_catches_without_on_clauses # we do this commonly
    # - avoid_catching_errors # we do this commonly
61
    - avoid_classes_with_only_static_members
62
    - avoid_empty_else
63
    - avoid_function_literals_in_foreach_calls
64
    - avoid_init_to_null
65
    - avoid_null_checks_in_equality_operators
66
    # - avoid_positional_boolean_parameters # not yet tested
67
    - avoid_return_types_on_setters
68 69
    # - avoid_returning_null # we do this commonly
    # - avoid_returning_this # https://github.com/dart-lang/linter/issues/842
70
    # - avoid_setters_without_getters # not yet tested
71
    - avoid_slow_async_io
72
    # - avoid_types_on_closure_parameters # conflicts with always_specify_types
73
    # - avoid_unused_constructor_parameters # https://github.com/dart-lang/linter/pull/847
74
    - await_only_futures
75
    - camel_case_types
76
    - cancel_subscriptions
77
    # - cascade_invocations # not yet tested
78 79
    # - close_sinks # https://github.com/flutter/flutter/issues/5789
    # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
80
    # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
81
    - control_flow_in_finally
82
    - directives_ordering
83
    - empty_catches
84
    - empty_constructor_bodies
85 86
    - empty_statements
    - hash_and_equals
87
    - implementation_imports
88 89
    # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
    - iterable_contains_unrelated_type
90
    # - join_return_with_assignment # not yet tested
91 92
    - library_names
    - library_prefixes
93 94 95 96
    - list_remove_unrelated_type
    # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
    - no_adjacent_strings_in_list
    - no_duplicate_case_values
97
    - non_constant_identifier_names
98
    # - omit_local_variable_types # opposite of always_specify_types
99
    # - one_member_abstracts # too many false positives
100
    # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
101
    - overridden_fields
102
    - package_api_docs
103
    - package_names
104
    - package_prefixed_library_names
105
    # - parameter_assignments # we do this commonly
106
    - prefer_adjacent_string_concatenation
107
    - prefer_asserts_in_initializer_lists
108
    # - prefer_bool_in_asserts # not yet tested
109
    - prefer_collection_literals
110
    - prefer_conditional_assignment
111
    - prefer_const_constructors
112
    - prefer_const_constructors_in_immutables
113
    # - prefer_constructors_over_static_methods # not yet tested
114
    - prefer_contains
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
116
    - prefer_final_fields
117
    - prefer_final_locals
118
    - prefer_foreach
119
    # - prefer_function_declarations_over_variables # not yet tested
120
    - prefer_initializing_formals
121
    # - prefer_interpolation_to_compose_strings # not yet tested
122
    - prefer_is_empty
123
    - prefer_is_not_empty
124
    - prefer_single_quotes
125
    - prefer_typing_uninitialized_variables
126
    # - public_member_api_docs # this is the only difference from analysis_options_repo.yaml
127
    - recursive_getters
128 129 130 131
    - slash_for_doc_comments
    - sort_constructors_first
    - sort_unnamed_constructors_first
    - super_goes_last
132 133
    - test_types_in_equals
    - throw_in_finally
134
    # - type_annotate_public_apis # subset of always_specify_types
135
    - type_init_formals
136
    # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
137
    - unnecessary_brace_in_string_interps
138
    - unnecessary_getters_setters
139
    # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
140 141
    - unnecessary_null_aware_assignments
    - unnecessary_null_in_if_null_operators
142
    - unnecessary_overrides
143
    # - unnecessary_statements # not yet tested
144
    - unnecessary_this
145
    - unrelated_type_equality_checks
146
    - use_rethrow_when_possible
147
    # - use_setters_to_change_properties # not yet tested
148
    # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
149
    # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
150
    - valid_regexps