Skip to content

Commit 027d807

Browse files
authored
chore: enable lints for firebase_dynamic_links (#5256)
1 parent a2de9eb commit 027d807

File tree

8 files changed

+305
-29
lines changed

8 files changed

+305
-29
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
2+
# Copyright 2021 The Chromium Authors. All rights reserved.
3+
# Use of this source code is governed by a BSD-style license that can be
4+
# in the LICENSE file.
5+
6+
linter:
7+
rules:
8+
- always_declare_return_types
9+
- always_put_control_body_on_new_line
10+
- always_put_required_named_parameters_first
11+
- always_require_non_null_named_parameters
12+
- always_specify_types
13+
- always_use_package_imports
14+
- annotate_overrides
15+
- avoid_annotating_with_dynamic
16+
- avoid_as
17+
- avoid_bool_literals_in_conditional_expressions
18+
- avoid_catches_without_on_clauses
19+
- avoid_catching_errors
20+
- avoid_classes_with_only_static_members
21+
- avoid_double_and_int_checks
22+
- avoid_empty_else
23+
- avoid_equals_and_hash_code_on_mutable_classes
24+
- avoid_escaping_inner_quotes
25+
- avoid_field_initializers_in_const_classes
26+
- avoid_function_literals_in_foreach_calls
27+
- avoid_implementing_value_types
28+
- avoid_init_to_null
29+
- avoid_js_rounded_ints
30+
- avoid_null_checks_in_equality_operators
31+
- avoid_positional_boolean_parameters
32+
- avoid_print
33+
- avoid_private_typedef_functions
34+
- avoid_redundant_argument_values
35+
- avoid_relative_lib_imports
36+
- avoid_renaming_method_parameters
37+
- avoid_return_types_on_setters
38+
- avoid_returning_null
39+
- avoid_returning_null_for_future
40+
- avoid_returning_null_for_void
41+
- avoid_returning_this
42+
- avoid_setters_without_getters
43+
- avoid_shadowing_type_parameters
44+
- avoid_single_cascade_in_expression_statements
45+
- avoid_slow_async_io
46+
- avoid_type_to_string
47+
- avoid_types_as_parameter_names
48+
- avoid_types_on_closure_parameters
49+
- avoid_unnecessary_containers
50+
- avoid_unused_constructor_parameters
51+
- avoid_void_async
52+
- avoid_web_libraries_in_flutter
53+
- await_only_futures
54+
- camel_case_extensions
55+
- camel_case_types
56+
- cancel_subscriptions
57+
- cascade_invocations
58+
- cast_nullable_to_non_nullable
59+
- close_sinks
60+
- comment_references
61+
- constant_identifier_names
62+
- control_flow_in_finally
63+
- curly_braces_in_flow_control_structures
64+
- diagnostic_describe_all_properties
65+
- directives_ordering
66+
- do_not_use_environment
67+
- empty_catches
68+
- empty_constructor_bodies
69+
- empty_statements
70+
- exhaustive_cases
71+
- file_names
72+
- flutter_style_todos
73+
- hash_and_equals
74+
- implementation_imports
75+
- invariant_booleans
76+
- iterable_contains_unrelated_type
77+
- join_return_with_assignment
78+
- leading_newlines_in_multiline_strings
79+
- library_names
80+
- library_prefixes
81+
- lines_longer_than_80_chars
82+
- list_remove_unrelated_type
83+
- literal_only_boolean_expressions
84+
- missing_whitespace_between_adjacent_strings
85+
- no_adjacent_strings_in_list
86+
- no_default_cases
87+
- no_duplicate_case_values
88+
- no_logic_in_create_state
89+
- no_runtimeType_toString
90+
- non_constant_identifier_names
91+
- null_check_on_nullable_type_parameter
92+
- null_closures
93+
- omit_local_variable_types
94+
- one_member_abstracts
95+
- only_throw_errors
96+
- overridden_fields
97+
- package_api_docs
98+
- package_names
99+
- package_prefixed_library_names
100+
- parameter_assignments
101+
- prefer_adjacent_string_concatenation
102+
- prefer_asserts_in_initializer_lists
103+
- prefer_asserts_with_message
104+
- prefer_collection_literals
105+
- prefer_conditional_assignment
106+
- prefer_const_constructors
107+
- prefer_const_constructors_in_immutables
108+
- prefer_const_declarations
109+
- prefer_const_literals_to_create_immutables
110+
- prefer_constructors_over_static_methods
111+
- prefer_contains
112+
- prefer_double_quotes
113+
- prefer_equal_for_default_values
114+
- prefer_expression_function_bodies
115+
- prefer_final_fields
116+
- prefer_final_in_for_each
117+
- prefer_final_locals
118+
- prefer_for_elements_to_map_fromIterable
119+
- prefer_foreach
120+
- prefer_function_declarations_over_variables
121+
- prefer_generic_function_type_aliases
122+
- prefer_if_elements_to_conditional_expressions
123+
- prefer_if_null_operators
124+
- prefer_initializing_formals
125+
- prefer_inlined_adds
126+
- prefer_int_literals
127+
- prefer_interpolation_to_compose_strings
128+
- prefer_is_empty
129+
- prefer_is_not_empty
130+
- prefer_is_not_operator
131+
- prefer_iterable_whereType
132+
- prefer_mixin
133+
- prefer_null_aware_operators
134+
- prefer_relative_imports
135+
- prefer_single_quotes
136+
- prefer_spread_collections
137+
- prefer_typing_uninitialized_variables
138+
- prefer_void_to_null
139+
- provide_deprecation_message
140+
- public_member_api_docs
141+
- recursive_getters
142+
- sized_box_for_whitespace
143+
- slash_for_doc_comments
144+
- sort_child_properties_last
145+
- sort_constructors_first
146+
- sort_pub_dependencies
147+
- sort_unnamed_constructors_first
148+
- test_types_in_equals
149+
- throw_in_finally
150+
- tighten_type_of_initializing_formals
151+
- type_annotate_public_apis
152+
- type_init_formals
153+
- unawaited_futures
154+
- unnecessary_await_in_return
155+
- unnecessary_brace_in_string_interps
156+
- unnecessary_const
157+
- unnecessary_final
158+
- unnecessary_getters_setters
159+
- unnecessary_lambdas
160+
- unnecessary_new
161+
- unnecessary_null_aware_assignments
162+
- unnecessary_null_checks
163+
- unnecessary_null_in_if_null_operators
164+
- unnecessary_nullable_for_final_variable_declarations
165+
- unnecessary_overrides
166+
- unnecessary_parenthesis
167+
- unnecessary_raw_strings
168+
- unnecessary_statements
169+
- unnecessary_string_escapes
170+
- unnecessary_string_interpolations
171+
- unnecessary_this
172+
- unrelated_type_equality_checks
173+
- unsafe_html
174+
- use_full_hex_values_for_flutter_colors
175+
- use_function_type_syntax_for_parameters
176+
- use_is_even_rather_than_modulo
177+
- use_key_in_widget_constructors
178+
- use_late_for_private_fields_and_variables
179+
- use_raw_strings
180+
- use_rethrow_when_possible
181+
- use_setters_to_change_properties
182+
- use_string_buffers
183+
- use_to_and_as_if_applicable
184+
- valid_regexps
185+
- void_checks
Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,93 @@
1-
# This is a temporary file to allow us to land a new set of linter rules in a
2-
# series of manageable patches instead of one gigantic PR. It disables some of
3-
# the new lints that are already failing on this plugin, for this plugin. It
4-
# should be deleted and the failing lints addressed as soon as possible.
5-
6-
include: ../../analysis_options.yaml
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# in the LICENSE file.
74

5+
include: all_lint_rules.yaml
86
analyzer:
7+
# TODO(rrousselGit): disable implicit-cast/implicit-dynamic
98
errors:
10-
avoid_relative_lib_imports: ignore
11-
public_member_api_docs: ignore
12-
unawaited_futures: ignore
9+
# Otherwise cause the import of all_lint_rules to warn because of some rules conflicts.
10+
# We explicitly enabled even conflicting rules and are fixing the conflict
11+
# in this file
12+
included_file_warning: ignore
13+
14+
linter:
15+
rules:
16+
## Disabled rules because the repository doesn't respect them (yet)
17+
18+
always_put_control_body_on_new_line: false
19+
comment_references: false
20+
prefer_constructors_over_static_methods: false
21+
prefer_final_fields: false
22+
prefer_final_locals: false
23+
omit_local_variable_types: false
24+
avoid_equals_and_hash_code_on_mutable_classes: false
25+
public_member_api_docs: false
26+
27+
#############
28+
29+
# Personal preference. I don't find it more readable
30+
cascade_invocations: false
31+
32+
# Conflicts with `prefer_single_quotes`
33+
# Single quotes are easier to type and don't compromise on readability.
34+
prefer_double_quotes: false
35+
36+
# Conflicts with `omit_local_variable_types` and other rules.
37+
# As per Dart guidelines, we want to avoid unnecessary types to make the code
38+
# more readable.
39+
# See https://dart.dev/guides/language/effective-dart/design#avoid-type-annotating-initialized-local-variables
40+
always_specify_types: false
41+
42+
# Incompatible with `prefer_final_locals`
43+
# Having immutable local variables makes larger functions more predictible
44+
# so we will use `prefer_final_locals` instead.
45+
unnecessary_final: false
46+
47+
# Not quite suitable for Flutter, which may have a `build` method with a single
48+
# return, but that return is still complex enough that a "body" is worth it.
49+
prefer_expression_function_bodies: false
50+
51+
# Conflicts with the convention used by flutter, which puts `Key key`
52+
# and `@required Widget child` last.
53+
always_put_required_named_parameters_first: false
54+
55+
# `as` is not that bad (especially with the upcoming non-nullable types).
56+
# Explicit exceptions is better than implicit exceptions.
57+
avoid_as: false
58+
59+
# This project doesn't use Flutter-style todos
60+
flutter_style_todos: false
61+
62+
# There are situations where we voluntarily want to catch everything,
63+
# especially as a library.
64+
avoid_catches_without_on_clauses: false
65+
66+
# Boring as it sometimes force a line of 81 characters to be split in two.
67+
# As long as we try to respect that 80 characters limit, going slightly
68+
# above is fine.
69+
lines_longer_than_80_chars: false
70+
71+
# Conflicts with disabling `implicit-dynamic`
72+
avoid_annotating_with_dynamic: false
73+
74+
# conflicts with `prefer_relative_imports`
75+
always_use_package_imports: false
76+
77+
# Disabled for now until we have NNBD as it otherwise conflicts with `missing_return`
78+
no_default_cases: false
79+
80+
# False positive, null checks don't need a message
81+
prefer_asserts_with_message: false
82+
83+
# Cumbersome with `context.select`
84+
avoid_types_on_closure_parameters: false
85+
86+
# Too many false positive (builders)
87+
diagnostic_describe_all_properties: false
88+
89+
# false positives (setter-like functions)
90+
avoid_positional_boolean_parameters: false
91+
92+
# Does not apply to providers
93+
prefer_const_constructors_in_immutables: false
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2021 The Chromium Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# in the LICENSE file.
4+
include: ../analysis_options.yaml
5+
linter:
6+
rules:
7+
public_member_api_docs: false
8+
avoid_print: false

packages/firebase_dynamic_links/example/lib/main.dart

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,24 @@ class _MainScreenState extends State<_MainScreen> {
3030
String _linkMessage;
3131
bool _isCreatingLink = false;
3232
String _testString =
33-
"To test: long press link and then copy and click from a non-browser "
33+
'To test: long press link and then copy and click from a non-browser '
3434
"app. Make sure this isn't being tested on iOS simulator and iOS xcode "
35-
"is properly setup. Look at firebase_dynamic_links/README.md for more "
36-
"details.";
35+
'is properly setup. Look at firebase_dynamic_links/README.md for more '
36+
'details.';
3737

3838
@override
3939
void initState() {
4040
super.initState();
4141
initDynamicLinks();
4242
}
4343

44-
void initDynamicLinks() async {
44+
Future<void> initDynamicLinks() async {
4545
FirebaseDynamicLinks.instance.onLink(
4646
onSuccess: (PendingDynamicLinkData dynamicLink) async {
4747
final Uri deepLink = dynamicLink?.link;
4848

4949
if (deepLink != null) {
50+
// ignore: unawaited_futures
5051
Navigator.pushNamed(context, deepLink.path);
5152
}
5253
}, onError: (OnLinkErrorException e) async {
@@ -59,6 +60,7 @@ class _MainScreenState extends State<_MainScreen> {
5960
final Uri deepLink = data?.link;
6061

6162
if (deepLink != null) {
63+
// ignore: unawaited_futures
6264
Navigator.pushNamed(context, deepLink.path);
6365
}
6466
}
@@ -128,10 +130,6 @@ class _MainScreenState extends State<_MainScreen> {
128130
],
129131
),
130132
InkWell(
131-
child: Text(
132-
_linkMessage ?? '',
133-
style: const TextStyle(color: Colors.blue),
134-
),
135133
onTap: () async {
136134
if (_linkMessage != null) {
137135
await launch(_linkMessage);
@@ -143,6 +141,10 @@ class _MainScreenState extends State<_MainScreen> {
143141
const SnackBar(content: Text('Copied Link!')),
144142
);
145143
},
144+
child: Text(
145+
_linkMessage ?? '',
146+
style: const TextStyle(color: Colors.blue),
147+
),
146148
),
147149
Text(_linkMessage == null ? '' : _testString)
148150
],

packages/firebase_dynamic_links/example/pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ environment:
66
flutter: ">=1.10.0"
77

88
dependencies:
9-
flutter:
10-
sdk: flutter
11-
firebase_dynamic_links:
12-
path: ../
139
firebase_core:
1410
path: ../../firebase_core/firebase_core
11+
firebase_dynamic_links:
12+
path: ../
13+
flutter:
14+
sdk: flutter
1515
url_launcher: ^5.1.6
1616

1717
dependency_overrides:
@@ -23,10 +23,10 @@ dependency_overrides:
2323
path: ../../firebase_core/firebase_core_web
2424

2525
dev_dependencies:
26-
pedantic: ^1.8.0
2726
e2e: ^0.6.1
2827
flutter_driver:
2928
sdk: flutter
29+
pedantic: ^1.8.0
3030

3131
flutter:
3232
uses-material-design: true

0 commit comments

Comments
 (0)