Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/overcommit/hook/pre_commit/reek.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def run

extract_messages(
output,
/^(?<file>[^:]+):(?<line>\d+):/,
/^\s*(?<file>[^:]+):(?<line>\d+):/,
)
end

Expand Down
34 changes: 27 additions & 7 deletions spec/overcommit/hook/pre_commit/reek_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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