Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 7a23d77

Browse files
authored
fix: avoid-unused-parameters now support abstract methods (#438)
1 parent d01d3cf commit 7a23d77

File tree

6 files changed

+29
-4
lines changed

6 files changed

+29
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* Fix rule and metrics excludes for monorepos.
6+
* Improve static code diagnostics `avoid-unused-parameters`, `prefer-match-file-name`.
67

78
## 4.2.0
89

lib/src/analyzers/lint_analyzer/rules/rules_list/avoid_unused_parameters/visitor.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class _Visitor extends RecursiveAstVisitor<void> {
1313
final parameters = node.parameters;
1414

1515
if (parent is ClassDeclaration && parent.isAbstract ||
16+
node.isAbstract ||
1617
node.externalKeyword != null ||
1718
(parameters == null || parameters.parameters.isEmpty)) {
1819
return;

test/analyzers/lint_analyzer/rules/rules_factory_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ void main() {
3636
'avoid-wrapping-in-padding': <String, Object>{},
3737
'prefer-extracting-callbacks': <String, Object>{},
3838
'prefer-single-widget-per-file': <String, Object>{},
39+
'avoid-ignoring-return-values': <String, Object>{},
3940
}).map((rule) => rule.id),
4041
equals([
4142
'always-remove-listener',
43+
'avoid-ignoring-return-values',
4244
'avoid-late-keyword',
4345
'avoid-non-null-assertion',
4446
'avoid-preserve-whitespace-false',

test/analyzers/lint_analyzer/rules/rules_list/avoid_unused_parameters/avoid_unused_parameters_test.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ void main() {
3636

3737
RuleTestHelper.verifyIssues(
3838
issues: issues,
39-
startOffsets: [142, 210, 369, 415, 661, 537, 739],
40-
startLines: [8, 11, 21, 24, 35, 29, 41],
41-
startColumns: [20, 40, 20, 20, 28, 38, 20],
42-
endOffsets: [155, 229, 382, 433, 677, 550, 755],
39+
startOffsets: [142, 210, 369, 415, 661, 537, 739, 867],
40+
startLines: [8, 11, 21, 24, 35, 29, 41, 47],
41+
startColumns: [20, 40, 20, 20, 28, 38, 20, 23],
42+
endOffsets: [155, 229, 382, 433, 677, 550, 755, 880],
4343
locationTexts: [
4444
'String string',
4545
'String secondString',
@@ -48,6 +48,7 @@ void main() {
4848
'TestClass object',
4949
'String string',
5050
'TestClass object',
51+
'String string',
5152
],
5253
messages: [
5354
'Parameter is unused.',
@@ -57,6 +58,7 @@ void main() {
5758
'Parameter is unused.',
5859
'Parameter is unused.',
5960
'Parameter is unused.',
61+
'Parameter is unused.',
6062
],
6163
);
6264
});

test/analyzers/lint_analyzer/rules/rules_list/avoid_unused_parameters/examples/correct_example.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@ void sixthFunction(TestClass object) {
7171
final func = (TestClass object) => object.value;
7272
object.firstMethod('');
7373
}
74+
75+
mixin AbstractMixin {
76+
AbstractMixin copyWithLegs(List<Leg> legs);
77+
78+
String secondMethod(String string) {
79+
return string;
80+
}
81+
}
82+
83+
class FavsListener extends Mock {
84+
void call(Iterable<FavoriteStop> value);
85+
}

test/analyzers/lint_analyzer/rules/rules_list/avoid_unused_parameters/examples/incorrect_example.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ void fifthFunction(TestClass object, String string) {
4141
void sixthFunction(TestClass object) {
4242
final func = (TestClass object) => object.value;
4343
}
44+
45+
mixin AbstractMixin {
46+
// LINT
47+
String secondMethod(String string) {
48+
return 'string';
49+
}
50+
}

0 commit comments

Comments
 (0)