Skip to content

Commit

Permalink
Merge pull request #93 from dart-lang/group_tweaks
Browse files Browse the repository at this point in the history
Add `errors` to builtin groups.
  • Loading branch information
pq committed May 11, 2015
2 parents 64f0a18 + c50ae67 commit 81840c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
17 changes: 5 additions & 12 deletions lib/src/linter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,18 @@ class Group implements Comparable<Group> {
'https://www.dartlang.org/articles/style-guide/'));

/// List of builtin groups in presentation order.
static Iterable<Group> get builtin => [style, pub];
static Iterable<Group> get builtin => [errors, style, pub];

This comment has been minimized.

Copy link
@kevmoo

kevmoo May 12, 2015

Member

This could just be const, right? All of the child elements are const, etc.

This comment has been minimized.

Copy link
@pq

pq May 12, 2015

Author Member

Indeed!

#95


final String name;
final bool custom;
final String description;
final Hyperlink link;

factory Group(String name, {String description: '', Hyperlink link}) {
switch (name.toLowerCase()) {
case 'errors':
return errors;
case 'pub':
return pub;
case 'style':
return style;
default:
return new Group._(name,
custom: true, description: description, link: link);
}
var n = name.toLowerCase();
return builtin.firstWhere((g) => g.name == n,
orElse: () => new Group._(name,
custom: true, description: description, link: link));
}

@override
Expand Down
10 changes: 8 additions & 2 deletions test/linter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ void defineLinterEngineTests() {

group('groups', () {
test('factory', () {
expect(new Group('Style').custom, isFalse);
expect(new Group('Pub').custom, isFalse);
expect(new Group('style').custom, isFalse);
expect(new Group('pub').custom, isFalse);
expect(new Group('errors').custom, isFalse);
expect(new Group('Kustom').custom, isTrue);
});
test('builtins', () {
expect(Group.builtin.contains(Group.style), isTrue);
expect(Group.builtin.contains(Group.errors), isTrue);
expect(Group.builtin.contains(Group.pub), isTrue);
});
});

group('lint driver', () {
Expand Down

0 comments on commit 81840c4

Please sign in to comment.