2016-05-04 17:15:15 +00:00
# Specify analysis options.
2016-09-09 17:37:56 +00:00
#
# 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
#
2017-06-09 00:17:48 +00:00
# There are four similar analysis options files in the flutter repos:
2017-08-15 12:46:42 +00:00
# - analysis_options.yaml (this file)
# - analysis_options_repo.yaml
2017-02-13 21:39:35 +00:00
# - packages/flutter/lib/analysis_options_user.yaml
2017-08-15 12:46:42 +00:00
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
2017-02-13 21:39:35 +00:00
#
2016-09-08 02:41:59 +00:00
# This file contains the analysis options used by Flutter editors, such as Atom.
2017-08-15 12:46:42 +00:00
# It is very similar to the analysis_options_repo.yaml file in this same directory;
2016-09-08 02:41:59 +00:00
# the only difference (currently) is the public_member_api_docs option,
# which triggers too many messages to be used in editors.
2017-06-09 00:17:48 +00:00
#
# The flutter/plugins repo contains a copy of this file, which should be kept
# in sync with this file.
2016-05-04 17:15:15 +00:00
analyzer :
language :
enableStrictCallChecks : true
enableSuperMixins : true
2017-04-05 18:28:33 +00:00
enableAssertInitializer : true
2017-01-23 09:04:31 +00:00
strong-mode :
implicit-dynamic : false
2016-05-04 17:15:15 +00:00
errors :
2017-02-13 22:56:56 +00:00
# treat missing required parameters as a warning (not a hint)
missing_required_param : warning
2017-03-16 21:28:18 +00:00
# treat missing returns as a warning (not a hint)
missing_return : warning
2016-09-09 17:37:56 +00:00
# allow having TODOs in the code
2016-05-04 17:15:15 +00:00
todo : ignore
2016-08-19 02:11:39 +00:00
exclude :
2016-11-07 22:47:53 +00:00
- 'bin/cache/**'
2017-01-23 00:43:24 +00:00
# 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/**'
2016-05-20 21:08:46 +00:00
2016-05-04 17:15:15 +00:00
linter :
rules :
2016-09-09 17:37:56 +00:00
# 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/
2016-05-20 21:08:46 +00:00
2016-09-09 17:37:56 +00:00
# === error rules ===
2016-05-04 17:15:15 +00:00
- avoid_empty_else
2017-02-15 22:41:54 +00:00
- avoid_slow_async_io
2016-09-12 20:32:08 +00:00
- cancel_subscriptions
2016-09-09 19:18:18 +00:00
# - close_sinks # https://github.com/flutter/flutter/issues/5789
2017-04-05 18:28:33 +00:00
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
2016-05-20 21:08:46 +00:00
- control_flow_in_finally
2016-09-09 19:18:18 +00:00
- empty_statements
2016-05-20 21:08:46 +00:00
- hash_and_equals
2016-09-09 19:18:18 +00:00
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
2017-04-20 07:38:57 +00:00
- iterable_contains_unrelated_type
2016-09-09 19:18:18 +00:00
- list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
2017-04-20 07:38:57 +00:00
- no_adjacent_strings_in_list
- no_duplicate_case_values
2016-05-20 21:08:46 +00:00
- test_types_in_equals
- throw_in_finally
- unrelated_type_equality_checks
2016-09-09 19:18:18 +00:00
- valid_regexps
2016-05-20 21:08:46 +00:00
2016-09-09 17:37:56 +00:00
# === style rules ===
2016-05-04 17:15:15 +00:00
- always_declare_return_types
2017-05-10 07:41:55 +00:00
- always_put_control_body_on_new_line
2017-08-31 06:55:21 +00:00
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
2017-05-10 06:45:36 +00:00
- always_require_non_null_named_parameters
2016-05-04 17:15:15 +00:00
- always_specify_types
- annotate_overrides
2017-05-10 06:20:13 +00:00
# - avoid_annotating_with_dynamic # not yet tested
2016-05-04 17:15:15 +00:00
- avoid_as
2017-05-10 06:20:13 +00:00
# - avoid_catches_without_on_clauses # not yet tested
# - avoid_catching_errors # not yet tested
# - avoid_classes_with_only_static_members # not yet tested
2017-04-20 07:38:57 +00:00
# - avoid_function_literals_in_foreach_calls # not yet tested
2016-05-04 17:15:15 +00:00
- avoid_init_to_null
2017-05-15 06:41:17 +00:00
- avoid_null_checks_in_equality_operators
2017-05-10 06:20:13 +00:00
# - avoid_positional_boolean_parameters # not yet tested
2016-05-20 21:08:46 +00:00
- avoid_return_types_on_setters
2017-05-10 06:20:13 +00:00
# - 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
2016-05-20 21:08:46 +00:00
- await_only_futures
2016-05-04 17:15:15 +00:00
- camel_case_types
2017-04-20 07:38:57 +00:00
# - cascade_invocations # not yet tested
2016-09-09 17:37:56 +00:00
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
2017-04-08 06:43:19 +00:00
- directives_ordering
2017-04-05 18:28:33 +00:00
- empty_catches
2016-05-04 17:15:15 +00:00
- empty_constructor_bodies
2016-05-20 21:08:46 +00:00
- implementation_imports
2017-05-10 06:20:13 +00:00
# - join_return_with_assignment # not yet tested
2016-05-04 17:15:15 +00:00
- library_names
- library_prefixes
- non_constant_identifier_names
2017-04-20 07:38:57 +00:00
# - omit_local_variable_types # opposite of always_specify_types
2017-04-05 18:28:33 +00:00
# - one_member_abstracts # too many false positives
2016-09-09 19:18:18 +00:00
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
2017-04-22 08:27:03 +00:00
- overridden_fields
2016-05-04 17:15:15 +00:00
- package_api_docs
- package_prefixed_library_names
2017-04-05 18:28:33 +00:00
# - parameter_assignments # we do this commonly
2017-04-21 06:52:07 +00:00
- prefer_adjacent_string_concatenation
2017-08-31 06:55:21 +00:00
# - prefer_asserts_in_initializer_lists # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_collection_literals
2017-05-10 06:20:13 +00:00
# - prefer_conditional_assignment # not yet tested
2017-08-31 06:55:21 +00:00
- prefer_const_constructors
# - prefer_const_constructors_in_immutables # not yet tested
2017-05-10 06:20:13 +00:00
# - prefer_constructors_over_static_methods # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_contains
2017-04-21 21:10:37 +00:00
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
2017-09-01 20:18:51 +00:00
- prefer_final_fields
2017-03-04 02:47:00 +00:00
- prefer_final_locals
2017-05-10 06:20:13 +00:00
# - prefer_foreach # not yet tested
2017-04-20 07:38:57 +00:00
# - prefer_function_declarations_over_variables # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_initializing_formals
2017-04-20 07:38:57 +00:00
# - prefer_interpolation_to_compose_strings # not yet tested
2017-04-08 06:43:19 +00:00
- prefer_is_empty
2016-05-04 17:15:15 +00:00
- prefer_is_not_empty
2017-08-31 06:55:21 +00:00
# - prefer_single_quote_strings # not yet tested
2017-08-15 12:46:42 +00:00
# - public_member_api_docs # this is the only difference from analysis_options_repo.yaml
2017-09-01 20:18:51 +00:00
- recursive_getters
2016-05-04 17:15:15 +00:00
- slash_for_doc_comments
- sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
2016-05-20 21:08:46 +00:00
# - type_annotate_public_apis # subset of always_specify_types
2016-05-04 17:15:15 +00:00
- type_init_formals
2017-04-05 18:28:33 +00:00
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
2017-04-20 07:38:57 +00:00
- unnecessary_brace_in_string_interps
2016-05-04 17:15:15 +00:00
- unnecessary_getters_setters
2017-04-20 07:38:57 +00:00
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
2017-04-08 06:43:19 +00:00
- unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators
2017-09-01 20:18:51 +00:00
- unnecessary_overrides
2017-04-20 07:38:57 +00:00
- unnecessary_this
2017-05-13 13:16:30 +00:00
- use_rethrow_when_possible
2017-05-10 06:20:13 +00:00
# - use_setters_to_change_properties # not yet tested
2017-05-12 17:00:55 +00:00
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
2017-05-15 07:44:39 +00:00
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
2016-05-20 21:08:46 +00:00
2016-09-09 17:37:56 +00:00
# === pub rules ===
2016-05-20 21:08:46 +00:00
- package_names