Skip to content

Commit

Permalink
issue-167. fixed after comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shaark committed Dec 5, 2024
2 parents b631295 + 3ee83ca commit 199cca6
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 41 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.4
- Added exclude classes, methods, functions into avoid_returning_widgets,avoid_unused_parameters, cyclomatic_complexity, function_lines_of_code, no_empty_bloc, number_of_parameters
- Changed exclude parameter name into unction lines of code from excludeNames to exclude

## 0.2.4

- Fixed an issue with `prefer_early_retrun` for throw expression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
import 'package:solid_lints/src/lints/avoid_unused_parameters/models/avoid_unused_parameters.dart';
Expand Down Expand Up @@ -96,14 +95,14 @@ class AvoidUnusedParametersRule extends SolidLintRule<AvoidUnusedParameters> {
) {
context.registry.addDeclaration((node) {
final isIgnored = config.parameters.exclude.shouldIgnore(node);

if (!isIgnored) {
final visitor = AvoidUnusedParametersVisitor();
node.accept(visitor);

for (final element in visitor.unusedParameters) {
reporter.atNode(element, code);
}
if (isIgnored) return;

final visitor = AvoidUnusedParametersVisitor();
node.accept(visitor);

for (final element in visitor.unusedParameters) {
reporter.atNode(element, code);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ class CyclomaticComplexityRule
context.registry.addDeclaration((declarationNode) {
final isIgnored =
config.parameters.exclude.shouldIgnore(declarationNode);
if (!isIgnored) {
final visitor = CyclomaticComplexityFlowVisitor();
node.visitChildren(visitor);
if (isIgnored) return;

if (visitor.complexityEntities.length + 1 >
config.parameters.maxComplexity) {
reporter.atNode(node, code);
}
final visitor = CyclomaticComplexityFlowVisitor();
node.visitChildren(visitor);

if (visitor.complexityEntities.length + 1 >
config.parameters.maxComplexity) {
reporter.atNode(node, code);
}
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ class FunctionLinesOfCodeRule
context.registry.addDeclaration((declarationNode) {
final isIgnored = config.parameters.exclude.shouldIgnore(declarationNode);

if (!isIgnored) {
context.registry.addMethodDeclaration(checkNode);
context.registry.addFunctionDeclaration(checkNode);
context.registry.addFunctionExpression(checkNode);
}
if (isIgnored) return;

context.registry.addMethodDeclaration(checkNode);
context.registry.addFunctionDeclaration(checkNode);
context.registry.addFunctionExpression(checkNode);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:solid_lints/src/common/parameters/excluded_identifiers_list_parameter.dart';

/// A data model class that represents the "avoid returning widgets" input
/// A data model class that represents the "no empty block" input
/// parameters.
class NoEmptyBlockParameters {
/// A list of methods that should be excluded from the lint.
Expand Down
12 changes: 6 additions & 6 deletions lib/src/lints/no_empty_block/no_empty_block_rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class NoEmptyBlockRule extends SolidLintRule<NoEmptyBlockParameters> {
) {
context.registry.addDeclaration((node) {
final isIgnored = config.parameters.exclude.shouldIgnore(node);
if (!isIgnored) {
final visitor = NoEmptyBlockVisitor();
node.accept(visitor);
if (isIgnored) return;

final visitor = NoEmptyBlockVisitor();
node.accept(visitor);

for (final emptyBlock in visitor.emptyBlocks) {
reporter.atNode(emptyBlock, code);
}
for (final emptyBlock in visitor.emptyBlocks) {
reporter.atNode(emptyBlock, code);
}
});
}
Expand Down
20 changes: 10 additions & 10 deletions lint_test/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ custom_lint:
- cyclomatic_complexity:
max_complexity: 4
exclude:
- method_name: excludeMethod
class_name: Exclude
- class_name: Exclude
method_name: excludeMethod
- method_name: excludeMethod
- number_of_parameters:
max_parameters: 2
exclude:
- method_name: avoidNumberOfParameters
class_name: Exclude
- class_name: Exclude
method_name: avoidNumberOfParameters
- method_name: avoidNumberOfParameters
- function_lines_of_code:
max_lines: 50
Expand All @@ -24,8 +24,8 @@ custom_lint:
- avoid_global_state
- avoid_returning_widgets:
exclude:
- method_name: excludeWidgetMethod
class_name: ExcludeWidget
- class_name: ExcludeWidget
method_name: excludeWidgetMethod
- method_name: excludeMethod
- avoid_unnecessary_setstate
- double_literal_format
Expand All @@ -34,14 +34,14 @@ custom_lint:
- avoid_unrelated_type_assertions
- avoid_unused_parameters:
exclude:
- method_name: excludeMethod
class_name: Exclude
- class_name: Exclude
method_name: excludeMethod
- method_name: excludeMethod
- newline_before_return
- no_empty_block:
exclude:
- method_name: excludeMethod
class_name: Exclude
- class_name: Exclude
method_name: excludeMethod
- method_name: excludeMethod
- no_equal_then_else
- avoid_debug_print_in_release
Expand Down
4 changes: 2 additions & 2 deletions lint_test/avoid_returning_widget_test/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ custom_lint:
rules:
- avoid_returning_widgets:
exclude:
- method_name: excludeWidgetMethod
class_name: ExcludeWidget
- class_name: ExcludeWidget
method_name: excludeWidgetMethod
- method_name: excludeMethod
4 changes: 2 additions & 2 deletions lint_test/avoid_unused_parameters_test/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ custom_lint:
rules:
- avoid_unused_parameters:
exclude:
- method_name: excludeMethod
class_name: Exclude
- class_name: Exclude
method_name: excludeMethod
- method_name: excludeMethod

0 comments on commit 199cca6

Please sign in to comment.