summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2018-10-21 05:54:23 +0800
committerGitHub <noreply@github.com>2018-10-21 05:54:23 +0800
commit453607353a77db7d7864f4ee9e01297b1483ccb9 (patch)
tree7b43aa616f2348470a1ea19c21e51a6d020328eb
parentb611bd2b41d27e27722ae291fae4c6aa575fec80 (diff)
parent4833e5082fb4be2b7c1ac64216f07c774e344616 (diff)
downloadpry-453607353a77db7d7864f4ee9e01297b1483ccb9.tar.gz
Merge pull request #1819 from pry/rubocop-lint-assignment-in-condition
rubocop: fix offences of the Lint/AssignmentInCondition cop
-rw-r--r--.rubocop_todo.yml15
-rw-r--r--lib/pry/command_set.rb4
-rw-r--r--lib/pry/commands/help.rb2
-rw-r--r--lib/pry/commands/ls/constants.rb2
-rw-r--r--lib/pry/helpers/table.rb2
-rw-r--r--lib/pry/output.rb2
-rw-r--r--lib/pry/slop.rb6
-rw-r--r--lib/pry/slop/commands.rb6
-rw-r--r--lib/pry/slop/option.rb2
-rw-r--r--lib/pry/wrapped_module.rb2
10 files changed, 14 insertions, 29 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 8537cc0c..a2ed8fe2 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -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:
diff --git a/lib/pry/command_set.rb b/lib/pry/command_set.rb
index efc41309..3d3e313c 100644
--- a/lib/pry/command_set.rb
+++ b/lib/pry/command_set.rb
@@ -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|
diff --git a/lib/pry/commands/help.rb b/lib/pry/commands/help.rb
index 8bd2d8aa..cb0932c8 100644
--- a/lib/pry/commands/help.rb
+++ b/lib/pry/commands/help.rb
@@ -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)
diff --git a/lib/pry/commands/ls/constants.rb b/lib/pry/commands/ls/constants.rb
index a488c6c6..516ce06e 100644
--- a/lib/pry/commands/ls/constants.rb
+++ b/lib/pry/commands/ls/constants.rb
@@ -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)
diff --git a/lib/pry/helpers/table.rb b/lib/pry/helpers/table.rb
index d0bb6e17..6ef66807 100644
--- a/lib/pry/helpers/table.rb
+++ b/lib/pry/helpers/table.rb
@@ -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
diff --git a/lib/pry/output.rb b/lib/pry/output.rb
index d862c365..ddefb230 100644
--- a/lib/pry/output.rb
+++ b/lib/pry/output.rb
@@ -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"
diff --git a/lib/pry/slop.rb b/lib/pry/slop.rb
index f256fcc9..777c7c68 100644
--- a/lib/pry/slop.rb
+++ b/lib/pry/slop.rb
@@ -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)
diff --git a/lib/pry/slop/commands.rb b/lib/pry/slop/commands.rb
index d8ac1cb2..eedd6608 100644
--- a/lib/pry/slop/commands.rb
+++ b/lib/pry/slop/commands.rb
@@ -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
diff --git a/lib/pry/slop/option.rb b/lib/pry/slop/option.rb
index b574b1e8..c9979309 100644
--- a/lib/pry/slop/option.rb
+++ b/lib/pry/slop/option.rb
@@ -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
diff --git a/lib/pry/wrapped_module.rb b/lib/pry/wrapped_module.rb
index 0b69dbbe..f22dd859 100644
--- a/lib/pry/wrapped_module.rb
+++ b/lib/pry/wrapped_module.rb
@@ -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
[]