mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1939 from pry/rubocop-layout-align-parameters
rubocop: fix offences of Layout/AlignParameters cop
This commit is contained in:
commit
abf3704c66
13 changed files with 33 additions and 50 deletions
|
@ -50,25 +50,6 @@ Layout/AlignHash:
|
|||
- 'spec/pry_defaults_spec.rb'
|
||||
- 'spec/sticky_locals_spec.rb'
|
||||
|
||||
# Offense count: 23
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, IndentationWidth.
|
||||
# SupportedStyles: with_first_parameter, with_fixed_indentation
|
||||
Layout/AlignParameters:
|
||||
Exclude:
|
||||
- 'lib/pry/commands/code_collector.rb'
|
||||
- 'lib/pry/commands/edit.rb'
|
||||
- 'lib/pry/commands/gem_search.rb'
|
||||
- 'lib/pry/commands/reload_code.rb'
|
||||
- 'lib/pry/commands/watch_expression.rb'
|
||||
- 'lib/pry/helpers/options_helpers.rb'
|
||||
- 'lib/pry/pry_instance.rb'
|
||||
- 'lib/pry/rubygem.rb'
|
||||
- 'lib/pry/slop.rb'
|
||||
- 'spec/command_spec.rb'
|
||||
- 'spec/commands/cd_spec.rb'
|
||||
- 'spec/commands/save_file_spec.rb'
|
||||
|
||||
# Offense count: 10
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyleAlignWith.
|
||||
|
|
|
@ -29,18 +29,18 @@ class Pry
|
|||
@output_result_ranges = []
|
||||
|
||||
opt.on :l, :lines, "Restrict to a subset of lines. Takes a line number or range",
|
||||
optional_argument: true, as: Range, default: 1..-1
|
||||
opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
optional_argument: true, as: Range, default: 1..-1
|
||||
opt.on :o, :out, "Select lines from Pry's output result history. Takes an index or range",
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
output_result_ranges << (r || (-5..-1))
|
||||
end
|
||||
opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
opt.on :i, :in, "Select lines from Pry's input expression history. Takes an index or range",
|
||||
optional_argument: true, as: Range, default: -5..-1 do |r|
|
||||
input_expression_ranges << (r || (-5..-1))
|
||||
end
|
||||
opt.on :s, :super, "Select the 'super' method. Can be repeated to traverse the ancestors",
|
||||
as: :count
|
||||
opt.on :d, :doc, "Select lines from the code object's documentation"
|
||||
as: :count
|
||||
opt.on :d, :doc, "Select lines from the code object's documentation"
|
||||
end
|
||||
|
||||
# The content (i.e code/docs) for the selected object.
|
||||
|
|
|
@ -24,12 +24,12 @@ class Pry
|
|||
|
||||
def options(opt)
|
||||
opt.on :e, :ex, "Open the file that raised the most recent exception (_ex_.file)",
|
||||
optional_argument: true, as: Integer
|
||||
optional_argument: true, as: Integer
|
||||
opt.on :i, :in, "Open a temporary file containing the Nth input expression. N may be a range",
|
||||
optional_argument: true, as: Range, default: -1..-1
|
||||
optional_argument: true, as: Range, default: -1..-1
|
||||
opt.on :t, :temp, "Open an empty temporary file"
|
||||
opt.on :l, :line, "Jump to this line in the opened file",
|
||||
argument: true, as: Integer
|
||||
argument: true, as: Integer
|
||||
opt.on :n, :"no-reload", "Don't automatically reload the edited file"
|
||||
opt.on :c, :current, "Open the current __FILE__ and at __LINE__ (as returned by `whereami`)"
|
||||
opt.on :r, :reload, "Reload the edited code immediately (default for ruby files)"
|
||||
|
@ -61,7 +61,7 @@ class Pry
|
|||
|
||||
def repl_edit
|
||||
content = Pry::Editor.new(_pry_).edit_tempfile_with_content(initial_temp_file_content,
|
||||
initial_temp_file_content.lines.count)
|
||||
initial_temp_file_content.lines.count)
|
||||
silence_warnings do
|
||||
eval_string.replace content
|
||||
end
|
||||
|
|
|
@ -17,9 +17,9 @@ class Pry::Command::GemSearch < Pry::ClassCommand
|
|||
|
||||
def options(opt)
|
||||
opt.on :l, :limit, 'Limit the number of results (max: 30)',
|
||||
default: 10,
|
||||
as: Integer,
|
||||
argument: true
|
||||
default: 10,
|
||||
as: Integer,
|
||||
argument: true
|
||||
end
|
||||
|
||||
def process(str)
|
||||
|
|
|
@ -57,8 +57,8 @@ class Pry
|
|||
raise CommandError, "Cannot locate #{identifier}!"
|
||||
elsif !File.exist?(code_object.source_file)
|
||||
raise CommandError,
|
||||
"Cannot reload #{identifier} as it has no associated file on disk. " \
|
||||
"File found was: #{code_object.source_file}"
|
||||
"Cannot reload #{identifier} as it has no associated file on disk. " \
|
||||
"File found was: #{code_object.source_file}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,10 +28,10 @@ class Pry
|
|||
|
||||
def options(opt)
|
||||
opt.on :d, :delete,
|
||||
"Delete the watch expression with the given index. If no index is given; clear all watch expressions.",
|
||||
optional_argument: true, as: Integer
|
||||
"Delete the watch expression with the given index. If no index is given; clear all watch expressions.",
|
||||
optional_argument: true, as: Integer
|
||||
opt.on :l, :list,
|
||||
"Show all current watch expressions and their values. Calling watch with no expressions or options will also show the watch expressions."
|
||||
"Show all current watch expressions and their values. Calling watch with no expressions or options will also show the watch expressions."
|
||||
end
|
||||
|
||||
def process
|
||||
|
|
|
@ -17,9 +17,9 @@ class Pry
|
|||
# Get the method object parsed by the slop instance
|
||||
def method_object
|
||||
@method_object ||= get_method_or_raise(args.empty? ? nil : args.join(" "), @method_target,
|
||||
super: opts[:super],
|
||||
instance: opts.present?(:'instance-methods') && !opts.present?(:'methods'),
|
||||
methods: opts.present?(:'methods') && !opts.present?(:'instance-methods')
|
||||
super: opts[:super],
|
||||
instance: opts.present?(:'instance-methods') && !opts.present?(:'methods'),
|
||||
methods: opts.present?(:'methods') && !opts.present?(:'instance-methods')
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -408,7 +408,8 @@ class Pry
|
|||
def process_command(val)
|
||||
val = val.lstrip if /^\s\S/ !~ val
|
||||
val = val.chomp
|
||||
result = commands.process_line(val,
|
||||
result = commands.process_line(
|
||||
val,
|
||||
target: current_binding,
|
||||
output: output,
|
||||
eval_string: @eval_string,
|
||||
|
@ -453,7 +454,8 @@ class Pry
|
|||
# @example
|
||||
# pry_instance.run_command("ls -m")
|
||||
def run_command(val)
|
||||
commands.process_line(val,
|
||||
commands.process_line(
|
||||
val,
|
||||
eval_string: @eval_string,
|
||||
target: current_binding,
|
||||
pry_instance: self,
|
||||
|
|
|
@ -71,10 +71,10 @@ class Pry
|
|||
installer.install(name)
|
||||
rescue Errno::EACCES
|
||||
raise CommandError,
|
||||
"Insufficient permissions to install #{green(name)}."
|
||||
"Insufficient permissions to install #{green(name)}."
|
||||
rescue Gem::GemNotFoundException
|
||||
raise CommandError,
|
||||
"Gem #{green(name)} not found. Aborting installation."
|
||||
"Gem #{green(name)} not found. Aborting installation."
|
||||
else
|
||||
Gem.refresh
|
||||
end
|
||||
|
|
|
@ -229,7 +229,7 @@ class Pry::Slop
|
|||
missing_options = options.select { |opt| opt.required? && opt.count < 1 }
|
||||
if missing_options.any?
|
||||
raise MissingOptionError,
|
||||
"Missing required option(s): #{missing_options.map(&:key).join(', ')}"
|
||||
"Missing required option(s): #{missing_options.map(&:key).join(', ')}"
|
||||
end
|
||||
|
||||
if @unknown_options.any?
|
||||
|
|
|
@ -429,8 +429,8 @@ describe "Pry::Command" do
|
|||
|
||||
it 'should accept normal parameters along with block' do
|
||||
@set.block_command "walking-spanish",
|
||||
"litella's been screeching for a blind pig.",
|
||||
takes_block: true do |x, y|
|
||||
"litella's been screeching for a blind pig.",
|
||||
takes_block: true do |x, y|
|
||||
insert_variable(:@x, x, target)
|
||||
insert_variable(:@y, y, target)
|
||||
insert_variable(:@block_var, command_block.call, target)
|
||||
|
|
|
@ -132,7 +132,7 @@ describe 'cd' do
|
|||
describe 'when using ^D (Control-D) key press' do
|
||||
it 'should keep correct old binding' do
|
||||
@t.eval 'cd :john_dogg', 'cd :mon_dogg', 'cd :kyr_dogg',
|
||||
'Pry::DEFAULT_CONTROL_D_HANDLER.call("", _pry_)'
|
||||
'Pry::DEFAULT_CONTROL_D_HANDLER.call("", _pry_)'
|
||||
expect(@t.mapped_binding_stack).to eq [@o, :john_dogg, :mon_dogg]
|
||||
|
||||
@t.eval 'cd -'
|
||||
|
|
|
@ -43,7 +43,7 @@ describe "save-file" do
|
|||
|
||||
it 'should save multi-ranged input expressions' do
|
||||
@t.eval ':or_nostrils', ':sucking_up_all_the_oxygen', ':or_whatever',
|
||||
':baby_ducks', ':cannot_escape'
|
||||
':baby_ducks', ':cannot_escape'
|
||||
@t.eval "save-file -i 1..2 -i 4..5 --to '#{@path}'"
|
||||
expect(File.read(@path)).to eq(":or_nostrils\n:sucking_up_all_the_oxygen\n:baby_ducks\n:cannot_escape\n")
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue