@@ -43,11 +43,14 @@ class NonConstantIdentifierNames extends LintRule implements NodeLintRule {
4343 void registerNodeProcessors (
4444 NodeLintRegistry registry, LinterContext context) {
4545 var visitor = _Visitor (this );
46+ registry.addCatchClause (this , visitor);
4647 registry.addConstructorDeclaration (this , visitor);
48+ registry.addForEachPartsWithDeclaration (this , visitor);
4749 registry.addFormalParameterList (this , visitor);
4850 registry.addFunctionDeclaration (this , visitor);
4951 registry.addMethodDeclaration (this , visitor);
5052 registry.addVariableDeclaration (this , visitor);
53+ registry.addVariableDeclarationStatement (this , visitor);
5154 }
5255}
5356
@@ -69,13 +72,23 @@ class _Visitor extends SimpleAstVisitor<void> {
6972 }
7073 }
7174
75+ @override
76+ void visitCatchClause (CatchClause node) {
77+ checkIdentifier (node.exceptionParameter, underscoresOk: true );
78+ }
79+
7280 @override
7381 void visitConstructorDeclaration (ConstructorDeclaration node) {
7482 // For rationale on accepting underscores, see:
7583 // https://github.com/dart-lang/linter/issues/1854
7684 checkIdentifier (node.name, underscoresOk: true );
7785 }
7886
87+ @override
88+ void visitForEachPartsWithDeclaration (ForEachPartsWithDeclaration node) {
89+ checkIdentifier (node.loopVariable.identifier);
90+ }
91+
7992 @override
8093 void visitFormalParameterList (FormalParameterList node) {
8194 node.parameters.forEach ((FormalParameter p) {
@@ -103,4 +116,13 @@ class _Visitor extends SimpleAstVisitor<void> {
103116 checkIdentifier (node.name);
104117 }
105118 }
119+
120+ @override
121+ void visitVariableDeclarationStatement (VariableDeclarationStatement node) {
122+ for (var variable in node.variables.variables) {
123+ if (! variable.isConst) {
124+ checkIdentifier (variable.name);
125+ }
126+ }
127+ }
106128}
0 commit comments