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

Side by Side Diff: lib/src/rules/one_member_abstracts.dart

Issue 2318333002: Fix broken markdown in docs (#306). (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « lib/src/rules/empty_constructor_bodies.dart ('k') | lib/src/rules/slash_for_doc_comments.dart » ('j') | 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 library linter.src.rules.one_member_abstracts; 5 library linter.src.rules.one_member_abstracts;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:linter/src/linter.dart'; 9 import 'package:linter/src/linter.dart';
10 10
11 const desc = 11 const desc =
12 'Avoid defining a one-member abstract class when a simple function will do.' ; 12 'Avoid defining a one-member abstract class when a simple function will do.' ;
13 13
14 const details = ''' 14 const details = '''
15 From the [style guide] (https://www.dartlang.org/articles/style-guide/): 15 From the [style guide](https://www.dartlang.org/articles/style-guide/):
16 16
17 **AVOID** defining a one-member abstract class when a simple function will do. 17 **AVOID** defining a one-member abstract class when a simple function will do.
18 18
19 Unlike Java, Dart has first-class functions, closures, and a nice light syntax 19 Unlike Java, Dart has first-class functions, closures, and a nice light syntax
20 for using them. If all you need is something like a callback, just use a 20 for using them. If all you need is something like a callback, just use a
21 function. If you're defining an class and it only has a single abstract member 21 function. If you're defining an class and it only has a single abstract member
22 with a meaningless name like `call` or `invoke`, there is a good chance 22 with a meaningless name like `call` or `invoke`, there is a good chance
23 you just want a function. 23 you just want a function.
24 24
25 **GOOD:** 25 **GOOD:**
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 var member = node.members[0]; 59 var member = node.members[0];
60 if (member is MethodDeclaration && 60 if (member is MethodDeclaration &&
61 member.isAbstract && 61 member.isAbstract &&
62 !member.isGetter && 62 !member.isGetter &&
63 !member.isSetter) { 63 !member.isSetter) {
64 rule.reportLint(node.name); 64 rule.reportLint(node.name);
65 } 65 }
66 } 66 }
67 } 67 }
68 } 68 }
OLDNEW
« no previous file with comments | « lib/src/rules/empty_constructor_bodies.dart ('k') | lib/src/rules/slash_for_doc_comments.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698