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
|
@ -5,27 +5,27 @@ module Ameba::Cli
|
|||
describe "Cmd" do
|
||||
describe ".run" do
|
||||
it "runs ameba" do
|
||||
r = Cli.run %w(-f silent -c spec/fixtures/config.yml spec/fixtures/source.cr)
|
||||
r = Cli.run %w[-f silent -c spec/fixtures/config.yml spec/fixtures/source.cr]
|
||||
r.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe ".parse_args" do
|
||||
%w(-s --silent).each do |flag|
|
||||
%w[-s --silent].each do |flag|
|
||||
it "accepts #{flag} flag" do
|
||||
c = Cli.parse_args [flag]
|
||||
c.formatter.should eq :silent
|
||||
end
|
||||
end
|
||||
|
||||
%w(-c --config).each do |flag|
|
||||
%w[-c --config].each do |flag|
|
||||
it "accepts #{flag} flag" do
|
||||
c = Cli.parse_args [flag, "config.yml"]
|
||||
c.config.should eq Path["config.yml"]
|
||||
end
|
||||
end
|
||||
|
||||
%w(-f --format).each do |flag|
|
||||
%w[-f --format].each do |flag|
|
||||
it "accepts #{flag} flag" do
|
||||
c = Cli.parse_args [flag, "my-formatter"]
|
||||
c.formatter.should eq "my-formatter"
|
||||
|
@ -34,68 +34,68 @@ module Ameba::Cli
|
|||
|
||||
it "accepts --only flag" do
|
||||
c = Cli.parse_args ["--only", "RULE1,RULE2"]
|
||||
c.only.should eq %w(RULE1 RULE2)
|
||||
c.only.should eq %w[RULE1 RULE2]
|
||||
end
|
||||
|
||||
it "accepts --except flag" do
|
||||
c = Cli.parse_args ["--except", "RULE1,RULE2"]
|
||||
c.except.should eq %w(RULE1 RULE2)
|
||||
c.except.should eq %w[RULE1 RULE2]
|
||||
end
|
||||
|
||||
it "defaults rules? flag to false" do
|
||||
c = Cli.parse_args %w(spec/fixtures/source.cr)
|
||||
c = Cli.parse_args %w[spec/fixtures/source.cr]
|
||||
c.rules?.should be_false
|
||||
end
|
||||
|
||||
it "defaults skip_reading_config? flag to false" do
|
||||
c = Cli.parse_args %w(spec/fixtures/source.cr)
|
||||
c = Cli.parse_args %w[spec/fixtures/source.cr]
|
||||
c.skip_reading_config?.should be_false
|
||||
end
|
||||
|
||||
it "accepts --rules flag" do
|
||||
c = Cli.parse_args %w(--rules)
|
||||
c = Cli.parse_args %w[--rules]
|
||||
c.rules?.should eq true
|
||||
end
|
||||
|
||||
it "defaults all? flag to false" do
|
||||
c = Cli.parse_args %w(spec/fixtures/source.cr)
|
||||
c = Cli.parse_args %w[spec/fixtures/source.cr]
|
||||
c.all?.should be_false
|
||||
end
|
||||
|
||||
it "accepts --all flag" do
|
||||
c = Cli.parse_args %w(--all)
|
||||
c = Cli.parse_args %w[--all]
|
||||
c.all?.should eq true
|
||||
end
|
||||
|
||||
it "accepts --gen-config flag" do
|
||||
c = Cli.parse_args %w(--gen-config)
|
||||
c = Cli.parse_args %w[--gen-config]
|
||||
c.formatter.should eq :todo
|
||||
end
|
||||
|
||||
it "accepts --no-color flag" do
|
||||
c = Cli.parse_args %w(--no-color)
|
||||
c = Cli.parse_args %w[--no-color]
|
||||
c.colors?.should be_false
|
||||
end
|
||||
|
||||
it "accepts --without-affected-code flag" do
|
||||
c = Cli.parse_args %w(--without-affected-code)
|
||||
c = Cli.parse_args %w[--without-affected-code]
|
||||
c.without_affected_code?.should be_true
|
||||
end
|
||||
|
||||
it "doesn't disable colors by default" do
|
||||
c = Cli.parse_args %w(--all)
|
||||
c = Cli.parse_args %w[--all]
|
||||
c.colors?.should be_true
|
||||
end
|
||||
|
||||
it "ignores --config if --gen-config flag passed" do
|
||||
c = Cli.parse_args %w(--gen-config --config my_config.yml)
|
||||
c = Cli.parse_args %w[--gen-config --config my_config.yml]
|
||||
c.formatter.should eq :todo
|
||||
c.skip_reading_config?.should be_true
|
||||
end
|
||||
|
||||
describe "-e/--explain" do
|
||||
it "configures file/line/column" do
|
||||
c = Cli.parse_args %w(--explain spec/fixtures/source.cr:3:5)
|
||||
c = Cli.parse_args %w[--explain spec/fixtures/source.cr:3:5]
|
||||
|
||||
location_to_explain = c.location_to_explain.should_not be_nil
|
||||
location_to_explain[:file].should eq "spec/fixtures/source.cr"
|
||||
|
@ -105,59 +105,59 @@ module Ameba::Cli
|
|||
|
||||
it "raises an error if location is not valid" do
|
||||
expect_raises(Exception, "location should have PATH:line:column") do
|
||||
Cli.parse_args %w(--explain spec/fixtures/source.cr:3)
|
||||
Cli.parse_args %w[--explain spec/fixtures/source.cr:3]
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an error if line number is not valid" do
|
||||
expect_raises(Exception, "location should have PATH:line:column") do
|
||||
Cli.parse_args %w(--explain spec/fixtures/source.cr:a:3)
|
||||
Cli.parse_args %w[--explain spec/fixtures/source.cr:a:3]
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an error if column number is not valid" do
|
||||
expect_raises(Exception, "location should have PATH:line:column") do
|
||||
Cli.parse_args %w(--explain spec/fixtures/source.cr:3:&)
|
||||
Cli.parse_args %w[--explain spec/fixtures/source.cr:3:&]
|
||||
end
|
||||
end
|
||||
|
||||
it "raises an error if line/column are missing" do
|
||||
expect_raises(Exception, "location should have PATH:line:column") do
|
||||
Cli.parse_args %w(--explain spec/fixtures/source.cr)
|
||||
Cli.parse_args %w[--explain spec/fixtures/source.cr]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "--fail-level" do
|
||||
it "configures fail level Convention" do
|
||||
c = Cli.parse_args %w(--fail-level convention)
|
||||
c = Cli.parse_args %w[--fail-level convention]
|
||||
c.fail_level.should eq Severity::Convention
|
||||
end
|
||||
|
||||
it "configures fail level Warning" do
|
||||
c = Cli.parse_args %w(--fail-level Warning)
|
||||
c = Cli.parse_args %w[--fail-level Warning]
|
||||
c.fail_level.should eq Severity::Warning
|
||||
end
|
||||
|
||||
it "configures fail level Error" do
|
||||
c = Cli.parse_args %w(--fail-level error)
|
||||
c = Cli.parse_args %w[--fail-level error]
|
||||
c.fail_level.should eq Severity::Error
|
||||
end
|
||||
|
||||
it "raises if fail level is incorrect" do
|
||||
expect_raises(Exception, "Incorrect severity name JohnDoe") do
|
||||
Cli.parse_args %w(--fail-level JohnDoe)
|
||||
Cli.parse_args %w[--fail-level JohnDoe]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "accepts unknown args as globs" do
|
||||
c = Cli.parse_args %w(source1.cr source2.cr)
|
||||
c.globs.should eq %w(source1.cr source2.cr)
|
||||
c = Cli.parse_args %w[source1.cr source2.cr]
|
||||
c.globs.should eq %w[source1.cr source2.cr]
|
||||
end
|
||||
|
||||
it "accepts one unknown arg as explain location if it has correct format" do
|
||||
c = Cli.parse_args %w(source.cr:3:22)
|
||||
c = Cli.parse_args %w[source.cr:3:22]
|
||||
|
||||
location_to_explain = c.location_to_explain.should_not be_nil
|
||||
location_to_explain[:file].should eq "source.cr"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue