rubocop: fix offences of the Style/RedundantBegin cop

This commit is contained in:
Kyrylo Silin 2019-02-24 18:32:19 +02:00
parent 898e9d963e
commit 8b41db334c
5 changed files with 19 additions and 37 deletions

View File

@ -1146,15 +1146,6 @@ Style/RaiseArgs:
Exclude:
- 'lib/pry/method.rb'
# Offense count: 4
# Cop supports --auto-correct.
Style/RedundantBegin:
Exclude:
- 'lib/pry/commands/shell_command.rb'
- 'lib/pry/editor.rb'
- 'lib/pry/method.rb'
- 'lib/pry/pry_class.rb'
# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantException:

View File

@ -38,12 +38,10 @@ class Pry
end
def process_cd(dest)
begin
state.old_pwd = Dir.pwd
Dir.chdir(File.expand_path(path_from_cd_path(dest) || dest))
rescue Errno::ENOENT
raise CommandError, "No such directory: #{dest}"
end
state.old_pwd = Dir.pwd
Dir.chdir(File.expand_path(path_from_cd_path(dest) || dest))
rescue Errno::ENOENT
raise CommandError, "No such directory: #{dest}"
end
def cd_path_env

View File

@ -37,7 +37,6 @@ class Pry
# all the flags we want as well as the file and line number we
# want to open at.
def build_editor_invocation_string(file, line, blocking)
if _pry_.config.editor.respond_to?(:call)
args = [file, line, blocking][0...(_pry_.config.editor.arity)]
_pry_.config.editor.call(*args)
@ -58,13 +57,11 @@ class Pry
# We need JRuby specific code here cos just shelling out using
# system() appears to be pretty broken :/
def open_editor_on_jruby(editor_invocation)
begin
require 'spoon'
pid = Spoon.spawnp(*Shellwords.split(editor_invocation))
Process.waitpid(pid)
rescue FFI::NotFoundError
system(editor_invocation)
end
require 'spoon'
pid = Spoon.spawnp(*Shellwords.split(editor_invocation))
Process.waitpid(pid)
rescue FFI::NotFoundError
system(editor_invocation)
end
# Some editors that run outside the terminal allow you to control whether or

View File

@ -211,11 +211,9 @@ class Pry
end
def singleton_class_of(obj)
begin
class << obj; self; end
rescue TypeError # can't define singleton. Fixnum, Symbol, Float, ...
obj.class
end
class << obj; self; end
rescue TypeError # can't define singleton. Fixnum, Symbol, Float, ...
obj.class
end
end

View File

@ -128,19 +128,17 @@ class Pry
end
def self.load_win32console
begin
require 'win32console'
# The mswin and mingw versions of pry require win32console, so this should
# only fail on jruby (where win32console doesn't work).
# Instead we'll recommend ansicon, which does.
rescue LoadError
warn <<-WARNING if Pry.config.windows_console_warning
require 'win32console'
# The mswin and mingw versions of pry require win32console, so this should
# only fail on jruby (where win32console doesn't work).
# Instead we'll recommend ansicon, which does.
rescue LoadError
warn <<-WARNING if Pry.config.windows_console_warning
For a better Pry experience on Windows, please use ansicon:
https://github.com/adoxa/ansicon
If you use an alternative to ansicon and don't want to see this warning again,
you can add "Pry.config.windows_console_warning = false" to your pryrc.
WARNING
end
WARNING
end
# Do basic setup for initial session including: loading pryrc, plugins,