mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Re-run autocorrect until all correctable issues have been corrected
This commit is contained in:
parent
573881cb8a
commit
f39a7a4cd4
12 changed files with 78 additions and 60 deletions
|
@ -69,24 +69,24 @@ module Ameba::Formatter
|
|||
|
||||
describe "#affected_code" do
|
||||
it "returns nil if there is no such a line number" do
|
||||
source = Source.new %(
|
||||
code = <<-EOF
|
||||
a = 1
|
||||
)
|
||||
EOF
|
||||
location = Crystal::Location.new("filename", 2, 1)
|
||||
subject.affected_code(source, location).should be_nil
|
||||
subject.affected_code(code, location).should be_nil
|
||||
end
|
||||
|
||||
it "returns correct line if it is found" do
|
||||
source = Source.new %(
|
||||
code = <<-EOF
|
||||
a = 1
|
||||
)
|
||||
EOF
|
||||
location = Crystal::Location.new("filename", 1, 1)
|
||||
subject.deansify(subject.affected_code(source, location))
|
||||
subject.deansify(subject.affected_code(code, location))
|
||||
.should eq "> a = 1\n ^\n"
|
||||
end
|
||||
|
||||
it "returns correct line if it is found" do
|
||||
source = Source.new <<-EOF
|
||||
code = <<-EOF
|
||||
# pre:1
|
||||
# pre:2
|
||||
# pre:3
|
||||
|
@ -101,7 +101,7 @@ module Ameba::Formatter
|
|||
EOF
|
||||
|
||||
location = Crystal::Location.new("filename", 6, 1)
|
||||
subject.deansify(subject.affected_code(source, location, context_lines: 3))
|
||||
subject.deansify(subject.affected_code(code, location, context_lines: 3))
|
||||
.should eq <<-STR
|
||||
> # pre:3
|
||||
> # pre:4
|
||||
|
|
|
@ -3,7 +3,8 @@ require "../spec_helper"
|
|||
module Ameba
|
||||
describe Issue do
|
||||
it "accepts rule and message" do
|
||||
issue = Issue.new rule: DummyRule.new,
|
||||
issue = Issue.new code: "",
|
||||
rule: DummyRule.new,
|
||||
location: nil,
|
||||
end_location: nil,
|
||||
message: "Blah",
|
||||
|
@ -15,7 +16,8 @@ module Ameba
|
|||
|
||||
it "accepts location" do
|
||||
location = Crystal::Location.new("path", 3, 2)
|
||||
issue = Issue.new rule: DummyRule.new,
|
||||
issue = Issue.new code: "",
|
||||
rule: DummyRule.new,
|
||||
location: location,
|
||||
end_location: nil,
|
||||
message: "Blah",
|
||||
|
@ -27,7 +29,8 @@ module Ameba
|
|||
|
||||
it "accepts end_location" do
|
||||
location = Crystal::Location.new("path", 3, 2)
|
||||
issue = Issue.new rule: DummyRule.new,
|
||||
issue = Issue.new code: "",
|
||||
rule: DummyRule.new,
|
||||
location: nil,
|
||||
end_location: location,
|
||||
message: "Blah",
|
||||
|
@ -38,7 +41,8 @@ module Ameba
|
|||
end
|
||||
|
||||
it "accepts status" do
|
||||
issue = Issue.new rule: DummyRule.new,
|
||||
issue = Issue.new code: "",
|
||||
rule: DummyRule.new,
|
||||
location: nil,
|
||||
end_location: nil,
|
||||
message: "",
|
||||
|
@ -50,7 +54,8 @@ module Ameba
|
|||
end
|
||||
|
||||
it "sets status to :enabled by default" do
|
||||
issue = Issue.new rule: DummyRule.new,
|
||||
issue = Issue.new code: "",
|
||||
rule: DummyRule.new,
|
||||
location: nil,
|
||||
end_location: nil,
|
||||
message: ""
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require "../../spec_helper"
|
||||
|
||||
private def dummy_issue(message,
|
||||
private def dummy_issue(code,
|
||||
message,
|
||||
position : {Int32, Int32}?,
|
||||
end_position : {Int32, Int32}?,
|
||||
path = "")
|
||||
|
@ -9,6 +10,7 @@ private def dummy_issue(message,
|
|||
end_location = Crystal::Location.new(path, *end_position) if end_position
|
||||
|
||||
Ameba::Issue.new(
|
||||
code: code,
|
||||
rule: Ameba::DummyRule.new,
|
||||
location: location,
|
||||
end_location: end_location,
|
||||
|
@ -25,7 +27,7 @@ private def expect_invalid_location(code,
|
|||
expect_raises Exception, exception_message, file, line do
|
||||
Ameba::Spec::AnnotatedSource.new(
|
||||
lines: code.lines,
|
||||
issues: [dummy_issue("Message", position, end_position, "path")]
|
||||
issues: [dummy_issue(code, "Message", position, end_position, "path")]
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue