mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Use square brackets for %w
and %i
array literals
This commit is contained in:
parent
06dc201344
commit
10b577d23a
27 changed files with 101 additions and 99 deletions
|
@ -6,41 +6,41 @@ module Ameba::Rule::Lint
|
|||
|
||||
it "passes if percent arrays are written correctly" do
|
||||
s = Source.new %q(
|
||||
%i(one two three)
|
||||
%w(one two three)
|
||||
%i[one two three]
|
||||
%w[one two three]
|
||||
|
||||
%i(1 2 3)
|
||||
%w(1 2 3)
|
||||
%i[1 2 3]
|
||||
%w[1 2 3]
|
||||
|
||||
%i()
|
||||
%w()
|
||||
%i[]
|
||||
%w[]
|
||||
)
|
||||
subject.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "fails if string percent array has commas" do
|
||||
s = Source.new %( %w(one, two) )
|
||||
s = Source.new %( %w[one, two] )
|
||||
subject.catch(s).should_not be_valid
|
||||
end
|
||||
|
||||
it "fails if string percent array has quotes" do
|
||||
s = Source.new %( %w("one" "two") )
|
||||
s = Source.new %( %w["one" "two"] )
|
||||
subject.catch(s).should_not be_valid
|
||||
end
|
||||
|
||||
it "fails if symbols percent array has commas" do
|
||||
s = Source.new %( %i(one, two) )
|
||||
s = Source.new %( %i[one, two] )
|
||||
subject.catch(s).should_not be_valid
|
||||
end
|
||||
|
||||
it "fails if symbols percent array has a colon" do
|
||||
s = Source.new %( %i(:one :two) )
|
||||
s = Source.new %( %i[:one :two] )
|
||||
subject.catch(s).should_not be_valid
|
||||
end
|
||||
|
||||
it "reports rule, location and message for %i" do
|
||||
s = Source.new %(
|
||||
%i(:one)
|
||||
%i[:one]
|
||||
), "source.cr"
|
||||
|
||||
subject.catch(s).should_not be_valid
|
||||
|
@ -54,7 +54,7 @@ module Ameba::Rule::Lint
|
|||
|
||||
it "reports rule, location and message for %w" do
|
||||
s = Source.new %(
|
||||
%w("one")
|
||||
%w["one"]
|
||||
), "source.cr"
|
||||
|
||||
subject.catch(s).should_not be_valid
|
||||
|
@ -71,14 +71,14 @@ module Ameba::Rule::Lint
|
|||
it "#string_array_unwanted_symbols" do
|
||||
rule = PercentArrays.new
|
||||
rule.string_array_unwanted_symbols = ","
|
||||
s = Source.new %( %w("one") )
|
||||
s = Source.new %( %w["one"] )
|
||||
rule.catch(s).should be_valid
|
||||
end
|
||||
|
||||
it "#symbol_array_unwanted_symbols" do
|
||||
rule = PercentArrays.new
|
||||
rule.symbol_array_unwanted_symbols = ","
|
||||
s = Source.new %( %i(:one) )
|
||||
s = Source.new %( %i[:one] )
|
||||
rule.catch(s).should be_valid
|
||||
end
|
||||
end
|
||||
|
|
|
@ -977,7 +977,7 @@ module Ameba::Rule::Lint
|
|||
s = Source.new %(
|
||||
foo = 22
|
||||
|
||||
{% for x in %w(foo) %}
|
||||
{% for x in %w[foo] %}
|
||||
add({{ x.id }})
|
||||
{% end %}
|
||||
)
|
||||
|
@ -988,7 +988,7 @@ module Ameba::Rule::Lint
|
|||
s = Source.new %(
|
||||
foo = 22
|
||||
|
||||
{% for x in %w(bar) %}
|
||||
{% for x in %w[bar] %}
|
||||
puts {{ "foo".id }}
|
||||
{% end %}
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue