.analysis_options 6.03 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 13
#   - .analysis_options (this file)
#   - .analysis_options_repo
#   - packages/flutter/lib/analysis_options_user.yaml
14
#   - https://github.com/flutter/plugins/blob/master/.analysis_options
15
#
16
# This file contains the analysis options used by Flutter editors, such as Atom.
17
# It is very similar to the .analysis_options_repo file in this same directory;
18 19
# the only difference (currently) is the public_member_api_docs option,
# which triggers too many messages to be used in editors.
20 21 22
#
# The flutter/plugins repo contains a copy of this file, which should be kept
# in sync with this file.
23 24 25 26 27

analyzer:
  language:
    enableStrictCallChecks: true
    enableSuperMixins: true
28
    enableAssertInitializer: true
29 30
  strong-mode:
    implicit-dynamic: false
31
  errors:
32 33
    # treat missing required parameters as a warning (not a hint)
    missing_required_param: warning
34 35
    # treat missing returns as a warning (not a hint)
    missing_return: warning
36
    # allow having TODOs in the code
37
    todo: ignore
38
  exclude:
39
    - 'bin/cache/**'
40 41 42 43
    # 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/**'
44

45 46
linter:
  rules:
47 48 49
    # these rules are documented on and in the same order as
    # the Dart Lint rules page to make maintenance easier
    # http://dart-lang.github.io/linter/lints/
50

51
    # === error rules ===
52
    - avoid_empty_else
53
    - avoid_slow_async_io
54
    - cancel_subscriptions
55
    # - close_sinks # https://github.com/flutter/flutter/issues/5789
56
    # - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
57
    - control_flow_in_finally
58
    - empty_statements
59
    - hash_and_equals
60
    # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
61
    - iterable_contains_unrelated_type
62 63
    - list_remove_unrelated_type
    # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
64 65
    - no_adjacent_strings_in_list
    - no_duplicate_case_values
66 67 68
    - test_types_in_equals
    - throw_in_finally
    - unrelated_type_equality_checks
69
    - valid_regexps
70

71
    # === style rules ===
72
    - always_declare_return_types
73
    - always_put_control_body_on_new_line
74
    - always_require_non_null_named_parameters
75 76
    - always_specify_types
    - annotate_overrides
77
    # - avoid_annotating_with_dynamic # not yet tested
78
    - avoid_as
79 80 81
    # - avoid_catches_without_on_clauses # not yet tested
    # - avoid_catching_errors # not yet tested
    # - avoid_classes_with_only_static_members # not yet tested
82
    # - avoid_function_literals_in_foreach_calls # not yet tested
83
    - avoid_init_to_null
84
    - avoid_null_checks_in_equality_operators
85
    # - avoid_positional_boolean_parameters # not yet tested
86
    - avoid_return_types_on_setters
87 88 89 90
    # - avoid_returning_null # not yet tested
    # - avoid_returning_this # not yet tested
    # - avoid_setters_without_getters # not yet tested
    # - avoid_types_on_closure_parameters # not yet tested
91
    - await_only_futures
92
    - camel_case_types
93
    # - cascade_invocations # not yet tested
94
    # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
95
    - directives_ordering
96
    - empty_catches
97
    - empty_constructor_bodies
98
    - implementation_imports
99
    # - join_return_with_assignment # not yet tested
100 101 102
    - library_names
    - library_prefixes
    - non_constant_identifier_names
103
    # - omit_local_variable_types # opposite of always_specify_types
104
    # - one_member_abstracts # too many false positives
105
    # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
106
    - overridden_fields
107 108
    - package_api_docs
    - package_prefixed_library_names
109
    # - parameter_assignments # we do this commonly
110
    - prefer_adjacent_string_concatenation
111
    - prefer_collection_literals
112
    # - prefer_conditional_assignment # not yet tested
113
    - prefer_const_constructors
114
    # - prefer_constructors_over_static_methods # not yet tested
115
    - prefer_contains
116
    # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
117
    # - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
118
    - prefer_final_locals
119
    # - prefer_foreach # not yet tested
120
    # - prefer_function_declarations_over_variables # not yet tested
121
    - prefer_initializing_formals
122
    # - prefer_interpolation_to_compose_strings # not yet tested
123
    - prefer_is_empty
124
    - prefer_is_not_empty
125
    # - public_member_api_docs # this is the only difference from .analysis_options_repo
126
    # - recursive_getters # https://github.com/dart-lang/linter/issues/452
127 128 129 130
    - slash_for_doc_comments
    - sort_constructors_first
    - sort_unnamed_constructors_first
    - super_goes_last
131
    # - type_annotate_public_apis # subset of always_specify_types
132
    - type_init_formals
133
    # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
134
    - unnecessary_brace_in_string_interps
135
    - unnecessary_getters_setters
136
    # - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
137 138
    - unnecessary_null_aware_assignments
    - unnecessary_null_in_if_null_operators
139
    # - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
140
    - unnecessary_this
141
    - use_rethrow_when_possible
142
    # - use_setters_to_change_properties # not yet tested
143
    # - use_string_buffers # https://github.com/dart-lang/linter/pull/664
144
    # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
145

146
    # === pub rules ===
147
    - package_names