Skip to content

Commit 04753f6

Browse files
srawlinsCommit Queue
authored andcommitted
analyzer: Deprecate the avoid_null_checks_in_equality_operators lint rule
Work towards #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]>
1 parent 6c0ae60 commit 04753f6

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@
5050
- Fixes to the 'Extract Widget' refactoring.
5151
- (Thanks [@FMorschel](https://github.com/FMorschel) and
5252
[@DanTup](https://github.com/DanTup) for many of the above enhancements!)
53+
- The `avoid_null_checks_in_equality_operators` lint rule is now deprecated.
54+
- The `prefer_final_parameters` lint rule is now deprecated.
55+
- The `use_if_null_to_convert_nulls_to_bools` lint rule is now deprecated.
5356

5457
#### Pub
5558

pkg/linter/example/all.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ linter:
2727
- avoid_init_to_null
2828
- avoid_js_rounded_ints
2929
- avoid_multiple_declarations_per_line
30-
- avoid_null_checks_in_equality_operators
3130
- avoid_positional_boolean_parameters
3231
- avoid_print
3332
- avoid_private_typedef_functions

pkg/linter/lib/src/rules/avoid_null_checks_in_equality_operators.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
import 'package:analyzer/analysis_rule/analysis_rule.dart';
66
import 'package:analyzer/analysis_rule/rule_context.dart';
7+
import 'package:analyzer/analysis_rule/rule_state.dart';
78
import 'package:analyzer/analysis_rule/rule_visitor_registry.dart';
89
import 'package:analyzer/dart/ast/ast.dart';
910
import 'package:analyzer/dart/ast/token.dart';
1011
import 'package:analyzer/dart/ast/visitor.dart';
1112
import 'package:analyzer/dart/element/element.dart';
1213
import 'package:analyzer/dart/element/nullability_suffix.dart';
1314
import 'package:analyzer/error/error.dart';
15+
import 'package:pub_semver/pub_semver.dart';
1416

1517
import '../analyzer.dart';
1618
import '../diagnostic.dart' as diag;
@@ -43,6 +45,7 @@ class AvoidNullChecksInEqualityOperators extends AnalysisRule {
4345
: super(
4446
name: LintNames.avoid_null_checks_in_equality_operators,
4547
description: _desc,
48+
state: RuleState.deprecated(since: Version(3, 11, 0)),
4649
);
4750

4851
@override

pkg/linter/messages.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,6 +1728,7 @@ LinterLintCode:
17281728
correctionMessage: "Try removing the comparison."
17291729
state:
17301730
stable: "2.0"
1731+
deprecated: "3.11"
17311732
categories: [style]
17321733
hasPublishedDocs: false
17331734
deprecatedDetails: |-

0 commit comments

Comments
 (0)