Index: lib/src/rules/type_annotate_public_apis.dart |
diff --git a/lib/src/rules/type_annotate_public_apis.dart b/lib/src/rules/type_annotate_public_apis.dart |
index 1db683ceba0dda2bbcfba0e8726ac1f18f8b85ed..1c69aff6d2e564b004920cb97dc37afa70422189 100644 |
--- a/lib/src/rules/type_annotate_public_apis.dart |
+++ b/lib/src/rules/type_annotate_public_apis.dart |
@@ -5,8 +5,8 @@ |
library linter.src.rules.type_annotate_public_apis; |
import 'package:analyzer/src/generated/ast.dart'; |
-import 'package:linter/src/linter.dart'; |
import 'package:linter/src/ast.dart'; |
+import 'package:linter/src/linter.dart'; |
const desc = r'Type annotate public APIs.'; |
@@ -61,10 +61,10 @@ class TypeAnnotatePublicApis extends LintRule { |
} |
class Visitor extends SimpleAstVisitor { |
+ _VisitorHelper v; |
final LintRule rule; |
- _VisitoHelper v; |
Visitor(this.rule) { |
- v = new _VisitoHelper(rule); |
+ v = new _VisitorHelper(rule); |
} |
@override |
@@ -75,59 +75,59 @@ class Visitor extends SimpleAstVisitor { |
} |
@override |
- visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
- if (node.variables.type == null) { |
- node.variables.accept(v); |
- } |
- } |
- |
- @override |
visitFunctionDeclaration(FunctionDeclaration node) { |
if (!isPrivate(node.name)) { |
- if (node.returnType == null) { |
+ if (node.returnType == null && !node.isSetter) { |
rule.reportLint(node.name); |
} else { |
- node.functionExpression.parameters.accept(v); |
+ node.functionExpression.parameters?.accept(v); |
} |
} |
} |
@override |
+ visitFunctionTypeAlias(FunctionTypeAlias node) { |
+ if (node.returnType == null) { |
+ rule.reportLint(node.name); |
+ } else { |
+ node.parameters.accept(v); |
+ } |
+ } |
+ |
+ @override |
visitMethodDeclaration(MethodDeclaration node) { |
if (!isPrivate(node.name)) { |
- if (node.returnType == null) { |
+ if (node.returnType == null && !node.isSetter) { |
rule.reportLint(node.name); |
} else { |
- node.parameters.accept(v); |
+ node.parameters?.accept(v); |
} |
} |
} |
@override |
- visitFunctionTypeAlias(FunctionTypeAlias node) { |
- if (node.returnType == null) { |
- rule.reportLint(node.name); |
- } else { |
- node.parameters.accept(v); |
+ visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { |
+ if (node.variables.type == null) { |
+ node.variables.accept(v); |
} |
} |
} |
-class _VisitoHelper extends RecursiveAstVisitor { |
+class _VisitorHelper extends RecursiveAstVisitor { |
final LintRule rule; |
- _VisitoHelper(this.rule); |
+ _VisitorHelper(this.rule); |
@override |
- visitVariableDeclaration(VariableDeclaration node) { |
- if (!isPrivate(node.name)) { |
- rule.reportLint(node.name); |
+ visitSimpleFormalParameter(SimpleFormalParameter param) { |
+ if (param.type == null) { |
+ rule.reportLint(param); |
} |
} |
@override |
- visitSimpleFormalParameter(SimpleFormalParameter param) { |
- if (param.type == null) { |
- rule.reportLint(param); |
+ visitVariableDeclaration(VariableDeclaration node) { |
+ if (!isPrivate(node.name)) { |
+ rule.reportLint(node.name); |
} |
} |
} |