mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
RedundantStringCoercion: do not report to_s with named args
closes #160
This commit is contained in:
parent
3448de30da
commit
7f501a1df5
2 changed files with 12 additions and 1 deletions
|
@ -66,6 +66,13 @@ module Ameba::Rule::Lint
|
||||||
subject.catch(s).should be_valid
|
subject.catch(s).should be_valid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't report if Object#to_s is called with named args" do
|
||||||
|
s = Source.new %q(
|
||||||
|
"0x#{250.to_s base: 16}"
|
||||||
|
)
|
||||||
|
subject.catch(s).should be_valid
|
||||||
|
end
|
||||||
|
|
||||||
it "reports rule, location and message" do
|
it "reports rule, location and message" do
|
||||||
s = Source.new %q(
|
s = Source.new %q(
|
||||||
"Hello, #{name1.to_s}"
|
"Hello, #{name1.to_s}"
|
||||||
|
|
|
@ -36,7 +36,11 @@ module Ameba::Rule::Lint
|
||||||
|
|
||||||
private def string_coercion_nodes(node)
|
private def string_coercion_nodes(node)
|
||||||
node.expressions.select do |e|
|
node.expressions.select do |e|
|
||||||
e.is_a?(Crystal::Call) && e.name == "to_s" && e.args.size.zero? && e.obj
|
e.is_a?(Crystal::Call) &&
|
||||||
|
e.name == "to_s" &&
|
||||||
|
e.args.size.zero? &&
|
||||||
|
e.named_args.nil? &&
|
||||||
|
e.obj
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue