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