1
0
Fork 0
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:
Kyrylo Silin 2018-10-21 05:54:23 +08:00 committed by GitHub
commit 453607353a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 29 deletions

View file

@ -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:

View file

@ -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|

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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"

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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
[]