Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Update list of enforced lints #81

Merged
merged 4 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## 1.11.0

- Enforce 8 new lint rules:
- [`avoid_single_cascade_in_expression_statements`]
- [`await_only_futures`]
- [`prefer_inlined_adds`]
- [`sort_child_properties_last`]
- [`unnecessary_brace_in_string_interps`]
- [`unnecessary_getters_setters`]
- [`unsafe_html`]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider sorting unsafe_html before use_full_hex_values_for_flutter_colors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done!

- [`use_full_hex_values_for_flutter_colors`]

- Mark a number of lints unused, see `README.md` for details.

- Remove [`avoid_empty_else`] as it is redundant when
[`curly_braces_in_control_structures`] is also enabled.

[`avoid_empty_else`]: https://dart-lang.github.io/linter/lints/avoid_empty_else.html
[`avoid_single_cascade_in_expression_statements`]: https://dart-lang.github.io/linter/lints/avoid_single_cascade_in_expression_statements.html
[`await_only_futures`]: https://dart-lang.github.io/linter/lints/await_only_futures.html
[`curly_braces_in_control_structures`]: https://dart-lang.github.io/linter/lints/curly_braces_in_flow_control_structures.html
[`prefer_inlined_adds`]: https://dart-lang.github.io/linter/lints/prefer_inlined_adds.html
[`sort_child_properties_last`]: https://dart-lang.github.io/linter/lints/sort_child_properties_last.html
[`unnecessary_brace_in_string_interps`]: https://dart-lang.github.io/linter/lints/unnecessary_brace_in_string_interps.html
[`unnecessary_getters_setters`]: https://dart-lang.github.io/linter/lints/unnecessary_getters_setters.html
[`unsafe_html`]: https://dart-lang.github.io/linter/lints/unsafe_html.html
[`use_full_hex_values_for_flutter_colors`]: https://dart-lang.github.io/linter/lints/use_full_hex_values_for_flutter_colors.html

## 1.10.0

* Stable null safety release.
Expand Down
34 changes: 24 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand All @@ -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`.

Expand All @@ -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.
Expand All @@ -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`
Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down
61 changes: 61 additions & 0 deletions lib/analysis_options.1.11.0.yaml
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
2 changes: 1 addition & 1 deletion lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# whenever a new version of `package:pedantic` is released. To avoid this,
# specify a specific version of `analysis_options.yaml` instead.

include: package:pedantic/analysis_options.1.9.0.yaml
include: package:pedantic/analysis_options.1.11.0.yaml
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: pedantic
version: 1.10.0
version: 1.11.0
description: >-
The Dart analyzer settings and best practices used internally at Google.
homepage: https://github.com/google/pedantic
Expand Down