Skip to content

Commit 199cca6

Browse files
author
shaark
committed
issue-167. fixed after comments
2 parents b631295 + 3ee83ca commit 199cca6

File tree

9 files changed

+44
-41
lines changed

9 files changed

+44
-41
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.4
2+
- Added exclude classes, methods, functions into avoid_returning_widgets,avoid_unused_parameters, cyclomatic_complexity, function_lines_of_code, no_empty_bloc, number_of_parameters
3+
- Changed exclude parameter name into unction lines of code from excludeNames to exclude
4+
15
## 0.2.4
26

37
- Fixed an issue with `prefer_early_retrun` for throw expression

lib/src/lints/avoid_unused_parameters/avoid_unused_parameters_rule.dart

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'package:analyzer/error/listener.dart';
32
import 'package:custom_lint_builder/custom_lint_builder.dart';
43
import 'package:solid_lints/src/lints/avoid_unused_parameters/models/avoid_unused_parameters.dart';
@@ -96,14 +95,14 @@ class AvoidUnusedParametersRule extends SolidLintRule<AvoidUnusedParameters> {
9695
) {
9796
context.registry.addDeclaration((node) {
9897
final isIgnored = config.parameters.exclude.shouldIgnore(node);
99-
100-
if (!isIgnored) {
101-
final visitor = AvoidUnusedParametersVisitor();
102-
node.accept(visitor);
10398

104-
for (final element in visitor.unusedParameters) {
105-
reporter.atNode(element, code);
106-
}
99+
if (isIgnored) return;
100+
101+
final visitor = AvoidUnusedParametersVisitor();
102+
node.accept(visitor);
103+
104+
for (final element in visitor.unusedParameters) {
105+
reporter.atNode(element, code);
107106
}
108107
});
109108
}

lib/src/lints/cyclomatic_complexity/cyclomatic_complexity_rule.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ class CyclomaticComplexityRule
5555
context.registry.addDeclaration((declarationNode) {
5656
final isIgnored =
5757
config.parameters.exclude.shouldIgnore(declarationNode);
58-
if (!isIgnored) {
59-
final visitor = CyclomaticComplexityFlowVisitor();
60-
node.visitChildren(visitor);
58+
if (isIgnored) return;
6159

62-
if (visitor.complexityEntities.length + 1 >
63-
config.parameters.maxComplexity) {
64-
reporter.atNode(node, code);
65-
}
60+
final visitor = CyclomaticComplexityFlowVisitor();
61+
node.visitChildren(visitor);
62+
63+
if (visitor.complexityEntities.length + 1 >
64+
config.parameters.maxComplexity) {
65+
reporter.atNode(node, code);
6666
}
6767
});
6868
});

lib/src/lints/function_lines_of_code/function_lines_of_code_rule.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ class FunctionLinesOfCodeRule
5353
context.registry.addDeclaration((declarationNode) {
5454
final isIgnored = config.parameters.exclude.shouldIgnore(declarationNode);
5555

56-
if (!isIgnored) {
57-
context.registry.addMethodDeclaration(checkNode);
58-
context.registry.addFunctionDeclaration(checkNode);
59-
context.registry.addFunctionExpression(checkNode);
60-
}
56+
if (isIgnored) return;
57+
58+
context.registry.addMethodDeclaration(checkNode);
59+
context.registry.addFunctionDeclaration(checkNode);
60+
context.registry.addFunctionExpression(checkNode);
6161
});
6262
}
6363

lib/src/lints/no_empty_block/models/no_empty_block_parameters.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:solid_lints/src/common/parameters/excluded_identifiers_list_parameter.dart';
22

3-
/// A data model class that represents the "avoid returning widgets" input
3+
/// A data model class that represents the "no empty block" input
44
/// parameters.
55
class NoEmptyBlockParameters {
66
/// A list of methods that should be excluded from the lint.

lib/src/lints/no_empty_block/no_empty_block_rule.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ class NoEmptyBlockRule extends SolidLintRule<NoEmptyBlockParameters> {
7979
) {
8080
context.registry.addDeclaration((node) {
8181
final isIgnored = config.parameters.exclude.shouldIgnore(node);
82-
if (!isIgnored) {
83-
final visitor = NoEmptyBlockVisitor();
84-
node.accept(visitor);
82+
if (isIgnored) return;
83+
84+
final visitor = NoEmptyBlockVisitor();
85+
node.accept(visitor);
8586

86-
for (final emptyBlock in visitor.emptyBlocks) {
87-
reporter.atNode(emptyBlock, code);
88-
}
87+
for (final emptyBlock in visitor.emptyBlocks) {
88+
reporter.atNode(emptyBlock, code);
8989
}
9090
});
9191
}

lint_test/analysis_options.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ custom_lint:
77
- cyclomatic_complexity:
88
max_complexity: 4
99
exclude:
10-
- method_name: excludeMethod
11-
class_name: Exclude
10+
- class_name: Exclude
11+
method_name: excludeMethod
1212
- method_name: excludeMethod
1313
- number_of_parameters:
1414
max_parameters: 2
1515
exclude:
16-
- method_name: avoidNumberOfParameters
17-
class_name: Exclude
16+
- class_name: Exclude
17+
method_name: avoidNumberOfParameters
1818
- method_name: avoidNumberOfParameters
1919
- function_lines_of_code:
2020
max_lines: 50
@@ -24,8 +24,8 @@ custom_lint:
2424
- avoid_global_state
2525
- avoid_returning_widgets:
2626
exclude:
27-
- method_name: excludeWidgetMethod
28-
class_name: ExcludeWidget
27+
- class_name: ExcludeWidget
28+
method_name: excludeWidgetMethod
2929
- method_name: excludeMethod
3030
- avoid_unnecessary_setstate
3131
- double_literal_format
@@ -34,14 +34,14 @@ custom_lint:
3434
- avoid_unrelated_type_assertions
3535
- avoid_unused_parameters:
3636
exclude:
37-
- method_name: excludeMethod
38-
class_name: Exclude
37+
- class_name: Exclude
38+
method_name: excludeMethod
3939
- method_name: excludeMethod
4040
- newline_before_return
4141
- no_empty_block:
4242
exclude:
43-
- method_name: excludeMethod
44-
class_name: Exclude
43+
- class_name: Exclude
44+
method_name: excludeMethod
4545
- method_name: excludeMethod
4646
- no_equal_then_else
4747
- avoid_debug_print_in_release

lint_test/avoid_returning_widget_test/analysis_options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ custom_lint:
66
rules:
77
- avoid_returning_widgets:
88
exclude:
9-
- method_name: excludeWidgetMethod
10-
class_name: ExcludeWidget
9+
- class_name: ExcludeWidget
10+
method_name: excludeWidgetMethod
1111
- method_name: excludeMethod

lint_test/avoid_unused_parameters_test/analysis_options.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ custom_lint:
66
rules:
77
- avoid_unused_parameters:
88
exclude:
9-
- method_name: excludeMethod
10-
class_name: Exclude
9+
- class_name: Exclude
10+
method_name: excludeMethod
1111
- method_name: excludeMethod

0 commit comments

Comments
 (0)