mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
rubocop: fix offences of the Style/AccessModifierDeclarations cop
This commit is contained in:
parent
c120e94e72
commit
919d9255b2
8 changed files with 44 additions and 61 deletions
|
@ -125,18 +125,6 @@ Security/Eval:
|
|||
- 'spec/indent_spec.rb'
|
||||
- 'spec/wrapped_module_spec.rb'
|
||||
|
||||
# Offense count: 9
|
||||
# Configuration parameters: EnforcedStyle.
|
||||
# SupportedStyles: inline, group
|
||||
Style/AccessModifierDeclarations:
|
||||
Exclude:
|
||||
- 'lib/pry/command.rb'
|
||||
- 'lib/pry/forwardable.rb'
|
||||
- 'lib/pry/helpers/base_helpers.rb'
|
||||
- 'lib/pry/pry_instance.rb'
|
||||
- 'spec/editor_spec.rb'
|
||||
- 'spec/method/patcher_spec.rb'
|
||||
|
||||
# Offense count: 39
|
||||
Style/CaseEquality:
|
||||
Enabled: false
|
||||
|
|
|
@ -411,40 +411,6 @@ class Pry
|
|||
call_safely(*(captures + args))
|
||||
end
|
||||
|
||||
# Pass a block argument to a command.
|
||||
# @param [String] arg_string The arguments (as a string) passed to the command.
|
||||
# We inspect these for a '| do' or a '| {' and if we find it we use it
|
||||
# to start a block input sequence. Once we have a complete
|
||||
# block, we save it to an accessor that can be retrieved from the command context.
|
||||
# Note that if we find the '| do' or '| {' we delete this and the
|
||||
# elements following it from `arg_string`.
|
||||
def pass_block(arg_string)
|
||||
# Workaround for weird JRuby bug where rindex in this case can return nil
|
||||
# even when there's a match.
|
||||
arg_string.scan(/\| *(?:do|\{)/)
|
||||
block_index = $LAST_MATCH_INFO && $LAST_MATCH_INFO.offset(0)[0]
|
||||
|
||||
return unless block_index
|
||||
|
||||
block_init_string = arg_string.slice!(block_index..-1)[1..-1]
|
||||
prime_string = "proc #{block_init_string}\n"
|
||||
|
||||
block_string =
|
||||
if !Pry::Code.complete_expression?(prime_string)
|
||||
pry_instance.r(target, prime_string)
|
||||
else
|
||||
prime_string
|
||||
end
|
||||
|
||||
begin
|
||||
self.command_block = target.eval(block_string)
|
||||
rescue Pry::RescuableException
|
||||
raise CommandError, "Incomplete block definition."
|
||||
end
|
||||
end
|
||||
|
||||
private :pass_block
|
||||
|
||||
# Run the command with the given `args`.
|
||||
#
|
||||
# This is a public wrapper around `#call` which ensures all preconditions
|
||||
|
@ -482,6 +448,38 @@ class Pry
|
|||
|
||||
private
|
||||
|
||||
# Pass a block argument to a command.
|
||||
# @param [String] arg_string The arguments (as a string) passed to the command.
|
||||
# We inspect these for a '| do' or a '| {' and if we find it we use it
|
||||
# to start a block input sequence. Once we have a complete
|
||||
# block, we save it to an accessor that can be retrieved from the command context.
|
||||
# Note that if we find the '| do' or '| {' we delete this and the
|
||||
# elements following it from `arg_string`.
|
||||
def pass_block(arg_string)
|
||||
# Workaround for weird JRuby bug where rindex in this case can return nil
|
||||
# even when there's a match.
|
||||
arg_string.scan(/\| *(?:do|\{)/)
|
||||
block_index = $LAST_MATCH_INFO && $LAST_MATCH_INFO.offset(0)[0]
|
||||
|
||||
return unless block_index
|
||||
|
||||
block_init_string = arg_string.slice!(block_index..-1)[1..-1]
|
||||
prime_string = "proc #{block_init_string}\n"
|
||||
|
||||
block_string =
|
||||
if !Pry::Code.complete_expression?(prime_string)
|
||||
pry_instance.r(target, prime_string)
|
||||
else
|
||||
prime_string
|
||||
end
|
||||
|
||||
begin
|
||||
self.command_block = target.eval(block_string)
|
||||
rescue Pry::RescuableException
|
||||
raise CommandError, "Incomplete block definition."
|
||||
end
|
||||
end
|
||||
|
||||
def find_hooks(event)
|
||||
event_name = "#{event}_#{command_name}"
|
||||
(hooks || self.class.hooks).get_hooks(event_name).values
|
||||
|
|
|
@ -36,8 +36,6 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Generate the string that's used to start the editor. This includes
|
||||
# all the flags we want as well as the file and line number we
|
||||
# want to open at.
|
||||
|
@ -54,6 +52,8 @@ class Pry
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Start the editor running, using the calculated invocation string
|
||||
def open_editor(editor_invocation)
|
||||
# Note we dont want to use Pry.config.system here as that
|
||||
|
|
|
@ -17,7 +17,9 @@ class Pry
|
|||
instance_variable_get(target).__send__(private_delegate, *a, &b)
|
||||
end
|
||||
end
|
||||
class_eval { private(*private_delegates) }
|
||||
class_eval do
|
||||
private(*private_delegates) # rubocop:disable Style/AccessModifierDeclarations
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,6 @@ class Pry
|
|||
(Module === obj ? Module : Object).instance_method(method)
|
||||
.bind(obj).call(*args, &block)
|
||||
end
|
||||
public :safe_send
|
||||
|
||||
def find_command(name, set = Pry::Commands)
|
||||
command_match = set.find do |_, command|
|
||||
|
|
|
@ -349,7 +349,7 @@ class Pry
|
|||
|
||||
throw(:breakout) if current_binding.nil?
|
||||
end
|
||||
private :handle_line
|
||||
private :handle_line # rubocop:disable Style/AccessModifierDeclarations
|
||||
|
||||
# Potentially deprecated. Use `Pry::REPL.new(pry, :target => target).start`
|
||||
# (If nested sessions are going to exist, this method is fine, but a goal is
|
||||
|
@ -401,7 +401,7 @@ class Pry
|
|||
@eval_string.force_encoding(val.encoding)
|
||||
end
|
||||
end
|
||||
private :ensure_correct_encoding!
|
||||
private :ensure_correct_encoding! # rubocop:disable Style/AccessModifierDeclarations
|
||||
|
||||
# If the given line is a valid command, process it in the context of the
|
||||
# current `eval_string` and binding.
|
||||
|
@ -591,13 +591,13 @@ class Pry
|
|||
prompt_proc.call(conf.object, conf.nesting_level, conf.pry_instance)
|
||||
end
|
||||
end
|
||||
private :generate_prompt
|
||||
private :generate_prompt # rubocop:disable Style/AccessModifierDeclarations
|
||||
|
||||
# the array that the prompt stack is stored in
|
||||
def prompt_stack
|
||||
@prompt_stack ||= []
|
||||
end
|
||||
private :prompt_stack
|
||||
private :prompt_stack # rubocop:disable Style/AccessModifierDeclarations
|
||||
|
||||
# Pushes the current prompt onto a stack that it can be restored from later.
|
||||
# Use this if you wish to temporarily change the prompt.
|
||||
|
|
|
@ -1,12 +1,6 @@
|
|||
require 'pathname'
|
||||
|
||||
describe Pry::Editor do
|
||||
class Pry
|
||||
class Editor
|
||||
public :build_editor_invocation_string
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
# OS-specific tempdir name. For GNU/Linux it's "tmp", for Windows it's
|
||||
# something "Temp".
|
||||
|
|
|
@ -25,7 +25,9 @@ describe Pry::Method::Patcher do
|
|||
end
|
||||
|
||||
it "should preserve visibility" do
|
||||
class << @x; private :test; end
|
||||
class << @x
|
||||
private :test # rubocop:disable Style/AccessModifierDeclarations
|
||||
end
|
||||
expect(@method.visibility).to eq :private
|
||||
@method.redefine "def @x.test; :after; end\n"
|
||||
expect(Pry::Method(@x.method(:test)).visibility).to eq :private
|
||||
|
|
Loading…
Reference in a new issue