Skip to content

Commit f572aff

Browse files
committed
Fix formatting
1 parent 6c9207d commit f572aff

File tree

4 files changed

+56
-56
lines changed

4 files changed

+56
-56
lines changed

lib/src/lints/prefer_match_file_name/models/prefer_match_file_name_parameters.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/// A data model class that represents the "prefer factmatch file name" input
22
/// parameters
33
class PreferMatchFileNameParameters {
4-
54
/// A list of methods that should be excluded from the lint.
65
final Iterable<String> excludeEntity;
76

@@ -16,7 +15,8 @@ class PreferMatchFileNameParameters {
1615
factory PreferMatchFileNameParameters.fromJson(Map<String, Object?> json) =>
1716
PreferMatchFileNameParameters(
1817
excludeEntity: (json['exclude_entity'] as Iterable?)
19-
?.map((e) => e.toString())
20-
.toList() ?? [],
18+
?.map((e) => e.toString())
19+
.toList() ??
20+
[],
2121
);
2222
}

lib/src/lints/prefer_match_file_name/prefer_match_file_name_rule.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PreferMatchFileNameRule
8282
final excludedEntities = config.parameters.excludeEntity;
8383

8484
final visitor = PreferMatchFileNameVisitor(
85-
excludedEntities: excludedEntities,
85+
excludedEntities: excludedEntities,
8686
);
8787

8888
node.accept(visitor);

lib/src/lints/prefer_match_file_name/visitors/prefer_match_file_name_visitor.dart

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,16 @@ class PreferMatchFileNameVisitor extends RecursiveAstVisitor<void> {
1818
});
1919

2020
/// List of all declarations
21-
Iterable<DeclarationTokenInfo> get declarations =>
22-
_declarations
23-
..sort(
24-
// partition into public and private
25-
// put public ones first
26-
// each partition sorted by declaration order
27-
(a, b) =>
28-
_publicDeclarationsFirst(a, b) ?? _byDeclarationOrder(a, b),
29-
);
21+
Iterable<DeclarationTokenInfo> get declarations => _declarations
22+
..sort(
23+
// partition into public and private
24+
// put public ones first
25+
// each partition sorted by declaration order
26+
(a, b) => _publicDeclarationsFirst(a, b) ?? _byDeclarationOrder(a, b),
27+
);
3028

3129
bool _shouldIgnore(Declaration node) {
32-
if(excludedEntities.isEmpty) return false;
30+
if (excludedEntities.isEmpty) return false;
3331

3432
if (node is ClassDeclaration && excludedEntities.contains('class')) {
3533
return true;
@@ -45,59 +43,61 @@ class PreferMatchFileNameVisitor extends RecursiveAstVisitor<void> {
4543
return false;
4644
}
4745

46+
@override
47+
void visitClassDeclaration(ClassDeclaration node) {
48+
super.visitClassDeclaration(node);
4849

49-
@override
50-
void visitClassDeclaration(ClassDeclaration node) {
51-
super.visitClassDeclaration(node);
50+
if (_shouldIgnore(node)) return;
5251

53-
if(_shouldIgnore(node)) return;
54-
55-
_declarations.add((token: node.name, parent: node));
56-
}
52+
_declarations.add((token: node.name, parent: node));
53+
}
5754

58-
@override
59-
void visitExtensionDeclaration(ExtensionDeclaration node) {
60-
super.visitExtensionDeclaration(node);
55+
@override
56+
void visitExtensionDeclaration(ExtensionDeclaration node) {
57+
super.visitExtensionDeclaration(node);
6158

62-
if (_shouldIgnore(node)) return;
59+
if (_shouldIgnore(node)) return;
6360

64-
final name = node.name;
65-
if (name != null) {
66-
_declarations.add((token: name, parent: node));
61+
final name = node.name;
62+
if (name != null) {
63+
_declarations.add((token: name, parent: node));
64+
}
6765
}
68-
}
6966

70-
@override
71-
void visitMixinDeclaration(MixinDeclaration node) {
72-
super.visitMixinDeclaration(node);
67+
@override
68+
void visitMixinDeclaration(MixinDeclaration node) {
69+
super.visitMixinDeclaration(node);
7370

74-
if(_shouldIgnore(node)) return;
71+
if (_shouldIgnore(node)) return;
7572

76-
_declarations.add((token: node.name, parent: node));
77-
}
73+
_declarations.add((token: node.name, parent: node));
74+
}
7875

79-
@override
80-
void visitEnumDeclaration(EnumDeclaration node) {
81-
super.visitEnumDeclaration(node);
76+
@override
77+
void visitEnumDeclaration(EnumDeclaration node) {
78+
super.visitEnumDeclaration(node);
8279

83-
if(_shouldIgnore(node)) return;
80+
if (_shouldIgnore(node)) return;
8481

85-
_declarations.add((token: node.name, parent: node));
86-
}
82+
_declarations.add((token: node.name, parent: node));
83+
}
84+
85+
int? _publicDeclarationsFirst(
86+
DeclarationTokenInfo a,
87+
DeclarationTokenInfo b,
88+
) {
89+
final isAPrivate = Identifier.isPrivateName(a.token.lexeme);
90+
final isBPrivate = Identifier.isPrivateName(b.token.lexeme);
91+
if (!isAPrivate && isBPrivate) {
92+
return -1;
93+
} else if (isAPrivate && !isBPrivate) {
94+
return 1;
95+
}
96+
// no reorder needed;
97+
return null;
98+
}
8799

88-
int? _publicDeclarationsFirst(DeclarationTokenInfo a,
89-
DeclarationTokenInfo b,) {
90-
final isAPrivate = Identifier.isPrivateName(a.token.lexeme);
91-
final isBPrivate = Identifier.isPrivateName(b.token.lexeme);
92-
if (!isAPrivate && isBPrivate) {
93-
return -1;
94-
} else if (isAPrivate && !isBPrivate) {
95-
return 1;
100+
int _byDeclarationOrder(DeclarationTokenInfo a, DeclarationTokenInfo b) {
101+
return a.token.offset.compareTo(b.token.offset);
96102
}
97-
// no reorder needed;
98-
return null;
99103
}
100-
101-
int _byDeclarationOrder(DeclarationTokenInfo a, DeclarationTokenInfo b) {
102-
return a.token.offset.compareTo(b.token.offset);
103-
}}

lint_test/prefer_match_file_name_ignore_extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
/// Check if the `prefer_match_file_name` rule ignored for extensions
44
// expect_lint: prefer_match_file_name
5-
extension DefaultExtension on String {}
5+
extension DefaultExtension on String {}

0 commit comments

Comments
 (0)