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

Side by Side Diff: tool/rule.dart

Issue 1407283008: Verify type annotations on public APIs (#24). (Closed) Base URL: https://github.com/dart-lang/linter.git@master
Patch Set: Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « test/rules/type_annotate_public_apis.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:io'; 5 import 'dart:io';
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 8
9 String capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1); 9 String capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1);
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 stdout.write('''$message 77 stdout.write('''$message
78 Usage: rule 78 Usage: rule
79 ${parser.usage} 79 ${parser.usage}
80 '''); 80 ''');
81 } 81 }
82 82
83 String toClassName(String libName) => 83 String toClassName(String libName) =>
84 libName.split('_').map((bit) => capitalize(bit)).join(); 84 libName.split('_').map((bit) => capitalize(bit)).join();
85 85
86 String _generateStub(String libName, String className) => ''' 86 String _generateStub(String libName, String className) => """
87 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 87 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
88 // for details. All rights reserved. Use of this source code is governed by a 88 // for details. All rights reserved. Use of this source code is governed by a
89 // BSD-style license that can be found in the LICENSE file. 89 // BSD-style license that can be found in the LICENSE file.
90 90
91 library linter.src.rules.$libName; 91 library linter.src.rules.$libName;
92 92
93 import 'package:analyzer/src/generated/ast.dart'; 93 import 'package:analyzer/src/generated/ast.dart';
94 import 'package:analyzer/src/generated/scanner.dart'; 94 import 'package:analyzer/src/generated/scanner.dart';
95 import 'package:linter/src/linter.dart'; 95 import 'package:linter/src/linter.dart';
96 96
97 const desc = r' '; 97 const desc = r' ';
98 98
99 const details = r' '; 99 const details = r'''
100
101 **DO** ...
102
103 **BAD:**
104 ```
105
106 ```
107
108 **GOOD:**
109 ```
110
111 ```
112
113 ''';
100 114
101 class $className extends LintRule { 115 class $className extends LintRule {
102 $className() : super( 116 $className() : super(
103 name: '$libName', 117 name: '$libName',
104 description: desc, 118 description: desc,
105 details: details, 119 details: details,
106 group: Group.STYLE_GUIDE, 120 group: Group.style);
107 kind: Kind.AVOID);
108 121
109 @override 122 @override
110 AstVisitor getVisitor() => new Visitor(this); 123 AstVisitor getVisitor() => new Visitor(this);
111 } 124 }
112 125
113 class Visitor extends SimpleAstVisitor { 126 class Visitor extends SimpleAstVisitor {
114 LintRule rule; 127 final LintRule rule;
115 Visitor(this.rule); 128 Visitor(this.rule);
116 129
117 130
118 } 131 }
119 '''; 132 """;
120 133
121 String _generateTest(String libName, String className) => ''' 134 String _generateTest(String libName, String className) => '''
122 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 135 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
123 // for details. All rights reserved. Use of this source code is governed by a 136 // for details. All rights reserved. Use of this source code is governed by a
124 // BSD-style license that can be found in the LICENSE file. 137 // BSD-style license that can be found in the LICENSE file.
125 138
126 '''; 139 ''';
127 140
128 void addToRuleIndex(String libName, String className) { 141 void addToRuleIndex(String libName, String className) {
129 //TODO: find right place to insert into imports and ruleMap 142 //TODO: find right place to insert into imports and ruleMap
130 } 143 }
OLDNEW
« no previous file with comments | « test/rules/type_annotate_public_apis.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698