From 970d0e1d57fad52f2c63f3af6f43ddd0b2cf5dfe Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Mon, 25 Feb 2019 00:31:59 +0200 Subject: [PATCH] rubocop: fix offences of the Layout/FirstParameterIndentation cop --- .rubocop_todo.yml | 11 ------- lib/pry/input_completer.rb | 8 ++--- spec/command_spec.rb | 8 ++--- spec/commands/ls_spec.rb | 63 ++++++++++++++++++++++++-------------- spec/method_spec.rb | 9 +++--- 5 files changed, 53 insertions(+), 46 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4f5c3665..26e1dcaf 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,17 +13,6 @@ Gemspec/RequiredRubyVersion: Exclude: - 'pry.gemspec' -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: - Exclude: - - 'lib/pry/input_completer.rb' - - 'spec/command_spec.rb' - - 'spec/commands/ls_spec.rb' - - 'spec/method_spec.rb' - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. diff --git a/lib/pry/input_completer.rb b/lib/pry/input_completer.rb index 4e9f8fb1..9c04cd1d 100644 --- a/lib/pry/input_completer.rb +++ b/lib/pry/input_completer.rb @@ -188,10 +188,10 @@ class Pry::InputCompleter select_message(path, receiver, message, candidates) else candidates = eval( - "methods | private_methods | local_variables | " \ - "self.class.constants | instance_variables", - bind - ).collect(&:to_s) + "methods | private_methods | local_variables | " \ + "self.class.constants | instance_variables", + bind + ).collect(&:to_s) if eval("respond_to?(:class_variables)", bind) candidates += eval("class_variables", bind).collect(&:to_s) diff --git a/spec/command_spec.rb b/spec/command_spec.rb index 9a010ff5..f284a077 100644 --- a/spec/command_spec.rb +++ b/spec/command_spec.rb @@ -784,10 +784,10 @@ describe "Pry::Command" do describe 'group' do before do @set.import( - Pry::CommandSet.new do - create_command("magic") { group("Not for a public use") } - end - ) + Pry::CommandSet.new do + create_command("magic") { group("Not for a public use") } + end + ) end it 'should be correct for default commands' do diff --git a/spec/commands/ls_spec.rb b/spec/commands/ls_spec.rb index 87eae6fb..09052d4b 100644 --- a/spec/commands/ls_spec.rb +++ b/spec/commands/ls_spec.rb @@ -20,13 +20,19 @@ describe "ls" do end it "should include super-classes by default" do - expect(pry_eval( - "cd Class.new(Class.new{ def goo; end; public :goo }).new", - "ls")).to match(/goo/) + expect( + pry_eval( + "cd Class.new(Class.new{ def goo; end; public :goo }).new", + "ls" + ) + ).to match(/goo/) - expect(pry_eval( - "cd Class.new(Class.new{ def goo; end; public :goo })", - "ls -M")).to match(/goo/) + expect( + pry_eval( + "cd Class.new(Class.new{ def goo; end; public :goo })", + "ls -M" + ) + ).to match(/goo/) end it "should not include super-classes when -q is given" do @@ -47,10 +53,12 @@ describe "ls" do end it "should work on subclasses of BasicObject" do - expect(pry_eval( - "class LessBasic < BasicObject; def jaroussky; 5; end; end", - "ls LessBasic.new" - )).to match(/LessBasic#methods:.*jaroussky/m) + expect( + pry_eval( + "class LessBasic < BasicObject; def jaroussky; 5; end; end", + "ls LessBasic.new" + ) + ).to match(/LessBasic#methods:.*jaroussky/m) end end @@ -127,6 +135,7 @@ describe "ls" do expect(result).not_to match(/0x\d{5}/) expect(result).to match(/asdf.*xyz/m) end + it 'should not list pry noise' do expect(pry_eval('ls -l')).not_to match(/_(?:dir|file|ex|pry|out|in)_/) end @@ -134,17 +143,23 @@ describe "ls" do describe "when inside Modules" do it "should still work" do - expect(pry_eval( - "cd Module.new{ def foobie; end; public :foobie }", - "ls -M")).to match(/foobie/) + expect( + pry_eval( + "cd Module.new{ def foobie; end; public :foobie }", + "ls -M" + ) + ).to match(/foobie/) end it "should work for ivars" do - expect(pry_eval( - "module StigmaT1sm; def foobie; @@gharble = 456; end; end", - "Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie", - "cd StigmaT1sm", - "ls -i")).to match(/@@gharble/) + expect( + pry_eval( + "module StigmaT1sm; def foobie; @@gharble = 456; end; end", + "Object.new.tap{ |o| o.extend(StigmaT1sm) }.foobie", + "cd StigmaT1sm", + "ls -i" + ) + ).to match(/@@gharble/) end it "should include instance methods by default" do @@ -184,11 +199,13 @@ describe "ls" do end it "should show constants for an object's class regardless of mixins" do - expect(pry_eval( - "cd Pry.new", - "extend Module.new", - "ls -c" - )).to match(/Method/) + expect( + pry_eval( + "cd Pry.new", + "extend Module.new", + "ls -c" + ) + ).to match(/Method/) end end diff --git a/spec/method_spec.rb b/spec/method_spec.rb index da61ab09..7be22090 100644 --- a/spec/method_spec.rb +++ b/spec/method_spec.rb @@ -486,10 +486,11 @@ describe Pry::Method do end it "should include the Pry::Method.instance_resolution_order of Class after the singleton classes" do - expect(Pry::Method.resolution_order(LS::Top)).to eq( - [eigen_class(LS::Top), eigen_class(Object), eigen_class(BasicObject), - *Pry::Method.instance_resolution_order(Class)] - ) + singleton_classes = [ + eigen_class(LS::Top), eigen_class(Object), eigen_class(BasicObject), + *Pry::Method.instance_resolution_order(Class) + ] + expect(Pry::Method.resolution_order(LS::Top)).to eq(singleton_classes) end end end