Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Unified Diff: lib/src/rules/type_annotate_public_apis.dart

Issue 1496603002: Fix NSME in `type_annotate_public_apis` (#151). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/rules/type_annotate_public_apis.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
}
« no previous file with comments | « no previous file | test/rules/type_annotate_public_apis.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698