-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathanalysis_options.yaml
More file actions
95 lines (90 loc) · 3.98 KB
/
Copy pathanalysis_options.yaml
File metadata and controls
95 lines (90 loc) · 3.98 KB
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
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
analyzer:
language:
# 禁止隐式 cast / 动态调用,尽早暴露类型问题。
strict-casts: true
# 禁止隐式 raw 类型(如使用 List 而非 List<String>)。
strict-raw-types: true
linter:
# The lint rules applied to this project can be customized in the
# section below to disable a lint rule included above or to enable
# additional rules. A list of all available lints and their documentation
# is published at https://dart.dev/lints.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# ── 正确性 / 常见 Bug ────────────────────────────────────────────
- avoid_print # 生产代码禁用 print(当前 lib/ 零调用,验证过)
- avoid_unnecessary_containers
- avoid_web_libraries_in_flutter
- no_logic_in_create_state
- prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- sized_box_for_whitespace
- sort_child_properties_last
- use_build_context_synchronously # 异步后使用 BuildContext 须检查 mounted
- use_full_hex_values_for_flutter_colors
# ── 风格一致性 ──────────────────────────────────────────────────
- always_declare_return_types
- annotate_overrides
- avoid_dynamic_calls # 动态调用易掩盖类型错误
- avoid_function_literals_in_foreach_calls
- avoid_redundant_argument_values
- avoid_slow_async_io
- avoid_type_to_string
- cancel_subscriptions # 订阅不取消会泄漏
# TODO(体检⑧ 第二批): 现存 127 处,多涉及 UI builder 链式赋值,需人工逐处改写。
# - cascade_invocations
- conditional_uri_does_not_exist
# TODO(体检⑧ 第二批): 现存 195 处,多为 UI 回调 fire-and-forget 语义,
# 需逐处判断 unawaited() 包裹或 await,机械修改风险大。
# - discarded_futures
- join_return_with_assignment
- literal_only_boolean_expressions
- no_adjacent_strings_in_list
- only_throw_errors
- prefer_final_in_for_each
- prefer_final_locals
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_int_literals
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_null_aware_method_calls
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- provide_deprecation_message
- test_types_in_equals
- throw_in_finally
- type_literal_in_constant_pattern
- unnecessary_await_in_return
- unnecessary_lambdas
- unnecessary_late
- unnecessary_null_aware_assignments
- unnecessary_null_checks
- unnecessary_overrides
- unnecessary_parenthesis
- unnecessary_statements
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- use_string_in_part_of_directives
- valid_regexps
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options