Skip to content

Commit

Permalink
Group tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
pq committed May 11, 2015
1 parent 64f0a18 commit c50ae67
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
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];

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
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 c50ae67

Please sign in to comment.