Skip to content

Commit c320343

Browse files
Yurii PrykhodkoYurii Prykhodko
authored andcommitted
Add more test cases, do not advertise class support
1 parent bf85077 commit c320343

File tree

7 files changed

+50
-7
lines changed

7 files changed

+50
-7
lines changed

lib/src/common/parameters/excluded_entities_list_parameter.dart

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import 'package:analyzer/dart/ast/ast.dart';
44
/// identifiers (classes, mixins, enums, extensions) to be ignored during
55
/// analysis.
66
/// Supported entities:
7-
/// - class
87
/// - mixin
98
/// - extension
109
/// - enum
@@ -28,6 +27,7 @@ class ExcludedEntitiesListParameter {
2827
excludedEntityNames: Set<String>.from(raw),
2928
);
3029
}
30+
3131
return ExcludedEntitiesListParameter(
3232
excludedEntityNames: {},
3333
);
@@ -37,10 +37,7 @@ class ExcludedEntitiesListParameter {
3737
bool shouldIgnoreEntity(Declaration node) {
3838
if (excludedEntityNames.isEmpty) return false;
3939

40-
if (node is ClassDeclaration && excludedEntityNames.contains('class')) {
41-
return true;
42-
} else if (node is MixinDeclaration &&
43-
excludedEntityNames.contains('mixin')) {
40+
if (node is MixinDeclaration && excludedEntityNames.contains('mixin')) {
4441
return true;
4542
} else if (node is EnumDeclaration &&
4643
excludedEntityNames.contains('enum')) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
analyzer:
2+
plugins:
3+
- ../../../custom_lint
4+
5+
custom_lint:
6+
rules:
7+
- prefer_match_file_name:
8+
exclude_entity:
9+
- enum
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// ignore_for_file: unused_element, unused_field
2+
3+
/// `prefer_match_file_name` rule will be ignored by this enttiy because of
4+
/// exclude_entity:
5+
/// - enum
6+
/// in analysis_options.yaml
7+
enum Ignored { _ }
8+
enum IgnoredAgain { _ }
9+
10+
// expect_lint: prefer_match_file_name
11+
abstract class WrongNamedClass {}
12+
13+
/// Only first public element declaration is checked
14+
class PreferMatchFileNameIgnoreExtensions {}

lint_test/prefer_match_file_name_ignore_extensions/analysis_options.yaml renamed to lint_test/prefer_match_file_name_ignore_entity/extension/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
analyzer:
22
plugins:
3-
- ../../custom_lint
3+
- ../../../custom_lint
44

55
custom_lint:
66
rules:

lint_test/prefer_match_file_name_ignore_extensions/prefer_match_file_name_ignore_extensions.dart renamed to lint_test/prefer_match_file_name_ignore_entity/extension/test.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
/// exclude_entity:
55
/// - extension
66
/// in analysis_options.yaml
7-
extension DefaultExtension on String {}
7+
extension Ignored on String {}
8+
extension IgnoredAgain on String {}
89

910
// expect_lint: prefer_match_file_name
1011
abstract class WrongNamedClass {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
analyzer:
2+
plugins:
3+
- ../../../custom_lint
4+
5+
custom_lint:
6+
rules:
7+
- prefer_match_file_name:
8+
exclude_entity:
9+
- mixin
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// ignore_for_file: unused_element, unused_field
2+
3+
/// `prefer_match_file_name` rule will be ignored by this entity because of
4+
/// exclude_entity:
5+
/// - mixin
6+
/// in analysis_options.yaml
7+
mixin IgnoredMixin {}
8+
9+
// expect_lint: prefer_match_file_name
10+
abstract class WrongNamedClass {}
11+
12+
/// Only first public element declaration is checked
13+
class PreferMatchFileNameIgnoreExtensions {}

0 commit comments

Comments
 (0)