Skip to content

Commit f31b997

Browse files
author
Michael Klimushyn
authored
[all] Switch to pedantic analysis rules (flutter#2300)
Switches our out of date fork of Flutter's analysis rules to the pedantic package. In order to make this an easy change to initially land and then incrementally enable, any existing non-trivial lints have just been ignored within their respective packages instead of being fixed. Also adds a global lint for missing public DartDocs. Like the pedantic lints, this is ignored in packages that are already failing it.
1 parent 4ace778 commit f31b997

File tree

33 files changed

+225
-238
lines changed

33 files changed

+225
-238
lines changed

analysis_options.yaml

+5-134
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,9 @@
1-
# Specify analysis options.
2-
#
3-
# Until there are meta linter rules, each desired lint must be explicitly enabled.
4-
# See: https://github.com/dart-lang/linter/issues/288
5-
#
6-
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
7-
# See the configuration guide for more
8-
# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
9-
#
10-
# NOTE: Please keep this file in sync with
11-
# https://github.com/flutter/flutter/blob/master/analysis_options.yaml
12-
1+
include: package:pedantic/analysis_options.yaml
132
analyzer:
14-
language:
15-
strict-inference: true
16-
strict-raw-types: true
17-
strong-mode:
18-
implicit-dynamic: false
19-
errors:
20-
# treat missing required parameters as a warning (not a hint)
21-
missing_required_param: warning
22-
# treat missing returns as a warning (not a hint)
23-
missing_return: warning
24-
# allow having TODOs in the code
25-
todo: ignore
263
exclude:
27-
- 'bin/cache/**'
28-
# the following two are relative to the stocks example and the flutter package respectively
29-
# see https://github.com/dart-lang/sdk/issues/28463
30-
- 'lib/i18n/stock_messages_*.dart'
31-
- 'lib/src/http/**'
32-
4+
# Ignore generated files
5+
- '**/*.g.dart'
6+
- 'lib/src/generated/*.dart'
337
linter:
348
rules:
35-
# these rules are documented on and in the same order as
36-
# the Dart Lint rules page to make maintenance easier
37-
# http://dart-lang.github.io/linter/lints/
38-
39-
# === error rules ===
40-
- avoid_empty_else
41-
- avoid_slow_async_io
42-
- cancel_subscriptions
43-
# - close_sinks # https://github.com/flutter/flutter/issues/5789
44-
# - comment_references # blocked on https://github.com/dart-lang/dartdoc/issues/1153
45-
- control_flow_in_finally
46-
- empty_statements
47-
- hash_and_equals
48-
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790
49-
- iterable_contains_unrelated_type
50-
- list_remove_unrelated_type
51-
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
52-
- no_adjacent_strings_in_list
53-
- no_duplicate_case_values
54-
- test_types_in_equals
55-
- throw_in_finally
56-
- unrelated_type_equality_checks
57-
- valid_regexps
58-
59-
# === style rules ===
60-
- always_declare_return_types
61-
# - always_put_control_body_on_new_line
62-
- always_require_non_null_named_parameters
63-
- always_specify_types
64-
- annotate_overrides
65-
# - avoid_annotating_with_dynamic # not yet tested
66-
- avoid_as
67-
# - avoid_catches_without_on_clauses # not yet tested
68-
# - avoid_catching_errors # not yet tested
69-
# - avoid_classes_with_only_static_members # not yet tested
70-
# - avoid_function_literals_in_foreach_calls # not yet tested
71-
- avoid_init_to_null
72-
- avoid_null_checks_in_equality_operators
73-
# - avoid_positional_boolean_parameters # not yet tested
74-
- avoid_return_types_on_setters
75-
# - avoid_returning_null # not yet tested
76-
# - avoid_returning_this # not yet tested
77-
# - avoid_setters_without_getters # not yet tested
78-
# - avoid_types_on_closure_parameters # not yet tested
79-
- await_only_futures
80-
- camel_case_types
81-
# - cascade_invocations # not yet tested
82-
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
83-
- directives_ordering
84-
- empty_catches
85-
- empty_constructor_bodies
86-
- implementation_imports
87-
# - join_return_with_assignment # not yet tested
88-
- library_names
89-
- library_prefixes
90-
- non_constant_identifier_names
91-
# - omit_local_variable_types # opposite of always_specify_types
92-
# - one_member_abstracts # too many false positives
93-
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792
94-
- overridden_fields
95-
- package_api_docs
96-
- package_prefixed_library_names
97-
# - parameter_assignments # we do this commonly
98-
- prefer_adjacent_string_concatenation
99-
- prefer_collection_literals
100-
# - prefer_conditional_assignment # not yet tested
101-
- prefer_const_constructors
102-
# - prefer_constructors_over_static_methods # not yet tested
103-
- prefer_contains
104-
- prefer_equal_for_default_values
105-
# - prefer_expression_function_bodies # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
106-
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
107-
- prefer_final_locals
108-
# - prefer_foreach # not yet tested
109-
# - prefer_function_declarations_over_variables # not yet tested
110-
- prefer_initializing_formals
111-
# - prefer_interpolation_to_compose_strings # not yet tested
112-
- prefer_is_empty
113-
- prefer_is_not_empty
114-
- prefer_void_to_null
115-
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
116-
- slash_for_doc_comments
117-
- sort_constructors_first
118-
- sort_unnamed_constructors_first
119-
# - type_annotate_public_apis # subset of always_specify_types
120-
- type_init_formals
121-
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793
122-
- unnecessary_brace_in_string_interps
123-
- unnecessary_const
124-
- unnecessary_getters_setters
125-
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
126-
- unnecessary_new
127-
- unnecessary_null_aware_assignments
128-
- unnecessary_null_in_if_null_operators
129-
# - unnecessary_overrides # https://github.com/dart-lang/linter/issues/626 and https://github.com/dart-lang/linter/issues/627
130-
- unnecessary_statements
131-
- unnecessary_this
132-
- use_rethrow_when_possible
133-
# - use_setters_to_change_properties # not yet tested
134-
# - use_string_buffers # https://github.com/dart-lang/linter/pull/664
135-
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
136-
137-
# === pub rules ===
138-
- package_names
9+
- public_member_api_docs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# This exists to add a lint for missing API docs just on this specific package,
2-
# since not all packages have coverage for all their public members yet and
3-
# adding it in would be non-trivial. `public_member_api_docs` should be applied
4-
# to new packages going forward, and ideally the main `analysis_options.yaml`
5-
# file as soon as possible.
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.
65

76
include: ../../analysis_options.yaml
87

9-
linter:
10-
rules:
11-
- public_member_api_docs
8+
analyzer:
9+
errors:
10+
avoid_relative_lib_imports: ignore
11+
unawaited_futures: ignore
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore

packages/camera/analysis_options.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore
+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# This exists to add a lint for missing API docs just on this specific package,
2-
# since not all packages have coverage for all their public members yet and
3-
# adding it in would be non-trivial. `public_member_api_docs` should be applied
4-
# to new packages going forward, and ideally the main `analysis_options.yaml`
5-
# file as soon as possible.
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.
65

76
include: ../../analysis_options.yaml
87

9-
linter:
10-
rules:
11-
- public_member_api_docs
8+
analyzer:
9+
errors:
10+
unawaited_futures: ignore
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore

packages/e2e/analysis_options.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore

packages/flutter_plugin_android_lifecycle/example/lib/main.dart

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore_for_file: public_member_api_docs
2+
13
import 'package:flutter/material.dart';
24

35
void main() => runApp(MyApp());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
# Exclude auto-generated files from analysis/linting
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
7+
28
analyzer:
3-
exclude:
4-
- "lib/src/generated/**"
5-
9+
errors:
10+
public_member_api_docs: ignore
11+
unused_element: ignore
12+
unawaited_futures: ignore

packages/image_picker/analysis_options.yaml

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
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
7+
18
analyzer:
2-
exclude:
3-
- lib/**/*.g.dart # Ignore generated files
9+
errors:
10+
avoid_init_to_null: ignore
11+
prefer_is_empty: ignore
12+
prefer_is_not_empty: ignore
13+
public_member_api_docs: ignore
14+
type_init_formals: ignore
15+
unnecessary_new: ignore
16+
unawaited_futures: ignore

packages/local_auth/example/lib/main.dart

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright 2017 The Chromium Authors. All rights reserved.
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
4+
5+
// ignore_for_file: public_member_api_docs
6+
47
import 'dart:async';
58

69
import 'package:flutter/material.dart';

packages/local_auth/lib/auth_strings.dart

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// This is a temporary ignore to allow us to land a new set of linter rules in a
6+
// series of manageable patches instead of one gigantic PR. It disables some of
7+
// the new lints that are already failing on this plugin, for this plugin. It
8+
// should be deleted and the failing lints addressed as soon as possible.
9+
// ignore_for_file: public_member_api_docs
10+
511
import 'package:intl/intl.dart';
612

713
/// Android side authentication messages.

packages/local_auth/lib/local_auth.dart

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
// This is a temporary ignore to allow us to land a new set of linter rules in a
6+
// series of manageable patches instead of one gigantic PR. It disables some of
7+
// the new lints that are already failing on this plugin, for this plugin. It
8+
// should be deleted and the failing lints addressed as soon as possible.
9+
// ignore_for_file: public_member_api_docs
10+
511
import 'dart:async';
612

713
import 'package:flutter/services.dart';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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
7+
8+
analyzer:
9+
errors:
10+
public_member_api_docs: ignore
11+
unawaited_futures: ignore

packages/path_provider/analysis_options.yaml

-11
This file was deleted.

0 commit comments

Comments
 (0)