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

Side by Side Diff: pkg/analyzer/test/services/data/style_guide_tests.data

Issue 1001403002: Remove the old formatter from analyzer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 >>> DO use ; instead of {} for empty constructor bodies
2 class Point {
3 int x, y;
4 Point(this.x, this.y) {}
5 }
6 <<<
7 class Point {
8 int x, y;
9 Point(this.x, this.y);
10 }
11 >>> DO indent block bodies two spaces.
12 hi() {
13 if (condition) { print('hi'); }
14 }
15 <<<
16 hi() {
17 if (condition) {
18 print('hi');
19 }
20 }
21 >>> DON'T indent lines that are continued with a function expression.
22 var callback = new Future.delayed(const Duration(seconds: 1), () {
23 print('I am a callback');
24 });
25 <<<
26 var callback = new Future.delayed(const Duration(seconds: 1), () {
27 print('I am a callback');
28 });
29 >>> DO place the opening curly brace ({) on the same line as what it follows.
30 class Foo {
31 method()
32 {
33 if (true)
34 {
35 print('true');
36 } else {
37 print('false');
38 }
39 }
40 }
41 <<<
42 class Foo {
43 method() {
44 if (true) {
45 print('true');
46 } else {
47 print('false');
48 }
49 }
50 }
51 >>> DO use curly braces for all flow control structures.
52 flow() {
53 if (true) print('sanity');
54 else
55 print('opposite day!');
56 }
57 <<<
58 flow() {
59 if (true) {
60 print('sanity');
61 } else {
62 print('opposite day!');
63 }
64 }
65 >>> ... short if statements with no else may omit the braces ...
66 except() {
67 if (arg == null) return defaultValue;
68 }
69 <<<
70 except() {
71 if (arg == null) return defaultValue;
72 }
73 >>> DO indent switch cases two spaces and case bodies four spaces
74 switches() {
75 switch (fruit) {
76 case 'apple':
77 print('delish');
78 break;
79
80 case 'durian':
81 print('stinky');
82 break;
83 }
84 }
85 <<<
86 switches() {
87 switch (fruit) {
88 case 'apple':
89 print('delish');
90 break;
91
92 case 'durian':
93 print('stinky');
94 break;
95 }
96 }
97 >>> DO use spaces around binary and ternary operators, etc...
98 spaces() {
99 a=1+2/(3* - b);
100 c= ! condition==a>b;
101 d= condition?b:object.method(a,b,c);
102 if (obj is !SomeType) print('not SomeType');
103 }
104 <<<
105 spaces() {
106 a = 1 + 2 / (3 * -b);
107 c = !condition == a > b;
108 d = condition ? b : object.method(a, b, c);
109 if (obj is! SomeType) print('not SomeType');
110 }
111 >>> DO place spaces around in, and after each ; in a loop.
112 loop() {
113 for (var i = 0;i<100;i++) {
114 print(i);
115 }
116 for (final item in collection) {
117 print(item);
118 }
119 }
120 <<<
121 loop() {
122 for (var i = 0; i < 100; i++) {
123 print(i);
124 }
125 for (final item in collection) {
126 print(item);
127 }
128 }
129 >>> DO use a space after flow-control keywords.
130 flow() {
131 while(foo) {
132 print(foo);
133 }
134
135 try{
136 flow();
137 }catch(e) {
138 print(e);
139 }
140 }
141 <<<
142 flow() {
143 while (foo) {
144 print(foo);
145 }
146
147 try {
148 flow();
149 } catch (e) {
150 print(e);
151 }
152 }
153 >>> DON'T use a space after (, [, and {, or before ), ], and }.
154 spaces() {
155 var numbers = <int> [ 1, 2,( 3+4 ) ];
156 var mapLiteral = <int, int> {};
157 }
158 <<<
159 spaces() {
160 var numbers = <int>[1, 2, (3 + 4)];
161 var mapLiteral = <int, int>{};
162 }
163 >>> DO use a space before { in function and method bodies.
164 getEmptyFn(a){
165 return (){};
166 }
167 <<<
168 getEmptyFn(a) {
169 return () {};
170 }
171 >>> DO format constructor initialization lists with each field on its own line.
172 class MyClass {
173 var firstField, secondField, thirdField;
174 MyClass() : firstField = "some value", secondField = "another",
175 thirdField = "last";
176 }
177 <<<
178 class MyClass {
179 var firstField, secondField, thirdField;
180 MyClass()
181 : firstField = "some value",
182 secondField = "another",
183 thirdField = "last";
184 }
185 >>> DO format constructor initialization lists with each field on its own line.
186 class MyClass {
187 MyClass(looooooooooooooonA, looooooooooooooonB) : super(looooooooooooooonA, lo oooooooooooooonB);
188 MyClass(looooooooooooooonA, looooooooooooooonB) : this(looooooooooooooonA, loo ooooooooooooonB);
189 }
190 <<<
191 class MyClass {
192 MyClass(looooooooooooooonA, looooooooooooooonB)
193 : super(looooooooooooooonA, looooooooooooooonB);
194 MyClass(looooooooooooooonA, looooooooooooooonB)
195 : this(looooooooooooooonA, looooooooooooooonB);
196 }
197 >>> DO use a space after : in named parameters and named arguments.
198 class ListBox {
199 bool showScrollbars;
200
201 ListBox({this.showScrollbars: false});
202 }
203
204 main() {
205 new ListBox(showScrollbars:true);
206 new ListBox(showScrollbars : true);
207 }
208 <<<
209 class ListBox {
210 bool showScrollbars;
211
212 ListBox({this.showScrollbars: false});
213 }
214
215 main() {
216 new ListBox(showScrollbars: true);
217 new ListBox(showScrollbars: true);
218 }
219 >>> DO use a spaces around = in optional positional parameters.
220 class HttpServer {
221 static Future<HttpServer> listen([int port=80]) {
222 print('hi!');
223 }
224 }
225 <<<
226 class HttpServer {
227 static Future<HttpServer> listen([int port = 80]) {
228 print('hi!');
229 }
230 }
231 >>> DO use four spaces for method cascades
232 var list = new List()
233 ..addAll([1, 2, 3])
234 ..addAll([4, 5, 6]);
235 <<<
236 var list = new List()
237 ..addAll([1, 2, 3])
238 ..addAll([4, 5, 6]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698