mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1819 from pry/rubocop-lint-assignment-in-condition
rubocop: fix offences of the Lint/AssignmentInCondition cop
This commit is contained in:
commit
453607353a
10 changed files with 14 additions and 29 deletions
|
@ -563,21 +563,6 @@ Layout/TrailingWhitespace:
|
|||
- 'spec/commands/edit_spec.rb'
|
||||
- 'spec/indent_spec.rb'
|
||||
|
||||
# Offense count: 15
|
||||
# Configuration parameters: AllowSafeAssignment.
|
||||
Lint/AssignmentInCondition:
|
||||
Exclude:
|
||||
- 'Rakefile'
|
||||
- 'lib/pry/command_set.rb'
|
||||
- 'lib/pry/commands/help.rb'
|
||||
- 'lib/pry/commands/ls/constants.rb'
|
||||
- 'lib/pry/helpers/table.rb'
|
||||
- 'lib/pry/output.rb'
|
||||
- 'lib/pry/slop.rb'
|
||||
- 'lib/pry/slop/commands.rb'
|
||||
- 'lib/pry/slop/option.rb'
|
||||
- 'lib/pry/wrapped_module.rb'
|
||||
|
||||
# Offense count: 3
|
||||
Lint/Debugger:
|
||||
Exclude:
|
||||
|
|
|
@ -395,7 +395,7 @@ class Pry
|
|||
# @param [Hash] context The context to execute the commands with
|
||||
# @return [CommandSet::Result]
|
||||
def process_line(val, context={})
|
||||
if command = find_command(val)
|
||||
if (command = find_command(val))
|
||||
context = context.merge(command_set: self)
|
||||
retval = command.new(context).process_line(val)
|
||||
Result.new(true, retval)
|
||||
|
@ -415,7 +415,7 @@ class Pry
|
|||
# @param [Hash] context The context to create the command with
|
||||
# @return [Array<String>]
|
||||
def complete(search, context={})
|
||||
if command = find_command(search)
|
||||
if (command = find_command(search))
|
||||
command.new(context).complete(search)
|
||||
else
|
||||
@commands.keys.select do |key|
|
||||
|
|
|
@ -82,7 +82,7 @@ class Pry
|
|||
#
|
||||
# @param [String] search The string to search for.
|
||||
def display_search(search)
|
||||
if command = command_set.find_command_for_help(search)
|
||||
if (command = command_set.find_command_for_help(search))
|
||||
display_command(command)
|
||||
else
|
||||
display_filtered_search_results(search)
|
||||
|
|
|
@ -40,7 +40,7 @@ class Pry
|
|||
next
|
||||
end
|
||||
|
||||
if const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil)
|
||||
if (const = (!mod.autoload?(name) && (mod.const_get(name) || true) rescue nil))
|
||||
if (const < Exception rescue false)
|
||||
color(:exception_constant, name)
|
||||
elsif (Module === mod.const_get(name) rescue false)
|
||||
|
|
|
@ -13,7 +13,7 @@ class Pry
|
|||
def self.tablify_to_screen_width(things, options, config = Pry.config)
|
||||
options ||= {}
|
||||
things = things.compact
|
||||
if indent = options[:indent]
|
||||
if (indent = options[:indent])
|
||||
usable_width = Terminal.width! - indent.size
|
||||
tablify(things, usable_width, config).to_s.gsub(/^/, indent)
|
||||
else
|
||||
|
|
|
@ -10,7 +10,7 @@ class Pry::Output
|
|||
return print "\n" if objs.empty?
|
||||
|
||||
objs.each do |obj|
|
||||
if ary = Array.try_convert(obj)
|
||||
if (ary = Array.try_convert(obj))
|
||||
puts(*ary)
|
||||
else
|
||||
print "#{obj.to_s.chomp}\n"
|
||||
|
|
|
@ -217,7 +217,7 @@ class Pry::Slop
|
|||
return items
|
||||
end
|
||||
|
||||
if cmd = @commands[items[0]]
|
||||
if (cmd = @commands[items[0]])
|
||||
return cmd.parse! items[1..-1]
|
||||
end
|
||||
|
||||
|
@ -464,7 +464,7 @@ class Pry::Slop
|
|||
#
|
||||
# Returns nothing.
|
||||
def process_item(items, index, &block)
|
||||
return unless item = items[index]
|
||||
return unless (item = items[index])
|
||||
|
||||
option, argument = extract_option(item) if item.start_with?('-')
|
||||
|
||||
|
@ -546,7 +546,7 @@ class Pry::Slop
|
|||
def execute_multiple_switches(option, argument, index)
|
||||
execute_option(option, nil, index)
|
||||
argument.split('').each do |key|
|
||||
next unless opt = fetch_option(key)
|
||||
next unless (opt = fetch_option(key))
|
||||
|
||||
opt.count += 1
|
||||
execute_option(opt, nil, index, key)
|
||||
|
|
|
@ -133,13 +133,13 @@ class Pry::Slop
|
|||
#
|
||||
# Returns the original Array of items with options removed.
|
||||
def parse!(items = ARGV)
|
||||
if opts = commands[items[0].to_s]
|
||||
if (opts = commands[items[0].to_s])
|
||||
@triggered_command = items.shift
|
||||
execute_arguments! items
|
||||
opts.parse! items
|
||||
execute_global_opts! items
|
||||
else
|
||||
if opts = commands['default']
|
||||
if (opts = commands['default'])
|
||||
opts.parse! items
|
||||
else
|
||||
if config[:strict] && items[0]
|
||||
|
@ -187,7 +187,7 @@ class Pry::Slop
|
|||
|
||||
# Returns nothing.
|
||||
def execute_global_opts!(items)
|
||||
if global_opts = commands['global']
|
||||
if (global_opts = commands['global'])
|
||||
global_opts.parse! items
|
||||
end
|
||||
end
|
||||
|
|
|
@ -114,7 +114,7 @@ class Pry::Slop
|
|||
if type.respond_to?(:call)
|
||||
type.call(value)
|
||||
else
|
||||
if callable = types[type.to_s.downcase.to_sym]
|
||||
if (callable = types[type.to_s.downcase.to_sym])
|
||||
callable.call(value)
|
||||
else
|
||||
value
|
||||
|
|
|
@ -330,7 +330,7 @@ class Pry
|
|||
return methods unless methods.empty?
|
||||
|
||||
safe_send(mod, :constants).flat_map do |const_name|
|
||||
if const = nested_module?(mod, const_name)
|
||||
if (const = nested_module?(mod, const_name))
|
||||
all_relevant_methods_for(const)
|
||||
else
|
||||
[]
|
||||
|
|
Loading…
Reference in a new issue