From 715dd4c31465117a330990b3c6ab36849a3fa491 Mon Sep 17 00:00:00 2001 From: DenisBogatirov Date: Fri, 15 Sep 2023 13:47:58 +0300 Subject: [PATCH] Fixes Issue #54 multiple rule reporting (#55) * Fix newline-before-return * Fix avoid-unrelated-type-assertions * Fix avoid-unnecessary-type-casts --------- Co-authored-by: Denis Bogatirov --- .../avoid_unnecessary_type_casts_rule.dart | 3 +-- .../avoid_unrelated_type_assertions_rule.dart | 3 +-- .../newline_before_return/newline_before_return_rule.dart | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart index 97a3690c..e6ccbeeb 100644 --- a/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart +++ b/lib/lints/avoid_unnecessary_type_casts/avoid_unnecessary_type_casts_rule.dart @@ -36,9 +36,8 @@ class AvoidUnnecessaryTypeCastsRule extends SolidLintRule { ErrorReporter reporter, CustomLintContext context, ) { - final visitor = AvoidUnnecessaryTypeCastsVisitor(); - context.registry.addAsExpression((node) { + final visitor = AvoidUnnecessaryTypeCastsVisitor(); visitor.visitAsExpression(node); for (final element in visitor.expressions.entries) { diff --git a/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart b/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart index aa102f9c..117cc49f 100644 --- a/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart +++ b/lib/lints/avoid_unrelated_type_assertions/avoid_unrelated_type_assertions_rule.dart @@ -34,9 +34,8 @@ class AvoidUnrelatedTypeAssertionsRule extends SolidLintRule { ErrorReporter reporter, CustomLintContext context, ) { - final visitor = AvoidUnrelatedTypeAssertionsVisitor(); - context.registry.addIsExpression((node) { + final visitor = AvoidUnrelatedTypeAssertionsVisitor(); visitor.visitIsExpression(node); for (final element in visitor.expressions.entries) { diff --git a/lib/lints/newline_before_return/newline_before_return_rule.dart b/lib/lints/newline_before_return/newline_before_return_rule.dart index c965f359..f97ba0ac 100644 --- a/lib/lints/newline_before_return/newline_before_return_rule.dart +++ b/lib/lints/newline_before_return/newline_before_return_rule.dart @@ -56,9 +56,8 @@ class NewlineBeforeReturnRule extends SolidLintRule { ErrorReporter reporter, CustomLintContext context, ) { - final visitor = NewLineBeforeReturnVisitor(resolver.lineInfo); - context.registry.addReturnStatement((node) { + final visitor = NewLineBeforeReturnVisitor(resolver.lineInfo); visitor.visitReturnStatement(node); for (final element in visitor.statements) {