analyzer: Deprecate the avoid_null_checks_in_equality_operators lint rule
Work towards https://github.com/dart-lang/sdk/issues/59514
We introduced a new Warning called NON_NULLABLE_EQUALS_PARAMETER a few releases ago. It warns when the parameter of an `operator ==` override has a nullable type:
> The parameter type of '==' operators should be non-nullable.
I didn't realize it at the time, but that new warning, plus null safety, basically replace the `avoid_null_checks_in_equality_operators` lint rule. This rule reports doing any null-check work on a nullable parameter of an `operator ==` override.
Change-Id: Ibd8139cd5804a9ccb6cc07d2187c9305a336c7cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467922
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Samuel Rawlins <[email protected]>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 18aa96f..a515522 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -50,6 +50,9 @@
- Fixes to the 'Extract Widget' refactoring.
- (Thanks [@FMorschel](https://github.com/FMorschel) and
[@DanTup](https://github.com/DanTup) for many of the above enhancements!)
+- The `avoid_null_checks_in_equality_operators` lint rule is now deprecated.
+- The `prefer_final_parameters` lint rule is now deprecated.
+- The `use_if_null_to_convert_nulls_to_bools` lint rule is now deprecated.
#### Pub
diff --git a/pkg/linter/example/all.yaml b/pkg/linter/example/all.yaml
index 1dc3654..bea55b9 100644
--- a/pkg/linter/example/all.yaml
+++ b/pkg/linter/example/all.yaml
@@ -27,7 +27,6 @@
- avoid_init_to_null
- avoid_js_rounded_ints
- avoid_multiple_declarations_per_line
- - avoid_null_checks_in_equality_operators
- avoid_positional_boolean_parameters
- avoid_print
- avoid_private_typedef_functions
diff --git a/pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart b/pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart
index 90f94d1..46d46b3 100644
--- a/pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart
+++ b/pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart
@@ -4,6 +4,7 @@
import 'package:analyzer/analysis_rule/analysis_rule.dart';
import 'package:analyzer/analysis_rule/rule_context.dart';
+import 'package:analyzer/analysis_rule/rule_state.dart';
import 'package:analyzer/analysis_rule/rule_visitor_registry.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
@@ -11,6 +12,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/error/error.dart';
+import 'package:pub_semver/pub_semver.dart';
import '../analyzer.dart';
import '../diagnostic.dart' as diag;
@@ -43,6 +45,7 @@
: super(
name: LintNames.avoid_null_checks_in_equality_operators,
description: _desc,
+ state: RuleState.deprecated(since: Version(3, 11, 0)),
);
@override
diff --git a/pkg/linter/messages.yaml b/pkg/linter/messages.yaml
index 2b8adf5..4bf7973 100644
--- a/pkg/linter/messages.yaml
+++ b/pkg/linter/messages.yaml
@@ -1728,6 +1728,7 @@
correctionMessage: "Try removing the comparison."
state:
stable: "2.0"
+ deprecated: "3.11"
categories: [style]
hasPublishedDocs: false
deprecatedDetails: |-