This repository has been archived by the owner on Nov 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Update list of enforced lints #81
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ Here is how static analysis is used internally at Google: | |
## Enabled Lints | ||
|
||
The currently enabled lints can be found in | ||
[analysis_options.1.9.0.yaml](https://github.com/dart-lang/pedantic/blob/master/lib/analysis_options.1.9.0.yaml). | ||
[analysis_options.1.11.0.yaml](https://github.com/dart-lang/pedantic/blob/master/lib/analysis_options.1.11.0.yaml). | ||
|
||
## Stricter than Effective Dart | ||
|
||
|
@@ -65,11 +65,11 @@ To use the lints add a dependency in your `pubspec.yaml`: | |
```yaml | ||
# If you use `package:pedantic/pedantic.dart`, add a normal dependency. | ||
dependencies: | ||
pedantic: ^1.9.0 | ||
pedantic: ^1.11.0 | ||
|
||
# Or, if you just want `analysis_options.yaml`, it can be a dev dependency. | ||
dev_dependencies: | ||
pedantic: ^1.9.0 | ||
pedantic: ^1.11.0 | ||
``` | ||
|
||
then, add an include in your `analysis_options.yaml`. If you want to always | ||
|
@@ -86,7 +86,7 @@ fail whenever a new version of `package:pedantic` is released. To avoid this, | |
specify a specific version of `analysis_options.yaml` instead: | ||
|
||
```yaml | ||
include: package:pedantic/analysis_options.1.9.0.yaml | ||
include: package:pedantic/analysis_options.1.11.0.yaml | ||
``` | ||
|
||
## Unused Lints | ||
|
@@ -128,6 +128,9 @@ enum-like types) where it makes sense to violate this lint. | |
only applies to web, but there is currently no mechanism for enabling a lint | ||
on web code only. | ||
|
||
`avoid_empty_else` | ||
redundant when `curly_braces_in_control_structures` is also enabled. | ||
|
||
`avoid_equals_and_hash_code_on_mutable_classes` | ||
would require the `@immutable` annotation to be consistently and correctly | ||
used everywhere. | ||
|
@@ -143,7 +146,7 @@ on web code only. | |
is too strict, it's okay to `print` in some code. | ||
|
||
`avoid_returning_null` | ||
will be obsoleted by NNBD. | ||
will be obsoleted by sound null safety. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
`avoid_returning_this` | ||
has occasional false positives, and adds little value as the cascade operator | ||
|
@@ -160,6 +163,9 @@ to indicate that nobody should `await` for the result. | |
`cancel_subscriptions` | ||
has false positives when you use a utility method or class to call `cancel`. | ||
|
||
`cascade_invocations` | ||
does not reflect common usage. | ||
|
||
`close_sinks` | ||
has false positives when you use a utility method or class to call `close`. | ||
|
||
|
@@ -175,6 +181,9 @@ and there are occasional valid uses. | |
would enforce a slightly different ordering to that used by IntelliJ and other | ||
tools using the analyzer. | ||
|
||
`diagnose_describe_all_properties` | ||
requires too much maintenance for most codebases. | ||
|
||
`empty_statements` | ||
is superfluous, enforcing use of `dartfmt` is sufficient to make empty | ||
statements obvious. | ||
|
@@ -200,8 +209,11 @@ when the code is formatted with `dartfmt`. | |
is too strict, classes might implement more than one such abstract class and | ||
there is no equivalent way to do this using functions. | ||
|
||
`only_throw_errors` | ||
does not reflect common usage. | ||
|
||
`parameter_assignments` | ||
does not reflect common usage, and will cause particular problems with NNBD | ||
does not reflect common usage, and will cause particular problems with null safe | ||
code. | ||
|
||
`prefer_asserts_in_initializer_lists` | ||
|
@@ -240,13 +252,12 @@ does not reflect common usage. | |
`prefer_foreach` | ||
is too strict; `forEach` is not always an improvement. | ||
|
||
`prefer_if_elements_to_conditional_expressions` | ||
users prefer `?:` over `if`/`else`. | ||
|
||
`prefer_int_literals` | ||
does not reflect common usage. | ||
|
||
`prefer_typing_uninitialized_variables` | ||
will be obsoleted by NNBD, which comes with type inference for uninitialized | ||
variables. | ||
|
||
`sort_constructors_first` | ||
does not reflect common usage. | ||
|
||
|
@@ -267,6 +278,9 @@ does not offer enough value: this is hard to do by mistake, and harmless. | |
`use_setters_to_change_properties` | ||
is too strict: it can't detect when something is conceptually a property. | ||
|
||
`use_string_buffers` | ||
does not improve performance on web. | ||
|
||
`use_to_and_as_if_applicable` | ||
is too strict: it can't detect when the style rule actually applies. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file | ||
# for details. All rights reserved. Use of this source code is governed by a | ||
# BSD-style license that can be found in the LICENSE file. | ||
# | ||
# Google internally enforced rules. See README.md for more information, | ||
# including a list of lints that are intentionally _not_ enforced. | ||
|
||
linter: | ||
rules: | ||
- always_declare_return_types | ||
- always_require_non_null_named_parameters | ||
- annotate_overrides | ||
- avoid_init_to_null | ||
- avoid_null_checks_in_equality_operators | ||
- avoid_relative_lib_imports | ||
- avoid_return_types_on_setters | ||
- avoid_shadowing_type_parameters | ||
- avoid_single_cascade_in_expression_statements | ||
- avoid_types_as_parameter_names | ||
- await_only_futures | ||
- camel_case_extensions | ||
- curly_braces_in_flow_control_structures | ||
- empty_catches | ||
- empty_constructor_bodies | ||
- library_names | ||
- library_prefixes | ||
- no_duplicate_case_values | ||
- null_closures | ||
- omit_local_variable_types | ||
- prefer_adjacent_string_concatenation | ||
- prefer_collection_literals | ||
- prefer_conditional_assignment | ||
- prefer_contains | ||
- prefer_equal_for_default_values | ||
- prefer_final_fields | ||
- prefer_for_elements_to_map_fromIterable | ||
- prefer_generic_function_type_aliases | ||
- prefer_if_null_operators | ||
- prefer_inlined_adds | ||
- prefer_is_empty | ||
- prefer_is_not_empty | ||
- prefer_iterable_whereType | ||
- prefer_single_quotes | ||
- prefer_spread_collections | ||
- recursive_getters | ||
- slash_for_doc_comments | ||
- sort_child_properties_last | ||
- type_init_formals | ||
- unawaited_futures | ||
- unnecessary_brace_in_string_interps | ||
- unnecessary_const | ||
- unnecessary_getters_setters | ||
- unnecessary_new | ||
- unnecessary_null_in_if_null_operators | ||
- unnecessary_this | ||
- unrelated_type_equality_checks | ||
- unsafe_html | ||
- use_full_hex_values_for_flutter_colors | ||
- use_function_type_syntax_for_parameters | ||
- use_rethrow_when_possible | ||
- valid_regexps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider sorting
unsafe_html
beforeuse_full_hex_values_for_flutter_colors
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done!