-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathanalysis_options.yaml
255 lines (190 loc) · 8.18 KB
/
analysis_options.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
include: package:flutter_lints/flutter.yaml
analyzer:
plugins:
- dart_code_metrics
dart_code_metrics:
metrics:
cyclomatic-complexity: 20
number-of-parameters: 4
maximum-nesting: 5
metrics-exclude:
- test/**
rules:
- avoid-unused-parameters
- avoid-wrapping-in-padding
- binary-expression-operand-order
- double-literal-format
- newline-before-return
- no-boolean-literal-compare
- no-equal-then-else
- no-object-declaration
- prefer-trailing-comma
linter:
rules:
# Prevents accidental return type changes which results in a breaking API
# change. Enforcing return type makes API changes visible in a diff.
always_declare_return_types: true
# Don't put the statement part of an if, for, while, do on the same line as
# the expression, even if it is short. Doing so makes it unclear that there
# is relevant code there. This is especially important for early returns.
always_put_control_body_on_new_line: true
# This practice improves code readability and helps protect against unintentionally
# overriding superclass members.
annotate_overrides: true
# Highlights boolean expressions which can be simplified
avoid_bool_literals_in_conditional_expressions: true
# Errors aren't for catching but to prevent prior to runtime
avoid_catching_errors: true
# Can usually be replaced with an extension
avoid_classes_with_only_static_members: true
# Only useful when targeting JS. Kept in case it comes into play with
# Flutter Web.
avoid_double_and_int_checks: true
# Do not use empty else statements.
avoid_empty_else: true
# Use different quotes instead of escaping
avoid_escaping_inner_quotes: true
# Prevents unnecessary allocation of a field
avoid_field_initializers_in_const_classes: true
# When using implements, you do not inherit the method body of ==, making
# it nearly impossible to follow the contract of ==.
avoid_implementing_value_types: true
# Good APIs don't use ambiguous boolean parameters. Instead use named
# parameters
avoid_positional_boolean_parameters: true
# Do not use 'print' in production code.
avoid_print: true
# Always prefer function references over typedefs.
# Jumping twice in code to see the signature of a lambda sucks.
# This is different from the flutter analysis_options
avoid_private_typedef_functions: true
# Don't explicitly set defaults
avoid_redundant_argument_values: true
# Don't use `Future?`, therefore never return null instead of a Future.
avoid_returning_null_for_future: true
# Prevents logical inconsistencies. It's good practice to define getters for
# all existing setters.
avoid_setters_without_getters: true
# Do not use the following asynchronous file I/O methods because they are
# much slower than their synchronous counterparts.
#
# - Directory.exists
# - Directory.stat
# - File.lastModified
# - File.exists
# - File.stat
# - FileSystemEntity.isDirectory
# - FileSystemEntity.isFile
# - FileSystemEntity.isLink
# - FileSystemEntity.type
avoid_slow_async_io: true
# Avoid calls to '.toString()' in production code, since it does not
# contractually return the user-defined name of the Type. Prefer the
# 'is' operator to check the type.
avoid_type_to_string: true
# Unused parameters should be removed
avoid_unused_constructor_parameters: true
# For async functions use `Future<void>` as return value, not `void`
# This allows usage of the await keyword and prevents operations from
# running in parallel.
avoid_void_async: true
# Prevents leaks and code executing after their lifecycle.
cancel_subscriptions: true
# Follows dart style. Fully supported by IDEs and no manual effort for a
# consistent style
directives_ordering: true
# String.fromEnvironment looks up env variables at compile time. The
# variable is baked in by the compiler and can't be changed by environment
# variables.
do_not_use_environment: true
# Although there are some false positives, this lint generally catches
# unnecessary checks.
invariant_booleans: true
# Hint to join return and assignment
join_return_with_assignment: true
# Good for libraries to prevent unnecessary code paths.
# False positives may occur for applications when boolean properties are
# generated by external programs producing auto-generated source code
#
# Known issue: while(true) loops https://github.com/dart-lang/linter/issues/453
literal_only_boolean_expressions: true
# Don't forget the whitespaces at the end
missing_whitespace_between_adjacent_strings: true
# Concat Strings obviously with `+` inside a list.
no_adjacent_strings_in_list: true
# calling `runtimeType` may be a performance problem
no_runtimeType_toString: true
# Defining interfaces (abstract classes), with only one method, makes sense
# architecture wise.
# Discussion: https://github.com/passsy/dart-lint/issues/2
one_member_abstracts: true
# Only relevant for packages, not applications or general dart code
package_api_docs: true
# Most likely a mistake, if not: bad practice
parameter_assignments: true
# Makes it easier to migrate to const constructors and to have final fields
prefer_asserts_in_initializer_lists: true
# Assertions blocks don't require a message because they throw simple to
# understand errors
prefer_asserts_with_message: true
# Dart has named constructors. Static methods in other languages (java) are
# a workaround which don't have named constructors.
prefer_constructors_over_static_methods: true
# Helps avoid accidental reassignments and allows the compiler to do
# optimizations.
prefer_final_in_for_each: true
# Helps avoid accidental reassignments and allows the compiler to do
# optimizations.
prefer_final_locals: true
# Dense code isn't necessarily better code. But it's nice.
prefer_foreach: true
# Allows potential usage of const
prefer_if_elements_to_conditional_expressions: true
# Interpolate, use less "", '' and +
prefer_interpolation_to_compose_strings: true
# Use whatever makes you happy. noexcuse doesn't define a style
prefer_single_quotes: true
# Definitely not a rule for standard dart code. Maybe relevant for packages
# It's relevant here.
public_member_api_docs: false # true
# Hints accidental recursions
recursive_getters: true
# Flutter only, always put child last
sort_child_properties_last: true
# Any sorting is better than no sorting
sort_pub_dependencies: true
# Default constructor comes first
sort_unnamed_constructors_first: true
# First test, then cast
test_types_in_equals: true
# Hard to debug and bad style
throw_in_finally: true
# Type annotations make the compiler intelligent, use them
type_annotate_public_apis: true
# Remove async/await clutter when not required
unnecessary_await_in_return: true
# Do not create lambdas when a tear-off will do.
unnecessary_lambdas: true
# Don't assign `null` when value is already `null`
unnecessary_null_aware_assignments: true
# If a variable doesn't change and is initialized, no need to define it as nullable
unnecessary_nullable_for_final_variable_declarations: true
# Remove clutter where possible
unnecessary_parenthesis: true
# Use raw string only when needed
unnecessary_raw_strings: true
# Avoid magic overloads of + operators
unnecessary_statements: true
# Web only
unsafe_html: true
# The use of intValue.isOdd/isEven to check for evenness.
use_is_even_rather_than_modulo: true
# Still unsure if `late` is always better than `!` (NNBD)
use_late_for_private_fields_and_variables: true
# Use the setter syntax
use_setters_to_change_properties: true
# In most cases, using a string buffer is preferred for composing strings
# due to its improved performance
use_string_buffers: true
# A raw string can be used to avoid escaping only backslashes and dollars.
use_raw_strings: true