mirror of
https://github.com/pry/pry.git
synced 2022-11-09 12:35:05 -05:00
Merge pull request #1815 from pry/rubocop-style-multiline-ternary-operator
rubocop: fix offences of the Style/MultilineTernaryOperator cop
This commit is contained in:
commit
5f18796595
6 changed files with 24 additions and 38 deletions
|
@ -1187,16 +1187,6 @@ Style/MultilineBlockChain:
|
|||
- 'lib/pry/commands/ls/local_vars.rb'
|
||||
- 'spec/cli_spec.rb'
|
||||
|
||||
# Offense count: 6
|
||||
Style/MultilineTernaryOperator:
|
||||
Exclude:
|
||||
- 'lib/pry/commands/gem_stats.rb'
|
||||
- 'lib/pry/commands/show_doc.rb'
|
||||
- 'lib/pry/commands/whereami.rb'
|
||||
- 'lib/pry/history_array.rb'
|
||||
- 'lib/pry/pry_instance.rb'
|
||||
- 'spec/syntax_checking_spec.rb'
|
||||
|
||||
# Offense count: 2
|
||||
Style/MultipleComparison:
|
||||
Exclude:
|
||||
|
|
|
@ -71,11 +71,13 @@ FAILWHALE
|
|||
end
|
||||
|
||||
def format_dependencies(rdeps)
|
||||
rdeps.empty? ?
|
||||
bold("None") :
|
||||
with_line_numbers(rdeps.map {|h|
|
||||
"%{name} (%{requirements})" % {name: h["name"], requirements: h["requirements"]}
|
||||
}.join($/), 1, :bold)
|
||||
return bold('None') if rdeps.empty?
|
||||
|
||||
with_line_numbers(
|
||||
rdeps.map { |h| "#{h['name']} (#{h['requirements']})" }.join("\n"),
|
||||
1,
|
||||
:bold
|
||||
)
|
||||
end
|
||||
Pry::Commands.add_command(self)
|
||||
end
|
||||
|
|
|
@ -69,12 +69,10 @@ class Pry
|
|||
# number of lines in the comment and the start line of the code_object
|
||||
# @return [Fixnum] start line of docs
|
||||
def start_line_for(code_object)
|
||||
if code_object.command? || opts.present?(:'base-one')
|
||||
1
|
||||
else
|
||||
code_object.source_line.nil? ? 1 :
|
||||
(code_object.source_line - code_object.doc.lines.count)
|
||||
end
|
||||
return 1 if code_object.command? || opts.present?(:'base-one')
|
||||
return 1 unless code_object.source_line
|
||||
|
||||
code_object.source_line - code_object.doc.lines.count
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -154,8 +154,9 @@ class Pry
|
|||
# or it returns the class of `target_self` if `target_self` is not a class.
|
||||
# @return [Pry::WrappedModule]
|
||||
def target_class
|
||||
target_self.is_a?(Module) ? Pry::WrappedModule(target_self) :
|
||||
Pry::WrappedModule(target_self.class)
|
||||
return Pry::WrappedModule(target_self) if target_self.is_a?(Module)
|
||||
|
||||
Pry::WrappedModule(target_self.class)
|
||||
end
|
||||
|
||||
def class_code
|
||||
|
|
|
@ -51,21 +51,17 @@ class Pry
|
|||
# @return [Array, nil] The selected items. Nil if index is greater than
|
||||
# the size of the array.
|
||||
def [](index_or_range, size = nil)
|
||||
if index_or_range.is_a? Integer
|
||||
index = convert_index(index_or_range)
|
||||
|
||||
if size
|
||||
end_index = index + size
|
||||
index > @count ? nil : (index...[end_index, @count].min).map do |n|
|
||||
@hash[n]
|
||||
end
|
||||
else
|
||||
@hash[index]
|
||||
end
|
||||
else
|
||||
unless index_or_range.is_a?(Integer)
|
||||
range = convert_range(index_or_range)
|
||||
range.begin > @count ? nil : range.map { |n| @hash[n] }
|
||||
return range.begin > @count ? nil : range.map { |n| @hash[n] }
|
||||
end
|
||||
|
||||
index = convert_index(index_or_range)
|
||||
return @hash[index] unless size
|
||||
return if index > @count
|
||||
|
||||
end_index = index + size
|
||||
(index...[end_index, @count].min).map { |n| @hash[n] }
|
||||
end
|
||||
|
||||
# @return [Integer] Amount of objects in the array
|
||||
|
|
|
@ -531,8 +531,7 @@ class Pry
|
|||
# @return [String] The prompt.
|
||||
def select_prompt
|
||||
object = current_binding.eval('self')
|
||||
open_token = @indent.open_delimiters.any? ? @indent.open_delimiters.last :
|
||||
@indent.stack.last
|
||||
open_token = @indent.open_delimiters.last || @indent.stack.last
|
||||
|
||||
c = Pry::Config.assign({
|
||||
object: object,
|
||||
|
|
Loading…
Add table
Reference in a new issue