Avoid duplicated sections in a generated TODO file (additional fix)

This commit is contained in:
Vitalii Elenhaupt 2019-10-27 22:56:53 +02:00
parent 111596541b
commit 4ae0195628
No known key found for this signature in database
GPG key ID: CD0BF17825928BC0
3 changed files with 7 additions and 3 deletions

View file

@ -82,6 +82,7 @@ module Ameba
s1 = Source.new "a = 1", "source1.cr" s1 = Source.new "a = 1", "source1.cr"
s2 = Source.new "a = 1", "source2.cr" s2 = Source.new "a = 1", "source2.cr"
s1.add_issue DummyRule.new, {1, 2}, "message1" s1.add_issue DummyRule.new, {1, 2}, "message1"
s1.add_issue NamedRule.new, {1, 2}, "message1"
s1.add_issue DummyRule.new, {2, 2}, "message1" s1.add_issue DummyRule.new, {2, 2}, "message1"
s2.add_issue DummyRule.new, {2, 2}, "message2" s2.add_issue DummyRule.new, {2, 2}, "message2"

View file

@ -41,8 +41,7 @@ module Ameba::Formatter
Hash(Rule::Base, Array(Issue)).new.tap do |h| Hash(Rule::Base, Array(Issue)).new.tap do |h|
issues.each do |issue| issues.each do |issue|
next if issue.disabled? || issue.rule.is_a? Rule::Lint::Syntax next if issue.disabled? || issue.rule.is_a? Rule::Lint::Syntax
h[issue.rule] ||= Array(Issue).new (h[issue.rule] ||= Array(Issue).new) << issue
h[issue.rule] << issue
end end
end end
end end

View file

@ -106,7 +106,11 @@ module Ameba::Rule
end end
def ==(other) def ==(other)
self.name == other.name name == other.try &.name
end
def hash
name.hash
end end
macro issue_for(*args) macro issue_for(*args)