summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyrylo Silin <silin@kyrylo.org>2018-10-13 01:46:57 +0800
committerGitHub <noreply@github.com>2018-10-13 01:46:57 +0800
commit4f121a6a07a94dd5f7a71e75a406147d9d21568d (patch)
treecd60b5c52be027d464f3646508e78d352e1a0d96
parent6794ce504db64b5a188ef4275964906fc79067b8 (diff)
parentac9ddde444623c64539ee1ed2fefef31c6e99995 (diff)
downloadpry-4f121a6a07a94dd5f7a71e75a406147d9d21568d.tar.gz
Merge pull request #1797 from pry/rubocop-layout-end-alignment
rubocop: fix offences of the Layout/EndAlignment cop
-rw-r--r--.rubocop_todo.yml11
-rw-r--r--lib/pry/commands/find_method.rb7
-rw-r--r--lib/pry/commands/hist.rb3
-rw-r--r--lib/pry/editor.rb7
-rw-r--r--lib/pry/method.rb23
5 files changed, 17 insertions, 34 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index a970ff33..43ed5d36 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -261,17 +261,6 @@ Layout/EmptyLinesAroundModuleBody:
- 'spec/commands/show_doc_spec.rb'
- 'spec/commands/show_source_spec.rb'
-# Offense count: 5
-# Cop supports --auto-correct.
-# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
-# SupportedStylesAlignWith: keyword, variable, start_of_line
-Layout/EndAlignment:
- Exclude:
- - 'lib/pry/commands/find_method.rb'
- - 'lib/pry/commands/hist.rb'
- - 'lib/pry/editor.rb'
- - 'lib/pry/method.rb'
-
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
diff --git a/lib/pry/commands/find_method.rb b/lib/pry/commands/find_method.rb
index 52535c17..81de21cb 100644
--- a/lib/pry/commands/find_method.rb
+++ b/lib/pry/commands/find_method.rb
@@ -33,12 +33,7 @@ class Pry
return if args.size < 1
klass = search_class
- matches = if opts.content?
- content_search(klass)
- else
- name_search(klass)
- end
-
+ matches = opts.content? ? content_search(klass) : name_search(klass)
show_search_results(matches)
end
diff --git a/lib/pry/commands/hist.rb b/lib/pry/commands/hist.rb
index 4bbf2a20..a1ca241a 100644
--- a/lib/pry/commands/hist.rb
+++ b/lib/pry/commands/hist.rb
@@ -43,7 +43,8 @@ class Pry
@history = @history.grep(opts[:grep])
end
- @history = case
+ @history =
+ case
when opts.present?(:head)
@history.take_lines(1, opts[:head] || 10)
when opts.present?(:tail)
diff --git a/lib/pry/editor.rb b/lib/pry/editor.rb
index f1869d2c..9acdbe39 100644
--- a/lib/pry/editor.rb
+++ b/lib/pry/editor.rb
@@ -43,12 +43,7 @@ class Pry
args = [file, line, blocking][0...(_pry_.config.editor.arity)]
_pry_.config.editor.call(*args)
else
- sanitized_file = if windows?
- file
- else
- Shellwords.escape(file)
- end
-
+ sanitized_file = windows? ? file : Shellwords.escape(file)
"#{_pry_.config.editor} #{blocking_flag_for_editor(blocking)} #{start_line_syntax_for_editor(sanitized_file, line)}"
end
end
diff --git a/lib/pry/method.rb b/lib/pry/method.rb
index bad95d02..3fb5da7f 100644
--- a/lib/pry/method.rb
+++ b/lib/pry/method.rb
@@ -298,7 +298,8 @@ class Pry
# @return [String, nil] The documentation for the method, or `nil` if it's
# unavailable.
def doc
- @doc ||= case source_type
+ @doc ||=
+ case source_type
when :c
info = pry_doc_info
info.docstring if info
@@ -361,15 +362,17 @@ class Pry
if respond_to?(:parameters)
args = parameters.inject([]) do |args_array, (arg_type, name)|
name ||= (arg_type == :block ? 'block' : "arg#{args_array.size + 1}")
- args_array << case arg_type
- when :req then name.to_s
- when :opt then "#{name}=?"
- when :rest then "*#{name}"
- when :block then "&#{name}"
- when :key then "#{name}:?"
- when :keyreq then "#{name}:"
- else '?'
- end
+ args_array.push(
+ case arg_type
+ when :req then name.to_s
+ when :opt then "#{name}=?"
+ when :rest then "*#{name}"
+ when :block then "&#{name}"
+ when :key then "#{name}:?"
+ when :keyreq then "#{name}:"
+ else '?'
+ end
+ )
end
else
args = (1..arity.abs).map { |i| "arg#{i}" }