Skip to content

Commit fed16d7

Browse files
authored
Add analysis_options.yaml files (#203)
* Add analysis_options.yaml files * Fix #161 * Add analysis_options_legacy.yaml for legacy plugins * Sync analysis_options.yaml with flutter/plugins/analysis_options.yaml * Add analysis_options_plus.yaml * Add 3rd-party's analysis_options_plus.yaml * Add some package which used in each analysis_options.yaml to dev_dependencies Signed-off-by: Boram Bae <[email protected]> * Update the source of analysis_options.yaml * flutter -> flutter/plugins Signed-off-by: Boram Bae <[email protected]>
1 parent bd9338e commit fed16d7

File tree

69 files changed

+248
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+248
-12
lines changed

analysis_options.yaml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file was copied from flutter/analysis_options.yaml.
1+
# This file was copied from flutter/plugins/analysis_options.yaml.
22

33
analyzer:
44
strong-mode:
@@ -18,6 +18,18 @@ analyzer:
1818
# Stream and not importing dart:async
1919
# Please see https://github.com/flutter/flutter/pull/24528 for details.
2020
sdk_version_async_exported_from_core: ignore
21+
### Local flutter/plugins changes ###
22+
# Allow null checks for as long as mixed mode is officially supported.
23+
unnecessary_null_comparison: false
24+
always_require_non_null_named_parameters: false # not needed with nnbd
25+
# TODO(https://github.com/flutter/flutter/issues/74381):
26+
# Clean up existing unnecessary imports, and remove line to ignore.
27+
unnecessary_import: ignore
28+
exclude:
29+
# Ignore generated files
30+
- '**/*.g.dart'
31+
- 'lib/src/generated/*.dart'
32+
- '**/*.mocks.dart' # Mockito @GenerateMocks
2133

2234
linter:
2335
rules:
@@ -29,6 +41,7 @@ linter:
2941
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
3042
- always_require_non_null_named_parameters
3143
- always_specify_types
44+
# - always_use_package_imports # we do this commonly
3245
- annotate_overrides
3346
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
3447
# - avoid_as # required for implicit-casts: true
@@ -39,6 +52,7 @@ linter:
3952
# - avoid_double_and_int_checks # only useful when targeting JS runtime
4053
- avoid_empty_else
4154
- avoid_equals_and_hash_code_on_mutable_classes
55+
# - avoid_escaping_inner_quotes # not yet tested
4256
- avoid_field_initializers_in_const_classes
4357
- avoid_function_literals_in_foreach_calls
4458
# - avoid_implementing_value_types # not yet tested
@@ -57,9 +71,10 @@ linter:
5771
- avoid_returning_null_for_void
5872
# - avoid_returning_this # there are plenty of valid reasons to return this
5973
# - avoid_setters_without_getters # not yet tested
60-
# - avoid_shadowing_type_parameters # not yet tested
74+
- avoid_shadowing_type_parameters
6175
- avoid_single_cascade_in_expression_statements
6276
- avoid_slow_async_io
77+
# - avoid_type_to_string # we do this commonly
6378
- avoid_types_as_parameter_names
6479
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
6580
# - avoid_unnecessary_containers # not yet tested
@@ -71,53 +86,59 @@ linter:
7186
- camel_case_types
7287
- cancel_subscriptions
7388
# - cascade_invocations # not yet tested
89+
- cast_nullable_to_non_nullable
7490
# - close_sinks # not reliable enough
7591
# - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
7692
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
7793
- control_flow_in_finally
78-
# - curly_braces_in_flow_control_structures # not yet tested
94+
# - curly_braces_in_flow_control_structures # not required by flutter style
7995
# - diagnostic_describe_all_properties # not yet tested
8096
- directives_ordering
97+
# - do_not_use_environment # we do this commonly
8198
- empty_catches
8299
- empty_constructor_bodies
83100
- empty_statements
101+
- exhaustive_cases
84102
# - file_names # not yet tested
85103
- flutter_style_todos
86104
- hash_and_equals
87105
- implementation_imports
88106
# - invariant_booleans # too many false positives: https://github.com/dart-lang/linter/issues/811
89107
- iterable_contains_unrelated_type
90-
# - join_return_with_assignment # not yet tested
108+
# - join_return_with_assignment # not required by flutter style
109+
- leading_newlines_in_multiline_strings
91110
- library_names
92111
- library_prefixes
93-
# - lines_longer_than_80_chars # not yet tested
112+
# - lines_longer_than_80_chars # not required by flutter style
94113
- list_remove_unrelated_type
95114
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
96115
# - missing_whitespace_between_adjacent_strings # not yet tested
97116
- no_adjacent_strings_in_list
117+
# - no_default_cases # too many false positives
98118
- no_duplicate_case_values
99-
# - no_logic_in_create_state # not yet tested
100-
# - no_runtimeType_toString # not yet tested
119+
- no_logic_in_create_state
120+
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
101121
- non_constant_identifier_names
102-
# - null_closures # not yet tested
122+
- null_check_on_nullable_type_parameter
123+
# - null_closures # not required by flutter style
103124
# - omit_local_variable_types # opposite of always_specify_types
104125
# - one_member_abstracts # too many false positives
105126
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
106127
- overridden_fields
107128
- package_api_docs
108-
- package_names
129+
# - package_names # non conforming packages in sdk
109130
- package_prefixed_library_names
110131
# - parameter_assignments # we do this commonly
111132
- prefer_adjacent_string_concatenation
112133
- prefer_asserts_in_initializer_lists
113-
# - prefer_asserts_with_message # not yet tested
134+
# - prefer_asserts_with_message # not required by flutter style
114135
- prefer_collection_literals
115136
- prefer_conditional_assignment
116137
- prefer_const_constructors
117138
- prefer_const_constructors_in_immutables
118139
- prefer_const_declarations
119140
- prefer_const_literals_to_create_immutables
120-
# - prefer_constructors_over_static_methods # not yet tested
141+
# - prefer_constructors_over_static_methods # far too many false positives
121142
- prefer_contains
122143
# - prefer_double_quotes # opposite of prefer_single_quotes
123144
- prefer_equal_for_default_values
@@ -149,13 +170,14 @@ linter:
149170
# - provide_deprecation_message # not yet tested
150171
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
151172
- recursive_getters
173+
# - sized_box_for_whitespace # not yet tested
152174
- slash_for_doc_comments
153175
# - sort_child_properties_last # not yet tested
154176
- sort_constructors_first
155-
- sort_pub_dependencies
156177
- sort_unnamed_constructors_first
157178
- test_types_in_equals
158179
- throw_in_finally
180+
- tighten_type_of_initializing_formals
159181
# - type_annotate_public_apis # subset of always_specify_types
160182
- type_init_formals
161183
# - unawaited_futures # too many false positives
@@ -167,21 +189,35 @@ linter:
167189
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
168190
- unnecessary_new
169191
- unnecessary_null_aware_assignments
192+
# - unnecessary_null_checks # not yet tested
170193
- unnecessary_null_in_if_null_operators
194+
- unnecessary_nullable_for_final_variable_declarations
171195
- unnecessary_overrides
172196
- unnecessary_parenthesis
197+
# - unnecessary_raw_strings # not yet tested
173198
- unnecessary_statements
199+
- unnecessary_string_escapes
174200
- unnecessary_string_interpolations
175201
- unnecessary_this
176202
- unrelated_type_equality_checks
177203
# - unsafe_html # not yet tested
178204
- use_full_hex_values_for_flutter_colors
179205
# - use_function_type_syntax_for_parameters # not yet tested
206+
- use_is_even_rather_than_modulo
180207
# - use_key_in_widget_constructors # not yet tested
181208
- use_late_for_private_fields_and_variables
209+
- use_raw_strings
182210
- use_rethrow_when_possible
183211
# - use_setters_to_change_properties # not yet tested
184212
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
185213
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
186214
- valid_regexps
187215
- void_checks
216+
### Local flutter/plugins changes ###
217+
# These are from flutter/flutter/packages, so will need to be preserved
218+
# separately when moving to a shared file.
219+
- no_runtimeType_toString # use objectRuntimeType from package:foundation
220+
- public_member_api_docs # see https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#documentation-dartdocs-javadocs-etc
221+
# Flutter has a specific use case for dependencies that are intentionally
222+
# not sorted, which doesn't apply to this repo.
223+
- sort_pub_dependencies

analysis_options_legacy.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file was copied from flutter/plugins/analysis_options_legacy.yaml
2+
3+
include: package:pedantic/analysis_options.1.8.0.yaml
4+
analyzer:
5+
exclude:
6+
# Ignore generated files
7+
- '**/*.g.dart'
8+
- 'lib/src/generated/*.dart'
9+
- '**/*.mocks.dart' # Mockito @GenerateMocks
10+
errors:
11+
always_require_non_null_named_parameters: false # not needed with nnbd
12+
unnecessary_null_comparison: false # Turned as long as nnbd mix-mode is supported.
13+
linter:
14+
rules:
15+
- public_member_api_docs

analysis_options_plus.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This file was copied from plus_plugins/analysis_options.yaml.
2+
3+
include: package:pedantic/analysis_options.yaml
4+
5+
analyzer:
6+
enable-experiment:
7+
- non-nullable
8+
exclude:
9+
# Ignore generated files
10+
- '**/*.g.dart'
11+
- 'lib/src/generated/*.dart'
12+
13+
linter:
14+
rules:
15+
public_member_api_docs: true
16+
prefer_final_in_for_each: true
17+
prefer_final_locals: true
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was copied from audioplayers/analysis_options.yaml(tag:0.18.3).
2+
3+
# Source of linter options:
4+
# http://dart-lang.github.io/linter/lints/options/options.html
5+
6+
linter:
7+
rules:
8+
- camel_case_types
9+
- hash_and_equals
10+
- iterable_contains_unrelated_type
11+
- list_remove_unrelated_type
12+
- unrelated_type_equality_checks
13+
- valid_regexps
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_legacy.yaml

packages/battery/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dev_dependencies:
1818
sdk: flutter
1919
integration_test_tizen:
2020
path: ../../integration_test/
21+
pedantic: ^1.10.0
2122

2223
flutter:
2324
uses-material-design: true

packages/battery/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dependencies:
1616
flutter:
1717
sdk: flutter
1818

19+
dev_dependencies:
20+
pedantic: ^1.10.0
21+
1922
environment:
2023
sdk: ">=2.12.0 <3.0.0"
2124
flutter: ">=2.0.0"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_plus.yaml

packages/battery_plus/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dev_dependencies:
1818
sdk: flutter
1919
integration_test_tizen:
2020
path: ../../integration_test/
21+
pedantic: ^1.9.2
2122

2223
dependency_overrides:
2324
args: ^2.0.0

packages/battery_plus/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dependencies:
1616
flutter:
1717
sdk: flutter
1818

19+
dev_dependencies:
20+
pedantic: ^1.9.2
21+
1922
environment:
2023
sdk: ">=2.12.0 <3.0.0"
2124
flutter: ">=2.0.0"

packages/camera/analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_legacy.yaml

packages/camera/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
dev_dependencies:
1111
flutter_test:
1212
sdk: flutter
13+
pedantic: ^1.10.0
1314

1415
flutter:
1516
plugin:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_legacy.yaml

packages/connectivity/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dev_dependencies:
1818
sdk: flutter
1919
integration_test_tizen:
2020
path: ../../integration_test/
21+
pedantic: ^1.10.0
2122

2223
flutter:
2324
uses-material-design: true

packages/connectivity/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ dependencies:
1515
flutter:
1616
sdk: flutter
1717

18+
dev_dependencies:
19+
pedantic: ^1.10.0
20+
1821
environment:
1922
sdk: ">=2.12.0 <3.0.0"
2023
flutter: ">=2.0.0"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_plus.yaml

packages/connectivity_plus/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ dev_dependencies:
1818
sdk: flutter
1919
integration_test_tizen:
2020
path: ../../integration_test/
21+
pedantic: ^1.9.2
2122

2223
flutter:
2324
uses-material-design: true

packages/connectivity_plus/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dependencies:
1616
flutter:
1717
sdk: flutter
1818

19+
dev_dependencies:
20+
pedantic: ^1.9.2
21+
1922
environment:
2023
sdk: ">=2.12.0 <3.0.0"
2124
flutter: ">=2.0.0"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_legacy.yaml

packages/device_info/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dev_dependencies:
1717
sdk: flutter
1818
integration_test_tizen:
1919
path: ../../integration_test/
20+
pedantic: ^1.10.0
2021

2122
flutter:
2223
uses-material-design: true

packages/device_info/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dependencies:
1616
flutter:
1717
sdk: flutter
1818

19+
dev_dependencies:
20+
pedantic: ^1.10.0
21+
1922
environment:
2023
sdk: '>=2.12.0 <3.0.0'
2124
flutter: ">=2.0.0"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_plus.yaml

packages/device_info_plus/example/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dev_dependencies:
1717
sdk: flutter
1818
integration_test_tizen:
1919
path: ../../integration_test/
20+
pedantic: ^1.9.2
2021

2122
flutter:
2223
uses-material-design: true

packages/device_info_plus/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ dependencies:
1616
flutter:
1717
sdk: flutter
1818

19+
dev_dependencies:
20+
pedantic: ^1.9.2
21+
1922
environment:
2023
sdk: '>=2.12.0 <3.0.0'
2124
flutter: ">=2.0.0"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# This file was copied from flutter_tts/analysis_options.yaml.
2+
3+
analyzer:
4+
strong-mode:
5+
implicit-casts: false
6+
errors:
7+
unused_import: error
8+
unused_local_variable: error
9+
dead_code: error
10+
linter:
11+
rules:
12+
- avoid_empty_else
13+
- comment_references
14+
- control_flow_in_finally
15+
- empty_statements
16+
- hash_and_equals
17+
- only_throw_errors
18+
- test_types_in_equals
19+
- throw_in_finally
20+
- unrelated_type_equality_checks
21+
- valid_regexps
22+
- avoid_init_to_null
23+
- avoid_return_types_on_setters
24+
- await_only_futures
25+
- camel_case_types
26+
- directives_ordering
27+
- empty_catches
28+
- empty_constructor_bodies
29+
- library_names
30+
- library_prefixes
31+
- non_constant_identifier_names
32+
- omit_local_variable_types
33+
- prefer_final_fields
34+
- prefer_is_not_empty
35+
- prefer_typing_uninitialized_variables
36+
- slash_for_doc_comments
37+
- type_init_formals
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: ../../analysis_options_legacy.yaml

0 commit comments

Comments
 (0)