mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Consistently use CRYSTAL
marker for heredocs with crystal code
This commit is contained in:
parent
2cb8c1381f
commit
071a8b7afb
2 changed files with 10 additions and 10 deletions
|
@ -39,7 +39,7 @@ module Ameba::Formatter
|
||||||
|
|
||||||
describe "#context" do
|
describe "#context" do
|
||||||
it "returns correct pre/post context lines" do
|
it "returns correct pre/post context lines" do
|
||||||
source = Source.new <<-EOF
|
source = Source.new <<-CRYSTAL
|
||||||
# pre:1
|
# pre:1
|
||||||
# pre:2
|
# pre:2
|
||||||
# pre:3
|
# pre:3
|
||||||
|
@ -51,7 +51,7 @@ module Ameba::Formatter
|
||||||
# post:3
|
# post:3
|
||||||
# post:4
|
# post:4
|
||||||
# post:5
|
# post:5
|
||||||
EOF
|
CRYSTAL
|
||||||
|
|
||||||
subject.context(source.lines, lineno: 6, context_lines: 3)
|
subject.context(source.lines, lineno: 6, context_lines: 3)
|
||||||
.should eq({<<-PRE.lines, <<-POST.lines
|
.should eq({<<-PRE.lines, <<-POST.lines
|
||||||
|
@ -69,24 +69,24 @@ module Ameba::Formatter
|
||||||
|
|
||||||
describe "#affected_code" do
|
describe "#affected_code" do
|
||||||
it "returns nil if there is no such a line number" do
|
it "returns nil if there is no such a line number" do
|
||||||
code = <<-EOF
|
code = <<-CRYSTAL
|
||||||
a = 1
|
a = 1
|
||||||
EOF
|
CRYSTAL
|
||||||
location = Crystal::Location.new("filename", 2, 1)
|
location = Crystal::Location.new("filename", 2, 1)
|
||||||
subject.affected_code(code, location).should be_nil
|
subject.affected_code(code, location).should be_nil
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns correct line if it is found" do
|
it "returns correct line if it is found" do
|
||||||
code = <<-EOF
|
code = <<-CRYSTAL
|
||||||
a = 1
|
a = 1
|
||||||
EOF
|
CRYSTAL
|
||||||
location = Crystal::Location.new("filename", 1, 1)
|
location = Crystal::Location.new("filename", 1, 1)
|
||||||
subject.deansify(subject.affected_code(code, location))
|
subject.deansify(subject.affected_code(code, location))
|
||||||
.should eq "> a = 1\n ^\n"
|
.should eq "> a = 1\n ^\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns correct line if it is found" do
|
it "returns correct line if it is found" do
|
||||||
code = <<-EOF
|
code = <<-CRYSTAL
|
||||||
# pre:1
|
# pre:1
|
||||||
# pre:2
|
# pre:2
|
||||||
# pre:3
|
# pre:3
|
||||||
|
@ -98,7 +98,7 @@ module Ameba::Formatter
|
||||||
# post:3
|
# post:3
|
||||||
# post:4
|
# post:4
|
||||||
# post:5
|
# post:5
|
||||||
EOF
|
CRYSTAL
|
||||||
|
|
||||||
location = Crystal::Location.new("filename", 6, 1)
|
location = Crystal::Location.new("filename", 6, 1)
|
||||||
subject.deansify(subject.affected_code(code, location, context_lines: 3))
|
subject.deansify(subject.affected_code(code, location, context_lines: 3))
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "../../../spec_helper"
|
||||||
|
|
||||||
module Ameba::Rule::Metrics
|
module Ameba::Rule::Metrics
|
||||||
subject = CyclomaticComplexity.new
|
subject = CyclomaticComplexity.new
|
||||||
complex_method = <<-CODE
|
complex_method = <<-CRYSTAL
|
||||||
def hello(a, b, c)
|
def hello(a, b, c)
|
||||||
if a && b && c
|
if a && b && c
|
||||||
begin
|
begin
|
||||||
|
@ -15,7 +15,7 @@ module Ameba::Rule::Metrics
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
CODE
|
CRYSTAL
|
||||||
|
|
||||||
describe CyclomaticComplexity do
|
describe CyclomaticComplexity do
|
||||||
it "passes for empty methods" do
|
it "passes for empty methods" do
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue