1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

rubocop: fix offences of the Style/ConditionalAssignment cop

This commit is contained in:
Kyrylo Silin 2019-03-01 01:24:54 +02:00
parent 017fc06722
commit bd778a3c04
7 changed files with 38 additions and 53 deletions

View file

@ -213,19 +213,6 @@ Style/CommentedKeyword:
Exclude:
- 'spec/fixtures/example_nesting.rb'
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Exclude:
- 'lib/pry/command.rb'
- 'lib/pry/commands/easter_eggs.rb'
- 'lib/pry/commands/gist.rb'
- 'lib/pry/indent.rb'
- 'lib/pry/testable/pry_tester.rb'
- 'lib/pry/wrapped_module.rb'
# Offense count: 154
Style/Documentation:
Enabled: false

View file

@ -349,11 +349,12 @@ class Pry
# process and pass a block if one is found
pass_block(arg_string) if command_options[:takes_block]
if arg_string
args = command_options[:shellwords] ? Shellwords.shellwords(arg_string) : arg_string.split(" ")
else
args = []
end
args =
if arg_string
command_options[:shellwords] ? Shellwords.shellwords(arg_string) : arg_string.split(" ")
else
[]
end
[val[0..pos].rstrip, arg_string, captures, args]
end
@ -390,11 +391,12 @@ class Pry
block_init_string = arg_string.slice!(block_index..-1)[1..-1]
prime_string = "proc #{block_init_string}\n"
if !Pry::Code.complete_expression?(prime_string)
block_string = _pry_.r(target, prime_string)
else
block_string = prime_string
end
block_string =
if !Pry::Code.complete_expression?(prime_string)
_pry_.r(target, prime_string)
else
prime_string
end
begin
self.command_block = target.eval(block_string)

View file

@ -95,11 +95,12 @@ class Pry
\____/ \________________________|
EOS
if Helpers::Platform.windows_ansi?
move_up = proc { |n| "\e[#{n}F" }
else
move_up = proc { |n| "\e[#{n}A\e[0G" }
end
move_up =
if Helpers::Platform.windows_ansi?
proc { |n| "\e[#{n}F" }
else
proc { |n| "\e[#{n}A\e[0G" }
end
output.puts "\n" * 6
output.puts picture.lines.map(&:chomp).reverse.join(move_up[1])

View file

@ -72,11 +72,7 @@ class Pry
def comment_expression_result_for_gist(result)
content = ""
result.lines.each_with_index do |line, index|
if index == 0
content << "# => #{line}"
else
content << "# #{line}"
end
content << index == 0 ? "# => #{line}" : "# #{line}"
end
content

View file

@ -291,11 +291,7 @@ class Pry
when @close_heredocs[@heredoc_queue.first]
@heredoc_queue.shift
else
if @string_start
@string_start = nil
else
@string_start = token
end
@string_start = @string_start ? nil : token
end
end

View file

@ -23,11 +23,12 @@ class Pry
end
@history.push str if @history
if @pry.process_command(str)
result = last_command_result_or_output
else
result = @pry.evaluate_ruby(str)
end
result =
if @pry.process_command(str)
last_command_result_or_output
else
@pry.evaluate_ruby(str)
end
end
result

View file

@ -268,11 +268,12 @@ class Pry
def super(times = 1)
return self if times.zero?
if wrapped.is_a?(Class)
sup = ancestors.select { |v| v.is_a?(Class) }[times]
else
sup = ancestors[times]
end
sup =
if wrapped.is_a?(Class)
ancestors.select { |v| v.is_a?(Class) }[times]
else
ancestors[times]
end
Pry::WrappedModule(sup) if sup
end
@ -368,11 +369,12 @@ class Pry
def lines_for_file(file)
@lines_for_file ||= {}
if file == Pry.eval_path
@lines_for_file[file] ||= Pry.line_buffer.drop(1)
else
@lines_for_file[file] ||= File.readlines(file)
end
@lines_for_file[file] ||=
if file == Pry.eval_path
Pry.line_buffer.drop(1)
else
File.readlines(file)
end
end
end
end