From ac9ddde444623c64539ee1ed2fefef31c6e99995 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Sat, 13 Oct 2018 01:14:21 +0800 Subject: rubocop: fix offences of the Layout/EndAlignment cop --- .rubocop_todo.yml | 11 ----------- lib/pry/commands/find_method.rb | 7 +------ lib/pry/commands/hist.rb | 3 ++- lib/pry/editor.rb | 7 +------ lib/pry/method.rb | 23 +++++++++++++---------- 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}" } -- cgit v1.2.1