Merge pull request #1958 from davidmorgan/unnecessary-final-range
Make unnecessary_final lint report on the `final` keyword.
diff --git a/lib/src/rules/unnecessary_final.dart b/lib/src/rules/unnecessary_final.dart
index 8a23c5c..1b8aba9 100644
--- a/lib/src/rules/unnecessary_final.dart
+++ b/lib/src/rules/unnecessary_final.dart
@@ -63,6 +63,9 @@
void visitFormalParameterList(FormalParameterList parameterList) {
for (var node in parameterList.parameters) {
if (node.isFinal) {
+ // TODO(davidmorgan): for consistency this should report on the
+ // `final` keyword, not the node, but it's hard to get to from
+ // FormalParameter.
rule.reportLint(node);
}
}
@@ -79,7 +82,7 @@
final loopVariable = forLoopParts.loopVariable;
if (loopVariable.isFinal) {
- rule.reportLint(loopVariable.identifier);
+ rule.reportLintForToken(loopVariable.keyword);
}
}
}
@@ -87,7 +90,7 @@
@override
void visitVariableDeclarationStatement(VariableDeclarationStatement node) {
if (node.variables.isFinal) {
- rule.reportLint(node.variables);
+ rule.reportLintForToken(node.variables.keyword);
}
}
}