diff --git a/CHANGELOG.md b/CHANGELOG.md index d53040d..d35346a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`] + - [`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. diff --git a/README.md b/README.md index 7185eda..1e2d507 100644 --- a/README.md +++ b/README.md @@ -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. `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. diff --git a/lib/analysis_options.1.11.0.yaml b/lib/analysis_options.1.11.0.yaml new file mode 100644 index 0000000..e464d5a --- /dev/null +++ b/lib/analysis_options.1.11.0.yaml @@ -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 diff --git a/lib/analysis_options.yaml b/lib/analysis_options.yaml index cb7021e..a7c933f 100644 --- a/lib/analysis_options.yaml +++ b/lib/analysis_options.yaml @@ -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 diff --git a/pubspec.yaml b/pubspec.yaml index 7e24198..5309839 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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