mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Add conditional check using semantic version
This commit is contained in:
parent
2f29999106
commit
1f4dda1c4a
2 changed files with 12 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
require "../../../spec_helper"
|
require "../../../spec_helper"
|
||||||
|
require "semantic_version"
|
||||||
|
|
||||||
module Ameba::Rule::Lint
|
module Ameba::Rule::Lint
|
||||||
describe EmptyEnsure do
|
describe EmptyEnsure do
|
||||||
|
@ -63,7 +64,11 @@ module Ameba::Rule::Lint
|
||||||
issue.rule.should_not be_nil
|
issue.rule.should_not be_nil
|
||||||
# TODO: refactor this in next release
|
# TODO: refactor this in next release
|
||||||
# Crystal 1.4 changes the start location of Crystal::ExceptionHandler
|
# Crystal 1.4 changes the start location of Crystal::ExceptionHandler
|
||||||
# issue.location.to_s.should eq "source.cr:2:3"
|
if SemanticVersion.parse(Crystal::VERSION) <= SemanticVersion.parse("1.3.2")
|
||||||
|
issue.location.to_s.should eq "source.cr:2:3"
|
||||||
|
else
|
||||||
|
issue.location.to_s.should eq "source.cr:1:1"
|
||||||
|
end
|
||||||
issue.end_location.to_s.should eq "source.cr:6:3"
|
issue.end_location.to_s.should eq "source.cr:6:3"
|
||||||
issue.message.should eq "Empty `ensure` block detected"
|
issue.message.should eq "Empty `ensure` block detected"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
require "../../../spec_helper"
|
require "../../../spec_helper"
|
||||||
|
require "semantic_version"
|
||||||
|
|
||||||
private def check_shadowed(source, exceptions)
|
private def check_shadowed(source, exceptions)
|
||||||
s = Ameba::Source.new source
|
s = Ameba::Source.new source
|
||||||
|
@ -168,7 +169,11 @@ module Ameba::Rule::Lint
|
||||||
issue.rule.should_not be_nil
|
issue.rule.should_not be_nil
|
||||||
# TODO: refactor this in next release
|
# TODO: refactor this in next release
|
||||||
# Crystal 1.4 changes the start location of Crystal::ExceptionHandler
|
# Crystal 1.4 changes the start location of Crystal::ExceptionHandler
|
||||||
# issue.location.to_s.should eq "source.cr:2:3"
|
if SemanticVersion.parse(Crystal::VERSION) <= SemanticVersion.parse("1.3.2")
|
||||||
|
issue.location.to_s.should eq "source.cr:2:3"
|
||||||
|
else
|
||||||
|
issue.location.to_s.should eq "source.cr:1:1"
|
||||||
|
end
|
||||||
issue.end_location.to_s.should eq "source.cr:4:3"
|
issue.end_location.to_s.should eq "source.cr:4:3"
|
||||||
issue.message.should eq(
|
issue.message.should eq(
|
||||||
"Exception handler has shadowed exceptions: IndexError"
|
"Exception handler has shadowed exceptions: IndexError"
|
||||||
|
|
Loading…
Reference in a new issue