diff --git a/lib/overcommit/hook/pre_commit/reek.rb b/lib/overcommit/hook/pre_commit/reek.rb index a3387194..b6ff8363 100644 --- a/lib/overcommit/hook/pre_commit/reek.rb +++ b/lib/overcommit/hook/pre_commit/reek.rb @@ -11,7 +11,7 @@ def run extract_messages( output, - /^(?[^:]+):(?\d+):/, + /^\s*(?[^:]+):(?\d+):/, ) end diff --git a/spec/overcommit/hook/pre_commit/reek_spec.rb b/spec/overcommit/hook/pre_commit/reek_spec.rb index 3b978c88..3499f907 100644 --- a/spec/overcommit/hook/pre_commit/reek_spec.rb +++ b/spec/overcommit/hook/pre_commit/reek_spec.rb @@ -28,15 +28,35 @@ end context 'and it reports warnings' do - before do - result.stub(:stdout).and_return([ - 'file1.rb -- 1 warning:', - 'file1.rb:1: MyClass#my_method performs a nil-check. (NilCheck)' - ].join("\n")) - result.stub(:stderr).and_return('') + context 'in old format' do + before do + result.stub(:stdout).and_return([ + 'file1.rb -- 1 warning:', + 'file1.rb:1: MyClass#my_method performs a nil-check. (NilCheck)' + ].join("\n")) + result.stub(:stderr).and_return('') + end + + it { should fail_hook } + it 'parses the right file' do + subject.run.map(&:file).should == ['file1.rb'] + end end - it { should fail_hook } + context 'in new format' do + before do + result.stub(:stdout).and_return([ + 'file1.rb -- 1 warning:', + ' file1.rb:1: MyClass#my_method performs a nil-check. (NilCheck)' + ].join("\n")) + result.stub(:stderr).and_return('') + end + + it { should fail_hook } + it 'parses the right file' do + subject.run.map(&:file).should == ['file1.rb'] + end + end end end end