Skip to content

Commit 0753342

Browse files
authored
refactor: update to use flutter default analysis (#114)
1 parent f368088 commit 0753342

File tree

6 files changed

+82
-206
lines changed

6 files changed

+82
-206
lines changed

analysis_options.yaml

Lines changed: 23 additions & 170 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,28 @@
1-
# ~ Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2-
# ~ for details. All rights reserved. Use of this source code is governed by a
3-
# ~ BSD-style license that can be found in the LICENSE file.
4-
# ~
5-
# ~ A living list of rules following the Effective Dart guide.
6-
# ~ https://www.dartlang.org/guides/language/effective-dart
7-
# ~
8-
# ~ Note: not everything suggested in the guide has a rule associated with it.
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
97

10-
analyzer:
11-
#strong-mode:
12-
#implicit-casts: false
13-
#implicit-dynamic: false
14-
errors:
15-
todo: ignore
16-
#exclude:
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
1711

18-
# ~ Effective dart lint rules form https://github.com/dart-lang/linter
19-
# ~ We have implemented all but lines_longer_than_80_chars & public_member_api_docs
2012
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
2123
rules:
22-
# ~ --- STYLE
23-
# ~ identifiers
24-
- camel_case_types
25-
- library_names
26-
- file_names
27-
- library_prefixes
28-
- non_constant_identifier_names
29-
- constant_identifier_names # ~ prefer
30-
# ~ ordering
31-
- directives_ordering
32-
# ~ formating
33-
- curly_braces_in_flow_control_structures
34-
# ~ --- DOCUMENTATION
35-
# ~ comments
36-
# ~ doc comments
37-
- slash_for_doc_comments
38-
- package_api_docs # ~ prefer
39-
- comment_references
40-
# ~ markdown
41-
# ~ writing
42-
# ~ --- USAGE
43-
# ~ libraries
44-
- implementation_imports
45-
- avoid_relative_lib_imports
46-
# ~ strings
47-
- prefer_adjacent_string_concatenation
48-
- prefer_interpolation_to_compose_strings # ~ prefer
49-
- unnecessary_brace_in_string_interps # ~ avoid
50-
# ~ collections
51-
- prefer_collection_literals
52-
- avoid_function_literals_in_foreach_calls # ~ avoid
53-
- prefer_iterable_whereType
54-
# ~ functions
55-
- prefer_function_declarations_over_variables
56-
- unnecessary_lambdas
57-
# ~ variables
58-
- avoid_init_to_null
59-
# ~ members
60-
- unnecessary_getters_setters
61-
- prefer_final_fields
62-
- prefer_expression_function_bodies # consider
63-
- unnecessary_this
64-
- prefer_typing_uninitialized_variables
65-
# ~ constructors
66-
- prefer_initializing_formals
67-
- type_init_formals
68-
- empty_constructor_bodies
69-
- unnecessary_new
70-
- unnecessary_const
71-
# ~ error handling
72-
- avoid_catches_without_on_clauses # ~ avoid
73-
- use_rethrow_when_possible
74-
# ~ asynchrony
75-
# ~ --- DESIGN
76-
# ~ names
77-
- use_to_and_as_if_applicable
78-
# ~ libraries
79-
# ~ classes
80-
- one_member_abstracts # ~ avoid
81-
- avoid_classes_with_only_static_members # ~ avoid
82-
# ~ constructors
83-
- prefer_constructors_over_static_methods
84-
# ~ members
85-
- use_setters_to_change_properties
86-
- avoid_setters_without_getters
87-
- avoid_returning_this # ~ avoid
88-
# ~ types
89-
- type_annotate_public_apis # ~ prefer
90-
- omit_local_variable_types # ~ avoid
91-
- avoid_types_on_closure_parameters # ~ avoid
92-
- avoid_return_types_on_setters
93-
- prefer_generic_function_type_aliases
94-
- avoid_private_typedef_functions # ~ prefer
95-
# ~ parameters
96-
- avoid_positional_boolean_parameters # ~ avoid
97-
# ~ equality
98-
- hash_and_equals
99-
- avoid_null_checks_in_equality_operators
100-
101-
# ~ Rules that are not used but are recommended by effective dart:
102-
#
103-
# - public_member_api_docs # ~ We don't have time to document everything yet
104-
# - lines_longer_than_80_chars # prefer # ~ Doesn't seem reasonable
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
10526

106-
# ~ Rules that are not used
107-
# - always_declare_return_types
108-
# - always_put_control_body_on_new_line
109-
# - always_put_required_named_parameters_first
110-
# - always_require_non_null_named_parameters
111-
# - always_specify_types
112-
# - annotate_overrides
113-
# - avoid_annotating_with_dynamic
114-
# - avoid_as
115-
# - avoid_bool_literals_in_conditional_expressions
116-
# - avoid_catching_errors
117-
# - avoid_double_and_int_checks
118-
# - avoid_empty_else
119-
# - avoid_field_initializers_in_const_classes
120-
# - avoid_js_rounded_ints
121-
# - avoid_renaming_method_parameters
122-
# - avoid_single_cascade_in_expression_statements
123-
# - avoid_slow_async_io
124-
# - avoid_types_as_parameter_names
125-
# - avoid_unused_constructor_parameters
126-
# - await_only_futures
127-
# - cancel_subscriptions
128-
# - cascade_invocations
129-
# - close_sinks
130-
# - control_flow_in_finally
131-
# - empty_catches
132-
# - empty_statements
133-
# - invariant_booleans
134-
# - iterable_contains_unrelated_type
135-
# - join_return_with_assignment
136-
# - list_remove_unrelated_type
137-
# - literal_only_boolean_expressions
138-
# - no_adjacent_strings_in_list
139-
# - no_duplicate_case_values
140-
# - null_closures
141-
# - only_throw_errors
142-
# - overridden_fields
143-
# - package_names
144-
# - package_prefixed_library_names
145-
# - parameter_assignments
146-
# - prefer_asserts_in_initializer_lists
147-
# - prefer_bool_in_asserts
148-
# - prefer_conditional_assignment
149-
# - prefer_const_constructors
150-
# - prefer_const_constructors_in_immutables
151-
# - prefer_const_declarations
152-
# - prefer_const_literals_to_create_immutables
153-
# - prefer_contains
154-
# - prefer_expression_function_bodies
155-
# - prefer_final_locals
156-
# - prefer_foreach
157-
# - prefer_is_empty
158-
# - prefer_is_not_empty
159-
# - prefer_single_quotes
160-
# - recursive_getters
161-
# - sort_constructors_first
162-
# - sort_unnamed_constructors_first
163-
# - super_goes_last
164-
# - test_types_in_equals
165-
# - throw_in_finally
166-
# - unawaited_futures
167-
# - unnecessary_null_aware_assignments
168-
# - unnecessary_null_in_if_null_operators
169-
# - unnecessary_overrides
170-
# - unnecessary_parenthesis
171-
# - unnecessary_statements
172-
# - unrelated_type_equality_checks
173-
# - use_string_buffers
174-
# - valid_regexps
175-
# - void_checks
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ packages:
6868
path: ".."
6969
relative: true
7070
source: path
71-
version: "6.0.0"
71+
version: "5.1.0"
7272
flutter_lints:
7373
dependency: "direct dev"
7474
description:

lib/src/dotenv.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class DotEnv {
102102
} else if (['false', '0'].contains(value.toLowerCase())) {
103103
return false;
104104
} else {
105-
throw FormatException('Could not parse as a bool');
105+
throw const FormatException('Could not parse as a bool');
106106
}
107107
}
108108

pubspec.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@ packages:
5454
description: flutter
5555
source: sdk
5656
version: "0.0.0"
57+
flutter_lints:
58+
dependency: "direct dev"
59+
description:
60+
name: flutter_lints
61+
sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
62+
url: "https://pub.dev"
63+
source: hosted
64+
version: "4.0.0"
5765
flutter_test:
5866
dependency: "direct dev"
5967
description: flutter
@@ -83,6 +91,14 @@ packages:
8391
url: "https://pub.dev"
8492
source: hosted
8593
version: "3.0.1"
94+
lints:
95+
dependency: transitive
96+
description:
97+
name: lints
98+
sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
99+
url: "https://pub.dev"
100+
source: hosted
101+
version: "4.0.0"
86102
matcher:
87103
dependency: transitive
88104
description:

pubspec.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ dependencies:
1111
dev_dependencies:
1212
flutter_test:
1313
sdk: flutter
14+
15+
# The "flutter_lints" package below contains a set of recommended lints to
16+
# encourage good coding practices. The lint set provided by the package is
17+
# activated in the `analysis_options.yaml` file located at the root of your
18+
# package. See that file for information about deactivating specific lint
19+
# rules and activating additional ones.
20+
flutter_lints: ^4.0.0

0 commit comments

Comments
 (0)