From a2ca82c77276dee165b0657ceb6210a844855ef8 Mon Sep 17 00:00:00 2001 From: Kyrylo Silin Date: Tue, 26 Feb 2019 00:40:40 +0200 Subject: rubocop: fix offences of the Layout/SpaceAfterComma cop --- .rubocop_todo.yml | 15 --------------- lib/pry/code_object.rb | 4 ++-- lib/pry/commands/find_method.rb | 2 +- lib/pry/commands/gem_list.rb | 2 +- lib/pry/config/behavior.rb | 6 +++--- lib/pry/helpers/table.rb | 2 +- spec/commands/play_spec.rb | 8 ++++---- spec/commands/raise_up_spec.rb | 6 +++--- spec/hooks_spec.rb | 2 +- spec/pry_defaults_spec.rb | 12 ++++++------ spec/syntax_checking_spec.rb | 4 ++-- 11 files changed, 24 insertions(+), 39 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cbf97e5f..2659867a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -13,21 +13,6 @@ Gemspec/RequiredRubyVersion: Exclude: - 'pry.gemspec' -# Offense count: 30 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Exclude: - - 'lib/pry/code_object.rb' - - 'lib/pry/commands/find_method.rb' - - 'lib/pry/commands/gem_list.rb' - - 'lib/pry/config/behavior.rb' - - 'lib/pry/helpers/table.rb' - - 'spec/commands/play_spec.rb' - - 'spec/commands/raise_up_spec.rb' - - 'spec/hooks_spec.rb' - - 'spec/pry_defaults_spec.rb' - - 'spec/syntax_checking_spec.rb' - # Offense count: 5 # Cop supports --auto-correct. Layout/SpaceAfterSemicolon: diff --git a/lib/pry/code_object.rb b/lib/pry/code_object.rb index 2ffb17a7..f295f90f 100644 --- a/lib/pry/code_object.rb +++ b/lib/pry/code_object.rb @@ -133,9 +133,9 @@ class Pry def method_or_class_lookup obj = case str when /\S+\(\)\z/ - Pry::Method.from_str(str.sub(/\(\)\z/, ''),target) || Pry::WrappedModule.from_str(str, target) + Pry::Method.from_str(str.sub(/\(\)\z/, ''), target) || Pry::WrappedModule.from_str(str, target) else - Pry::WrappedModule.from_str(str,target) || Pry::Method.from_str(str, target) + Pry::WrappedModule.from_str(str, target) || Pry::Method.from_str(str, target) end lookup_super(obj, super_level) diff --git a/lib/pry/commands/find_method.rb b/lib/pry/commands/find_method.rb index eba97b31..51862992 100644 --- a/lib/pry/commands/find_method.rb +++ b/lib/pry/commands/find_method.rb @@ -142,7 +142,7 @@ class Pry # @return [Array] # def search_all_methods(namespace) - done = Hash.new { |h,k| h[k] = {} } + done = Hash.new { |h, k| h[k] = {} } matches = [] recurse_namespace(namespace) do |klass| diff --git a/lib/pry/commands/gem_list.rb b/lib/pry/commands/gem_list.rb index bb5e0f48..f7d9bae1 100644 --- a/lib/pry/commands/gem_list.rb +++ b/lib/pry/commands/gem_list.rb @@ -16,7 +16,7 @@ class Pry gems = Rubygem.list(pattern).group_by(&:name) gems.each do |gem, specs| - specs.sort! do |a,b| + specs.sort! do |a, b| Gem::Version.new(b.version) <=> Gem::Version.new(a.version) end diff --git a/lib/pry/config/behavior.rb b/lib/pry/config/behavior.rb index bc5a96a6..cd92007a 100644 --- a/lib/pry/config/behavior.rb +++ b/lib/pry/config/behavior.rb @@ -97,7 +97,7 @@ class Pry # def from_hash(attributes, default = nil) new(default).tap do |config| - attributes.each do |key,value| + attributes.each do |key, value| config[key] = if Hash === value from_hash(value) elsif Array === value @@ -168,7 +168,7 @@ class Pry raise ReservedKeyError, "It is not possible to use '#{key}' as a key name, please choose a different key name." end - __push(key,value) + __push(key, value) end # @@ -360,7 +360,7 @@ class Pry end end - def __push(key,value) + def __push(key, value) unless singleton_class.method_defined? key define_singleton_method(key) { self[key] } define_singleton_method("#{key}=") { |val| @lookup[key] = val } diff --git a/lib/pry/helpers/table.rb b/lib/pry/helpers/table.rb index 6a82ddab..1c36db2e 100644 --- a/lib/pry/helpers/table.rb +++ b/lib/pry/helpers/table.rb @@ -45,7 +45,7 @@ class Pry widths = columns.map { |e| _max_width(e) } @rows_without_colors.map do |r| padded = [] - r.each_with_index do |e,i| + r.each_with_index do |e, i| next unless e item = e.ljust(widths[i]) diff --git a/spec/commands/play_spec.rb b/spec/commands/play_spec.rb index 6015efaf..7488b7f4 100644 --- a/spec/commands/play_spec.rb +++ b/spec/commands/play_spec.rb @@ -173,16 +173,16 @@ describe "play" do def @o.test_method @s = [ - 1,2,3, - 4,5,6 + 1, 2, 3, + 4, 5, 6 ] end @t.process_command 'play test_method -e 2' expect(@t.eval_string).to eq unindent(<<-STR, 0) @s = [ - 1,2,3, - 4,5,6 + 1, 2, 3, + 4, 5, 6 ] STR end diff --git a/spec/commands/raise_up_spec.rb b/spec/commands/raise_up_spec.rb index e7a5bdd7..11a945af 100644 --- a/spec/commands/raise_up_spec.rb +++ b/spec/commands/raise_up_spec.rb @@ -16,7 +16,7 @@ describe "raise-up" do end it "should raise an unamed exception with raise-up" do - redirect_pry_io(InputTester.new("raise 'stop'","raise-up 'noreally'")) do + redirect_pry_io(InputTester.new("raise 'stop'", "raise-up 'noreally'")) do expect { Object.new.pry }.to raise_error(RuntimeError, "noreally") end end @@ -32,12 +32,12 @@ describe "raise-up" do end it "should raise the most recently raised exception" do - expect { mock_pry("raise NameError, 'homographery'","raise-up") }.to raise_error(NameError, 'homographery') + expect { mock_pry("raise NameError, 'homographery'", "raise-up") }.to raise_error(NameError, 'homographery') end it "should allow you to cd up and (eventually) out" do redirect_pry_io(InputTester.new("cd :inner", "raise NoMethodError", @inner, - "deep = :deep", "cd deep","Pad.deep = self", + "deep = :deep", "cd deep", "Pad.deep = self", "raise-up NoMethodError", "raise-up", @outer, "raise-up", "exit-all")) do expect { Pry.start(:outer) }.to raise_error NoMethodError diff --git a/spec/hooks_spec.rb b/spec/hooks_spec.rb index 114de49e..2c19d47e 100644 --- a/spec/hooks_spec.rb +++ b/spec/hooks_spec.rb @@ -350,7 +350,7 @@ describe Pry::Hooks do Pry.config.hooks.add_hook(:when_started, :test_hook) { |_target, _opt, _pry_| _pry_.binding_stack = [Pry.binding_for(o)] } - redirect_pry_io(InputTester.new("@value = true","exit-all")) do + redirect_pry_io(InputTester.new("@value = true", "exit-all")) do Pry.start binding, hello: :baby end diff --git a/spec/pry_defaults_spec.rb b/spec/pry_defaults_spec.rb index 2ee2de8d..3b3458e2 100644 --- a/spec/pry_defaults_spec.rb +++ b/spec/pry_defaults_spec.rb @@ -374,8 +374,8 @@ describe "test Pry defaults" do it 'should set the hooks default, and the default should be overridable' do Pry.config.input = InputTester.new("exit-all") Pry.config.hooks = Pry::Hooks.new - .add_hook(:before_session, :my_name) { |out,_,_| out.puts "HELLO" } - .add_hook(:after_session, :my_name) { |out,_,_| out.puts "BYE" } + .add_hook(:before_session, :my_name) { |out, _, _| out.puts "HELLO" } + .add_hook(:after_session, :my_name) { |out, _, _| out.puts "BYE" } Object.new.pry output: @str_output expect(@str_output.string).to match(/HELLO/) @@ -385,8 +385,8 @@ describe "test Pry defaults" do @str_output = StringIO.new hooks = Pry::Hooks.new - .add_hook( :before_session, :my_name) { |out,_,_| out.puts "MORNING" } - .add_hook(:after_session, :my_name) { |out,_,_| out.puts "EVENING" } + .add_hook( :before_session, :my_name) { |out, _, _| out.puts "MORNING" } + .add_hook(:after_session, :my_name) { |out, _, _| out.puts "EVENING" } Object.new.pry(output: @str_output, hooks: hooks) expect(@str_output.string).to match(/MORNING/) @@ -396,7 +396,7 @@ describe "test Pry defaults" do Pry.config.input.rewind @str_output = StringIO.new hooks = Pry::Hooks.new - .add_hook(:before_session, :my_name) { |out,_,_| out.puts "OPEN" } + .add_hook(:before_session, :my_name) { |out, _, _| out.puts "OPEN" } Object.new.pry(output: @str_output, hooks: hooks) expect(@str_output.string).to match(/OPEN/) @@ -404,7 +404,7 @@ describe "test Pry defaults" do Pry.config.input.rewind @str_output = StringIO.new hooks = Pry::Hooks.new - .add_hook(:after_session, :my_name) { |out,_,_| out.puts "CLOSE" } + .add_hook(:after_session, :my_name) { |out, _, _| out.puts "CLOSE" } Object.new.pry(output: @str_output, hooks: hooks) expect(@str_output.string).to match(/CLOSE/) diff --git a/spec/syntax_checking_spec.rb b/spec/syntax_checking_spec.rb index c57c9ae0..c4491412 100644 --- a/spec/syntax_checking_spec.rb +++ b/spec/syntax_checking_spec.rb @@ -28,7 +28,7 @@ describe Pry do ["puts :"] ] + [ ["def", "method(1"], # in this case the syntax error is "expecting ')'". - ["o = Object.new.tap{ def o.render;","'MEH'", "}"] # in this case the syntax error is "expecting keyword_end". + ["o = Object.new.tap{ def o.render;", "'MEH'", "}"] # in this case the syntax error is "expecting keyword_end". ]).compact.each do |foo| it "should raise an error on invalid syntax like #{foo.inspect}" do redirect_pry_io(InputTester.new(*foo), @str_output) do @@ -68,7 +68,7 @@ describe Pry do end it "should allow newline delimeted strings" do - expect(mock_pry('"%s" % %','foo')).to match(/"foo"/) + expect(mock_pry('"%s" % %', 'foo')).to match(/"foo"/) end it "should allow whitespace delimeted strings ending on the first char of a line" do -- cgit v1.2.1