Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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),
Expand All @@ -94,7 +95,6 @@ class SolidLintsPlugin extends Plugin {
PreferFirstRule(),
PreferLastRule(),
PreferMatchFileNameRule(analysisOptionsLoader: analysisLoader),
PreferMirrorTestStructureRule(),
ProperSuperCallsRule(),
UseDescriptiveNamesForTypeParametersRule(
analysisOptionsLoader: analysisLoader,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<void> {
class MirrorTestStructureRule extends SolidLintRule<void> {
/// Name of the lint.
static const lintName = 'prefer_mirror_test_structure';
static const lintName = 'mirror_test_structure';

static const _code = LintCode(
lintName,
Expand All @@ -44,8 +44,8 @@ class PreferMirrorTestStructureRule extends SolidLintRule<void> {
correctionMessage: "Move the test file to '{0}'.",
);

/// Creates an instance of [PreferMirrorTestStructureRule].
PreferMirrorTestStructureRule()
/// Creates an instance of [MirrorTestStructureRule].
MirrorTestStructureRule()
: super(
name: lintName,
description:
Expand All @@ -63,7 +63,7 @@ class PreferMirrorTestStructureRule extends SolidLintRule<void> {
) {
super.registerNodeProcessors(registry, context);

final visitor = PreferMirrorTestStructureVisitor(
final visitor = MirrorTestStructureVisitor(
rule: this,
context: context,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
class MirrorTestStructureVisitor extends SimpleAstVisitor<void> {
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,
});
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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');
Expand Down
Loading