Skip to content

Commit 009b7a2

Browse files
committed
Use consistent % literal delimiters
1 parent 2c6e4fe commit 009b7a2

File tree

11 files changed

+42
-20
lines changed

11 files changed

+42
-20
lines changed

.rubocop.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,18 @@ EndAlignment:
7373
CaseIndentation:
7474
IndentWhenRelativeTo: end
7575
IndentOneStep: false
76+
77+
DoubleNegation:
78+
Enabled: false
79+
80+
PercentLiteralDelimiters:
81+
PreferredDelimiters:
82+
'%': ()
83+
'%i': ()
84+
'%q': ()
85+
'%Q': ()
86+
'%r': '{}'
87+
'%s': ()
88+
'%w': '[]'
89+
'%W': '[]'
90+
'%x': ()

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ group :test do
2222
gem 'fakeweb', '>= 1.3'
2323
gem 'rspec', '>= 2.14'
2424
gem 'rspec-mocks', '>= 2.12.2'
25-
gem 'rubocop', '>= 0.16', :platforms => [:ruby_19, :ruby_20, :ruby_21]
25+
gem 'rubocop', '>= 0.19', :platforms => [:ruby_19, :ruby_20, :ruby_21]
2626
gem 'simplecov', :require => false
2727
end
2828

lib/thor/actions.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def _shared_configuration #:nodoc:
308308
def _cleanup_options_and_set(options, key) #:nodoc:
309309
case options
310310
when Array
311-
%w(--force -f --skip -s).each { |i| options.delete(i) }
311+
%w[--force -f --skip -s].each { |i| options.delete(i) }
312312
options << "--#{key}"
313313
when Hash
314314
[:force, :skip, 'force', 'skip'].each { |i| options.delete(i) }

lib/thor/base.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class Thor
1414
autoload :Group, 'thor/group'
1515

1616
# Shortcuts for help.
17-
HELP_MAPPINGS = %w(-h -? --help -D)
17+
HELP_MAPPINGS = %w[-h -? --help -D]
1818

1919
# Thor methods that should not be overwritten by the user.
20-
THOR_RESERVED_WORDS = %w(invoke shell options behavior root destination_root relative_root
21-
action add_file create_file in_root inside run run_ruby_script)
20+
THOR_RESERVED_WORDS = %w[invoke shell options behavior root destination_root relative_root
21+
action add_file create_file in_root inside run run_ruby_script]
2222

2323
TEMPLATE_EXTNAME = '.tt'
2424

lib/thor/shell/basic.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ def dynamic_width
353353
end
354354

355355
def dynamic_width_stty
356-
%x{stty size 2>/dev/null}.split[1].to_i
356+
%x(stty size 2>/dev/null).split[1].to_i
357357
end
358358

359359
def dynamic_width_tput
360-
%x{tput cols 2>/dev/null}.to_i
360+
%x(tput cols 2>/dev/null).to_i
361361
end
362362

363363
def unix?

spec/actions/directory_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def revoke!(*args, &block)
2424
end
2525

2626
def exists_and_identical?(source_path, destination_path)
27-
%w(config.rb README).each do |file|
27+
%w[config.rb README].each do |file|
2828
source = File.join(source_root, source_path, file)
2929
destination = File.join(destination_root, destination_path, file)
3030

spec/parser/arguments_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def parse(*args)
3333
it 'accepts arrays' do
3434
create :string => nil, :array => nil
3535
expect(parse('product', 'title', 'age')['string']).to eq('product')
36-
expect(parse('product', 'title', 'age')['array']).to eq(%w(title age))
36+
expect(parse('product', 'title', 'age')['array']).to eq(%w[title age])
3737
end
3838

3939
describe 'with no inputs' do

spec/parser/options_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def remaining
290290
end
291291

292292
it "raises error when value isn't in enum" do
293-
enum = %w(apple banana)
293+
enum = %w[apple banana]
294294
create :fruit => Thor::Option.new('fruit', :type => :string, :enum => enum)
295295
expect{ parse('--fruit', 'orange') }.to raise_error(Thor::MalformattedArgumentError,
296296
"Expected '--fruit' to be one of #{enum.join(', ')}; got orange")

spec/runner_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def when_no_thorfiles_exist
112112
it 'does not swallow Thor InvocationError' do
113113
ARGV.replace %w[my_script:animal]
114114
content = capture(:stderr) { Thor::Runner.start }
115-
expect(content.strip).to eq(%Q'ERROR: "thor animal" was called with no arguments\nUsage: "thor my_script:animal TYPE"')
115+
expect(content.strip).to eq(%Q(ERROR: "thor animal" was called with no arguments
116+
Usage: "thor my_script:animal TYPE"))
116117
end
117118
end
118119

spec/thor_spec.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,18 @@ def boring(*args)
259259
stderr = capture(:stderr) { Scripts::Arities.start(args) }
260260
expect(stderr.strip).to eq(msg)
261261
end
262-
arity_asserter.call %w[zero_args one], %Q'ERROR: "thor zero_args" was called with arguments ["one"]\nUsage: "thor scripts:arities:zero_args"'
263-
arity_asserter.call %w[one_arg], %Q'ERROR: "thor one_arg" was called with no arguments\nUsage: "thor scripts:arities:one_arg ARG"'
264-
arity_asserter.call %w[one_arg one two], %Q'ERROR: "thor one_arg" was called with arguments ["one", "two"]\nUsage: "thor scripts:arities:one_arg ARG"'
265-
arity_asserter.call %w[one_arg one two], %Q'ERROR: "thor one_arg" was called with arguments ["one", "two"]\nUsage: "thor scripts:arities:one_arg ARG"'
266-
arity_asserter.call %w[two_args one], %Q'ERROR: "thor two_args" was called with arguments ["one"]\nUsage: "thor scripts:arities:two_args ARG1 ARG2"'
267-
arity_asserter.call %w[optional_arg one two], %Q'ERROR: "thor optional_arg" was called with arguments ["one", "two"]\nUsage: "thor scripts:arities:optional_arg [ARG]"'
262+
arity_asserter.call %w[zero_args one], %Q(ERROR: "thor zero_args" was called with arguments ["one"]
263+
Usage: "thor scripts:arities:zero_args")
264+
arity_asserter.call %w[one_arg], %Q(ERROR: "thor one_arg" was called with no arguments
265+
Usage: "thor scripts:arities:one_arg ARG")
266+
arity_asserter.call %w[one_arg one two], %Q(ERROR: "thor one_arg" was called with arguments ["one", "two"]
267+
Usage: "thor scripts:arities:one_arg ARG")
268+
arity_asserter.call %w[one_arg one two], %Q(ERROR: "thor one_arg" was called with arguments ["one", "two"]
269+
Usage: "thor scripts:arities:one_arg ARG")
270+
arity_asserter.call %w[two_args one], %Q(ERROR: "thor two_args" was called with arguments ["one"]
271+
Usage: "thor scripts:arities:two_args ARG1 ARG2")
272+
arity_asserter.call %w[optional_arg one two], %Q(ERROR: "thor optional_arg" was called with arguments ["one", "two"]
273+
Usage: "thor scripts:arities:optional_arg [ARG]")
268274
end
269275

270276
it 'raises an error if the invoked command does not exist' do

0 commit comments

Comments
 (0)