Skip to content

Commit cd96ec7

Browse files
committed
use sw analysis options
1 parent 9edcf76 commit cd96ec7

File tree

1 file changed

+88
-1
lines changed

1 file changed

+88
-1
lines changed

analysis_options.yaml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,91 @@
11
include: package:flutter_lints/flutter.yaml
2+
analyzer:
3+
exclude:
4+
- "**/*.g.dart"
5+
- "**/*.freezed.dart"
6+
- "test/.test_coverage.dart"
7+
- "integrated_test/**"
8+
- "integration_test/**.dart"
9+
- "crypto_plugins/**"
10+
- "bin/cache/**"
11+
- "lib/generated_plugin_registrant.dart"
12+
13+
# For more information see:
14+
# https://dart.dev/guides/language/analysis-options#enabling-additional-type-checks
15+
language:
16+
strict-casts: true
17+
strict-inference: true
18+
strict-raw-types: true
19+
20+
21+
errors:
22+
# Without ignore here, we cause import of all_lint_rules to warn, because some rules conflict.
23+
# We explicitly enabled even conflicting rules and are fixing the conflicts in this file.
24+
# Put it to warning temporarily, if you need troubleshoot lint rule settings.
25+
included_file_warning: ignore
26+
27+
# Treat missing required parameters as an error, not as a hint or a warning.
28+
missing_required_param: error
29+
30+
# Treat missing returns as an error, not as a hint or a warning.
31+
missing_return: error
32+
33+
# Allow self-reference to deprecated members. This is done because otherwise we have
34+
# to annotate every member in every test, assert, etc., when we deprecate something.
35+
deprecated_member_use_from_same_package: ignore
36+
37+
# DON'T assign new values to parameters of methods or functions.
38+
#
39+
# https://dart-lang.github.io/linter/lints/parameter_assignments.html
40+
#
41+
# Treat assigning new values to a parameter as a warning. We would almost like to set this
42+
# to an error. However, this warning rule or even more so if set to an error, can sometimes
43+
# be a bit problematic you include other code directly that does it a lot.
44+
# It does however, make code safer when this cannot be done without involving
45+
# an extra local variable for clarity and safety. Enabling this error, even as just a warning,
46+
# does get in the way a bit if all you want to do is a null to default value release runtime
47+
# safety/fallback assignment. For that use case you have to add a local rule override. With
48+
# null-safety, the need for this kind of null check and re-assignment to default if null,
49+
# is rarely needed. Considering the comment in:
50+
# https://dart-lang.github.io/linter/lints/parameter_assignments.html:
51+
# "Assigning new values to parameters is generally a bad practice unless an operator
52+
# such as ??= is used. Otherwise, arbitrarily reassigning parameters is usually a mistake."
53+
# One might even think the rule would allow using the ??= operator, but it does not. For now,
54+
# we keep this lint as warning and overriding locally with:
55+
#
56+
# When we need it for the ??= operator, or some copy/paste in of some code that does things
57+
# that needs it too, and that we don't want to deal with fixing at the moment.
58+
parameter_assignments: warning
59+
60+
# Allow having TODOs in the code.
61+
todo: ignore
62+
63+
linter:
64+
# The lint rules applied to this project can be customized in the
65+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
66+
# included above or to enable additional rules. A list of all available lints
67+
# and their documentation is published at
68+
# https://dart-lang.github.io/linter/lints/index.html.
69+
#
70+
# Instead of disabling a lint rule for the entire project in the
71+
# section below, it can also be suppressed for a single line of code
72+
# or a specific dart file by using the `// ignore: name_of_lint` and
73+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
74+
# producing the lint.
75+
rules:
76+
prefer_relative_imports: true
77+
avoid_relative_lib_imports: true
78+
no_leading_underscores_for_local_identifiers: false
79+
no_leading_underscores_for_library_prefixes: false
80+
avoid_print: true
81+
unawaited_futures: true
82+
avoid_double_and_int_checks: false
83+
constant_identifier_names: false
84+
prefer_final_locals: true
85+
prefer_final_in_for_each: true
86+
require_trailing_commas: true
87+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
88+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
289

390
# Additional information about this file can be found at
4-
# https://dart.dev/guides/language/analysis-options
91+
# https://dart.dev/guides/language/analysis-options

0 commit comments

Comments
 (0)