diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index cae6016d..91712d53 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -22,16 +22,6 @@ Lint/HandleExceptions: - 'lib/pry/pager.rb' - 'lib/pry/terminal.rb' -# Offense count: 16 -Lint/InterpolationCheck: - Exclude: - - 'spec/command_integration_spec.rb' - - 'spec/command_set_spec.rb' - - 'spec/command_spec.rb' - - 'spec/commands/amend_line_spec.rb' - - 'spec/commands/edit_spec.rb' - - 'spec/pry_spec.rb' - # Offense count: 1 Lint/Loop: Exclude: diff --git a/spec/command_integration_spec.rb b/spec/command_integration_spec.rb index 29c0c264..0c42905f 100644 --- a/spec/command_integration_spec.rb +++ b/spec/command_integration_spec.rb @@ -236,7 +236,9 @@ describe "commands" do end end + # rubocop:disable Lint/InterpolationCheck expect(pry_tester(commands: set).eval('hello #{Pad.bong}')).to match(/bong/) + # rubocop:enable Lint/InterpolationCheck end # bug fix for https://github.com/pry/pry/issues/170 @@ -245,7 +247,10 @@ describe "commands" do "is a command" ) do redirect_pry_io( - InputTester.new('/#{Regexp.escape(File.expand_path("."))}/'), @str_output + # rubocop:disable Lint/InterpolationCheck + InputTester.new('/#{Regexp.escape(File.expand_path("."))}/'), + # rubocop:enable Lint/InterpolationCheck + @str_output ) do pry end @@ -260,16 +265,19 @@ describe "commands" do end end + # rubocop:disable Lint/InterpolationCheck expect(pry_tester(commands: set).eval('hello #{Pad.bong}')) .to match(/Pad\.bong/) + # rubocop:enable Lint/InterpolationCheck end it 'should NOT try to interpolate pure ruby code (no commands) ' do + # rubocop:disable Lint/InterpolationCheck # These should raise RuntimeError instead of NameError expect { pry_eval 'raise \'#{aggy}\'' }.to raise_error RuntimeError - expect { pry_eval 'raise #{aggy}' }.to raise_error RuntimeError - + expect { pry_eval 'raise #{aggy}' }.to raise_error RuntimeError expect(pry_eval('format \'#{my_var}\'')).to eq "\#{my_var}" + # rubocop:enable Lint/InterpolationCheck end it 'should create a command with a space in its name zzz' do @@ -326,7 +334,7 @@ describe "commands" do end bong = "bong" - expect(pry_tester(binding, commands: set).eval('hello #{bong}')) + expect(pry_tester(binding, commands: set).eval("hello #{bong}")) .to match(/hello #{bong}/) end @@ -342,7 +350,7 @@ describe "commands" do bang = 'bang' expect(pry_tester(binding, commands: set) - .eval('hellojohn #{bing} #{bong} #{bang}')) + .eval("hellojohn #{bing} #{bong} #{bang}")) .to match(/hello john #{bing} #{bong} #{bang}/) end diff --git a/spec/command_set_spec.rb b/spec/command_set_spec.rb index 3dcef166..58f7bf3c 100644 --- a/spec/command_set_spec.rb +++ b/spec/command_set_spec.rb @@ -575,7 +575,9 @@ describe Pry::CommandSet do it 'should not cause argument interpolation' do @set.command('hello') + # rubocop:disable Lint/InterpolationCheck expect { @set.valid_command?('hello #{raise "futz"}') }.to_not raise_error + # rubocop:enable Lint/InterpolationCheck end end diff --git a/spec/command_spec.rb b/spec/command_spec.rb index 3dd7c03d..fe86e8ec 100644 --- a/spec/command_spec.rb +++ b/spec/command_spec.rb @@ -315,12 +315,14 @@ describe "Pry::Command" do end describe 'tokenize' do - it 'should interpolate string with #{} in them' do + it "should interpolate string with \#{} in them" do expect do |probe| cmd = @set.command('random-dent', &probe) _foo = 5 - cmd.new(target: binding).process_line 'random-dent #{1 + 2} #{3 + _foo}' + # rubocop:disable Lint/InterpolationCheck + cmd.new(target: binding).process_line('random-dent #{1 + 2} #{3 + _foo}') + # rubocop:enable Lint/InterpolationCheck end.to yield_with_args('3', '8') end @@ -333,11 +335,13 @@ describe "Pry::Command" do end it 'should not interpolate commands with :interpolate => false' do + # rubocop:disable Lint/InterpolationCheck expect do |probe| cmd = @set.command('thor', 'norse god', interpolate: false, &probe) cmd.new.process_line 'thor %(#{foo})' end.to yield_with_args('%(#{foo})') + # rubocop:enable Lint/InterpolationCheck end it 'should use shell-words to split strings' do diff --git a/spec/commands/amend_line_spec.rb b/spec/commands/amend_line_spec.rb index b133a61f..29b68f80 100644 --- a/spec/commands/amend_line_spec.rb +++ b/spec/commands/amend_line_spec.rb @@ -97,7 +97,9 @@ describe "amend-line" do puts :bang STR + # rubocop:disable Lint/InterpolationCheck @t.process_command 'amend-line puts "#{goodbye}"' + # rubocop:enable Lint/InterpolationCheck expect(@t.eval_string).to eq unindent(<<-'STR') def hello diff --git a/spec/commands/edit_spec.rb b/spec/commands/edit_spec.rb index cc2d5c0a..f2c57ddc 100644 --- a/spec/commands/edit_spec.rb +++ b/spec/commands/edit_spec.rb @@ -726,7 +726,11 @@ describe "edit" do before do Pry.config.editor = lambda do |file, _line| lines = File.read(file).lines.to_a + + # rubocop:disable Lint/InterpolationCheck lines[1] = '"#{super}aa".to_sym' + "\n" + # rubocop:enable Lint/InterpolationCheck + File.open(file, 'w') do |f| f.write(lines.join) end diff --git a/spec/pry_spec.rb b/spec/pry_spec.rb index 306d4de4..1d45320f 100644 --- a/spec/pry_spec.rb +++ b/spec/pry_spec.rb @@ -318,7 +318,9 @@ describe Pry do a.to_i + 1 end + # rubocop:disable Lint/InterpolationCheck expect(mock_pry('++ 86', '++ #{_}')).to match(/88/) + # rubocop:enable Lint/InterpolationCheck end it "should be preserved over an empty line" do