mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Avoid duplicated sections in a generated TODO file
This commit is contained in:
parent
19d9223ec1
commit
111596541b
3 changed files with 38 additions and 0 deletions
|
@ -73,5 +73,15 @@ module Ameba::Rule
|
||||||
DummyRule.parsed_doc.should eq "Dummy Rule which does nothing."
|
DummyRule.parsed_doc.should eq "Dummy Rule which does nothing."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#==" do
|
||||||
|
it "returns true if rule has the same name" do
|
||||||
|
DummyRule.new.should eq(DummyRule.new)
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns false if rule has a different name" do
|
||||||
|
DummyRule.new.should_not eq(NoProperties.new)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,6 +76,30 @@ module Ameba
|
||||||
create_todo.should contain "Excluded:\n - source.cr"
|
create_todo.should contain "Excluded:\n - source.cr"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with multiple issues" do
|
||||||
|
formatter = Formatter::TODOFormatter.new IO::Memory.new
|
||||||
|
|
||||||
|
s1 = Source.new "a = 1", "source1.cr"
|
||||||
|
s2 = Source.new "a = 1", "source2.cr"
|
||||||
|
s1.add_issue DummyRule.new, {1, 2}, "message1"
|
||||||
|
s1.add_issue DummyRule.new, {2, 2}, "message1"
|
||||||
|
s2.add_issue DummyRule.new, {2, 2}, "message2"
|
||||||
|
|
||||||
|
file = formatter.finished([s1, s2])
|
||||||
|
content = File.read(file.not_nil!.path)
|
||||||
|
content.should contain <<-CONTENT
|
||||||
|
# Problems found: 3
|
||||||
|
# Run `ameba --only Ameba/DummyRule` for details
|
||||||
|
Ameba/DummyRule:
|
||||||
|
Description: Dummy rule that does nothing.
|
||||||
|
Enabled: true
|
||||||
|
Severity: Convention
|
||||||
|
Excluded:
|
||||||
|
- source1.cr
|
||||||
|
- source2.cr
|
||||||
|
CONTENT
|
||||||
|
end
|
||||||
|
|
||||||
context "when invalid syntax" do
|
context "when invalid syntax" do
|
||||||
it "does generate todo file" do
|
it "does generate todo file" do
|
||||||
formatter = Formatter::TODOFormatter.new IO::Memory.new
|
formatter = Formatter::TODOFormatter.new IO::Memory.new
|
||||||
|
|
|
@ -105,6 +105,10 @@ module Ameba::Rule
|
||||||
SPECIAL.includes? name
|
SPECIAL.includes? name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ==(other)
|
||||||
|
self.name == other.name
|
||||||
|
end
|
||||||
|
|
||||||
macro issue_for(*args)
|
macro issue_for(*args)
|
||||||
source.add_issue self, {{*args}}
|
source.add_issue self, {{*args}}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue