diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dfa23ca..86db9fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.0.1 + +- Renamed `prefer_mirror_test_structure` rule to `mirror_test_structure`. + ## 2.0.0 - BREAKING CHANGE: Updated rules in `analysis_options.yaml`. Existing diff --git a/lib/analysis_options.yaml b/lib/analysis_options.yaml index d2faab6e..f14374f9 100644 --- a/lib/analysis_options.yaml +++ b/lib/analysis_options.yaml @@ -92,6 +92,7 @@ solid_lints: - deactivate_method - dispose_method + mirror_test_structure: true newline_before_return: true no_empty_block: true no_equal_then_else: true @@ -113,7 +114,6 @@ solid_lints: prefer_first: true prefer_last: true prefer_match_file_name: true - prefer_mirror_test_structure: true proper_super_calls: true named_parameters_ordering: true use_nearest_context: true diff --git a/lib/main.dart b/lib/main.dart index 3adb7b30..51ed46b7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -23,6 +23,7 @@ import 'package:solid_lints/src/lints/double_literal_format/double_literal_forma import 'package:solid_lints/src/lints/feature_envy/feature_envy_rule.dart'; import 'package:solid_lints/src/lints/function_lines_of_code/function_lines_of_code_rule.dart'; import 'package:solid_lints/src/lints/member_ordering/member_ordering_rule.dart'; +import 'package:solid_lints/src/lints/mirror_test_structure/mirror_test_structure_rule.dart'; import 'package:solid_lints/src/lints/named_parameters_ordering/named_parameters_ordering_rule.dart'; import 'package:solid_lints/src/lints/newline_before_return/newline_before_return_rule.dart'; import 'package:solid_lints/src/lints/no_empty_block/no_empty_block_rule.dart'; @@ -34,7 +35,6 @@ import 'package:solid_lints/src/lints/prefer_early_return/prefer_early_return_ru import 'package:solid_lints/src/lints/prefer_first/prefer_first_rule.dart'; import 'package:solid_lints/src/lints/prefer_last/prefer_last_rule.dart'; import 'package:solid_lints/src/lints/prefer_match_file_name/prefer_match_file_name_rule.dart'; -import 'package:solid_lints/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart'; import 'package:solid_lints/src/lints/proper_super_calls/proper_super_calls_rule.dart'; import 'package:solid_lints/src/lints/use_descriptive_names_for_type_parameters/use_descriptive_names_for_type_parameters_rule.dart'; import 'package:solid_lints/src/lints/use_nearest_context/use_nearest_context_rule.dart'; @@ -83,6 +83,7 @@ class SolidLintsPlugin extends Plugin { FeatureEnvyRule(analysisOptionsLoader: analysisLoader), FunctionLinesOfCodeRule(analysisOptionsLoader: analysisLoader), MemberOrderingRule(analysisOptionsLoader: analysisLoader), + MirrorTestStructureRule(), NamedParametersOrderingRule(analysisOptionsLoader: analysisLoader), NewlineBeforeReturnRule(), NoEmptyBlockRule(analysisOptionsLoader: analysisLoader), @@ -94,7 +95,6 @@ class SolidLintsPlugin extends Plugin { PreferFirstRule(), PreferLastRule(), PreferMatchFileNameRule(analysisOptionsLoader: analysisLoader), - PreferMirrorTestStructureRule(), ProperSuperCallsRule(), UseDescriptiveNamesForTypeParametersRule( analysisOptionsLoader: analysisLoader, diff --git a/lib/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart b/lib/src/lints/mirror_test_structure/mirror_test_structure_rule.dart similarity index 82% rename from lib/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart rename to lib/src/lints/mirror_test_structure/mirror_test_structure_rule.dart index a088e59e..d9994d5d 100644 --- a/lib/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart +++ b/lib/src/lints/mirror_test_structure/mirror_test_structure_rule.dart @@ -1,7 +1,7 @@ import 'package:analyzer/analysis_rule/rule_context.dart'; import 'package:analyzer/analysis_rule/rule_visitor_registry.dart'; import 'package:analyzer/error/error.dart'; -import 'package:solid_lints/src/lints/prefer_mirror_test_structure/visitors/prefer_mirror_test_structure_visitor.dart'; +import 'package:solid_lints/src/lints/mirror_test_structure/visitors/mirror_test_structure_visitor.dart'; import 'package:solid_lints/src/models/solid_lint_rule.dart'; /// Warns when the test file folder structure does not mirror the 'lib/' folder @@ -33,9 +33,9 @@ import 'package:solid_lints/src/models/solid_lint_rule.dart'; /// import 'package:my_app/src/services/auth_service.dart'; // OK /// ``` /// -class PreferMirrorTestStructureRule extends SolidLintRule { +class MirrorTestStructureRule extends SolidLintRule { /// Name of the lint. - static const lintName = 'prefer_mirror_test_structure'; + static const lintName = 'mirror_test_structure'; static const _code = LintCode( lintName, @@ -44,8 +44,8 @@ class PreferMirrorTestStructureRule extends SolidLintRule { correctionMessage: "Move the test file to '{0}'.", ); - /// Creates an instance of [PreferMirrorTestStructureRule]. - PreferMirrorTestStructureRule() + /// Creates an instance of [MirrorTestStructureRule]. + MirrorTestStructureRule() : super( name: lintName, description: @@ -63,7 +63,7 @@ class PreferMirrorTestStructureRule extends SolidLintRule { ) { super.registerNodeProcessors(registry, context); - final visitor = PreferMirrorTestStructureVisitor( + final visitor = MirrorTestStructureVisitor( rule: this, context: context, ); diff --git a/lib/src/lints/prefer_mirror_test_structure/visitors/prefer_mirror_test_structure_visitor.dart b/lib/src/lints/mirror_test_structure/visitors/mirror_test_structure_visitor.dart similarity index 87% rename from lib/src/lints/prefer_mirror_test_structure/visitors/prefer_mirror_test_structure_visitor.dart rename to lib/src/lints/mirror_test_structure/visitors/mirror_test_structure_visitor.dart index c089a7a1..ea12fce8 100644 --- a/lib/src/lints/prefer_mirror_test_structure/visitors/prefer_mirror_test_structure_visitor.dart +++ b/lib/src/lints/mirror_test_structure/visitors/mirror_test_structure_visitor.dart @@ -3,24 +3,24 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:path/path.dart' as p; -import 'package:solid_lints/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart'; +import 'package:solid_lints/src/lints/mirror_test_structure/mirror_test_structure_rule.dart'; /// The AST visitor that checks if test files mirror the folder structure of /// their corresponding implementation files. -class PreferMirrorTestStructureVisitor extends SimpleAstVisitor { +class MirrorTestStructureVisitor extends SimpleAstVisitor { static const _testSuffix = '_test.dart'; static const _dartSuffix = '.dart'; static const _testDirName = 'test'; static const _libDirName = 'lib'; /// The rule that instantiated this visitor. - final PreferMirrorTestStructureRule rule; + final MirrorTestStructureRule rule; /// The context of the current analysis rule. final RuleContext context; - /// Creates a new instance of [PreferMirrorTestStructureVisitor]. - PreferMirrorTestStructureVisitor({ + /// Creates a new instance of [MirrorTestStructureVisitor]. + MirrorTestStructureVisitor({ required this.rule, required this.context, }); diff --git a/pubspec.yaml b/pubspec.yaml index f0c31416..36979b18 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: solid_lints description: Lints for Dart and Flutter based on software industry standards and best practices. -version: 2.0.0 +version: 2.0.1 homepage: https://lints.solid.software repository: https://github.com/solid-software/solid_lints issue_tracker: https://github.com/solid-software/solid_lints/issues diff --git a/test/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule_test.dart b/test/src/lints/mirror_test_structure/mirror_test_structure_rule_test.dart similarity index 96% rename from test/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule_test.dart rename to test/src/lints/mirror_test_structure/mirror_test_structure_rule_test.dart index 60a27fca..f66a1e3a 100644 --- a/test/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule_test.dart +++ b/test/src/lints/mirror_test_structure/mirror_test_structure_rule_test.dart @@ -1,17 +1,17 @@ import 'package:analyzer/error/error.dart'; import 'package:analyzer/src/diagnostic/diagnostic.dart' as diag; import 'package:analyzer_testing/analysis_rule/analysis_rule.dart'; -import 'package:solid_lints/src/lints/prefer_mirror_test_structure/prefer_mirror_test_structure_rule.dart'; +import 'package:solid_lints/src/lints/mirror_test_structure/mirror_test_structure_rule.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; void main() { defineReflectiveSuite(() { - defineReflectiveTests(PreferMirrorTestStructureRuleTest); + defineReflectiveTests(MirrorTestStructureRuleTest); }); } @reflectiveTest -class PreferMirrorTestStructureRuleTest extends AnalysisRuleTest { +class MirrorTestStructureRuleTest extends AnalysisRuleTest { static const _stubContent = 'class AuthService {}'; @override @@ -22,7 +22,7 @@ class PreferMirrorTestStructureRuleTest extends AnalysisRuleTest { @override void setUp() { - rule = PreferMirrorTestStructureRule(); + rule = MirrorTestStructureRule(); newPackage('other_package') ..addFile('lib/services/auth_service.dart', _stubContent); _newLibFile('services/auth_service.dart');