From af395a3c13cbaa2104921f4937da4576dc37e0cf Mon Sep 17 00:00:00 2001 From: Vitalii Elenhaupt Date: Thu, 25 Apr 2019 08:47:37 +0300 Subject: [PATCH] Do not report if disabled rules exist closes #101 --- spec/ameba/runner_spec.cr | 15 +++++++++++++++ src/ameba/runner.cr | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/spec/ameba/runner_spec.cr b/spec/ameba/runner_spec.cr index 66a0188d..1d3dc2ca 100644 --- a/spec/ameba/runner_spec.cr +++ b/spec/ameba/runner_spec.cr @@ -150,6 +150,21 @@ module Ameba Runner.new(rules, [s], formatter, Severity::Warning).run.success?.should be_true Runner.new(rules, [s], formatter, Severity::Refactoring).run.success?.should be_false end + + it "returns false if issue is disabled" do + rules = [NamedRule.new] of Rule::Base + source = Source.new %( + def foo + bar = 1 # ameba:disable #{NamedRule.name} + end + ) + source.add_issue NamedRule.new, location: {2, 1}, + message: "Useless assignment" + + Runner + .new(rules, [source], formatter, default_severity) + .run.success?.should be_true + end end end end diff --git a/src/ameba/runner.cr b/src/ameba/runner.cr index 9bb25683..0677c666 100644 --- a/src/ameba/runner.cr +++ b/src/ameba/runner.cr @@ -112,7 +112,9 @@ module Ameba # def success? @sources.all? do |source| - source.issues.none? { |issue| issue.rule.severity <= @severity } + source.issues + .reject(&.disabled?) + .none? { |issue| issue.rule.severity <= @severity } end end