analysis_options.yaml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # Specify analysis options.
  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. #
  10. # There are other similar analysis options files in the flutter repos,
  11. # which should be kept in sync with this file:
  12. #
  13. # - analysis_options.yaml (this file)
  14. # - packages/flutter/lib/analysis_options_user.yaml
  15. # - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
  16. # - https://github.com/flutter/engine/blob/master/analysis_options.yaml
  17. #
  18. # This file contains the analysis options used by Flutter tools, such as IntelliJ,
  19. # Android Studio, and the `flutter analyze` command.
  20. analyzer:
  21. strong-mode:
  22. implicit-casts: false
  23. implicit-dynamic: false
  24. errors:
  25. # treat missing required parameters as a warning (not a hint)
  26. missing_required_param: warning
  27. # treat missing returns as a warning (not a hint)
  28. missing_return: warning
  29. # allow having TODOs in the code
  30. todo: ignore
  31. exclude:
  32. - 'flutter/**'
  33. linter:
  34. rules:
  35. # these rules are documented on and in the same order as
  36. # the Dart Lint rules page to make maintenance easier
  37. # https://github.com/dart-lang/linter/blob/master/example/all.yaml
  38. - always_declare_return_types
  39. - always_put_control_body_on_new_line
  40. # - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
  41. - always_require_non_null_named_parameters
  42. - always_specify_types
  43. - annotate_overrides
  44. # - avoid_annotating_with_dynamic # conflicts with always_specify_types
  45. # - avoid_as # conflicts with implicit-casts: false
  46. # - avoid_bool_literals_in_conditional_expressions # not yet tested
  47. # - avoid_catches_without_on_clauses # we do this commonly
  48. # - avoid_catching_errors # we do this commonly
  49. - avoid_classes_with_only_static_members
  50. # - avoid_double_and_int_checks # only useful when targeting JS runtime
  51. - avoid_empty_else
  52. - avoid_field_initializers_in_const_classes
  53. - avoid_function_literals_in_foreach_calls
  54. # - avoid_implementing_value_types # not yet tested
  55. - avoid_init_to_null
  56. # - avoid_js_rounded_ints # only useful when targeting JS runtime
  57. - avoid_null_checks_in_equality_operators
  58. # - avoid_positional_boolean_parameters # not yet tested
  59. # - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
  60. - avoid_relative_lib_imports
  61. - avoid_renaming_method_parameters
  62. - avoid_return_types_on_setters
  63. # - avoid_returning_null # there are plenty of valid reasons to return null
  64. - avoid_returning_null_for_void
  65. # - avoid_returning_this # there are plenty of valid reasons to return this
  66. # - avoid_setters_without_getters # not yet tested
  67. # - avoid_single_cascade_in_expression_statements # not yet tested
  68. - avoid_slow_async_io
  69. - avoid_types_as_parameter_names
  70. # - avoid_types_on_closure_parameters # conflicts with always_specify_types
  71. - avoid_unused_constructor_parameters
  72. - avoid_void_async
  73. - await_only_futures
  74. - camel_case_types
  75. - cancel_subscriptions
  76. # - cascade_invocations # not yet tested
  77. # - close_sinks # not reliable enough
  78. # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
  79. # - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
  80. - control_flow_in_finally
  81. # - curly_braces_in_flow_control_structures # not yet tested
  82. - directives_ordering
  83. - empty_catches
  84. - empty_constructor_bodies
  85. - empty_statements
  86. # - file_names # not yet tested
  87. - flutter_style_todos
  88. - hash_and_equals
  89. - implementation_imports
  90. # - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
  91. - iterable_contains_unrelated_type
  92. # - join_return_with_assignment # not yet tested
  93. - library_names
  94. - library_prefixes
  95. # - lines_longer_than_80_chars # not yet tested
  96. - list_remove_unrelated_type
  97. # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
  98. - no_adjacent_strings_in_list
  99. - no_duplicate_case_values
  100. - non_constant_identifier_names
  101. # - null_closures # not yet tested
  102. # - omit_local_variable_types # opposite of always_specify_types
  103. # - one_member_abstracts # too many false positives
  104. # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
  105. - overridden_fields
  106. - package_api_docs
  107. - package_names
  108. - package_prefixed_library_names
  109. # - parameter_assignments # we do this commonly
  110. - prefer_adjacent_string_concatenation
  111. - prefer_asserts_in_initializer_lists
  112. - prefer_collection_literals
  113. - prefer_conditional_assignment
  114. - prefer_const_constructors
  115. - prefer_const_constructors_in_immutables
  116. - prefer_const_declarations
  117. - prefer_const_literals_to_create_immutables
  118. # - prefer_constructors_over_static_methods # not yet tested
  119. - prefer_contains
  120. - prefer_equal_for_default_values
  121. # - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
  122. - prefer_final_fields
  123. - prefer_final_locals
  124. - prefer_foreach
  125. # - prefer_function_declarations_over_variables # not yet tested
  126. - prefer_generic_function_type_aliases
  127. - prefer_initializing_formals
  128. # - prefer_int_literals # not yet tested
  129. # - prefer_interpolation_to_compose_strings # not yet tested
  130. - prefer_is_empty
  131. - prefer_is_not_empty
  132. - prefer_iterable_whereType
  133. # - prefer_mixin # https://github.com/dart-lang/language/issues/32
  134. - prefer_single_quotes
  135. - prefer_typing_uninitialized_variables
  136. - prefer_void_to_null
  137. # - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
  138. - recursive_getters
  139. - slash_for_doc_comments
  140. - sort_constructors_first
  141. - sort_pub_dependencies
  142. - sort_unnamed_constructors_first
  143. - public_member_api_docs
  144. - test_types_in_equals
  145. - throw_in_finally
  146. # - type_annotate_public_apis # subset of always_specify_types
  147. - type_init_formals
  148. # - unawaited_futures # too many false positives
  149. - unnecessary_brace_in_string_interps
  150. - unnecessary_const
  151. - unnecessary_getters_setters
  152. # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
  153. - unnecessary_new
  154. - unnecessary_null_aware_assignments
  155. - unnecessary_null_in_if_null_operators
  156. - unnecessary_overrides
  157. - unnecessary_parenthesis
  158. - unnecessary_statements
  159. - unnecessary_this
  160. - unrelated_type_equality_checks
  161. - use_rethrow_when_possible
  162. # - use_setters_to_change_properties # not yet tested
  163. # - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
  164. # - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
  165. - valid_regexps
  166. # - void_checks # not yet tested