Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalastyle: capture messages with no line number #368

Merged
merged 2 commits into from
Apr 20, 2016
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master (unreleased)

* Fix `Scalastyle` pre-commit hook to capture messages with no line number
* Fix `CoffeeLint` pre-commit hook detection of modified lines

## 0.33.0
Expand Down
4 changes: 2 additions & 2 deletions lib/overcommit/hook/pre_commit/scalastyle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Scalastyle < Base
MESSAGE_REGEX = /
^(?<type>error|warning)\s
file=(?<file>(?:\w:)?.+)\s
message=.+\s
line=(?<line>\d+)
message=.+\s*
(line=(?<line>\d+))?
/x

def run
Expand Down
36 changes: 32 additions & 4 deletions spec/overcommit/hook/pre_commit/scalastyle_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,21 @@
OUT
end

it { should warn }
it { should warn(/Use : Unit = for procedures/) }
end

context 'and it reports a warning with no line' do
before do
result.stub(stderr: '', stdout: normalize_indent(<<-OUT))
warning file=file1.scala message=File must end with newline character
Processed 1 file(s)
Found 0 errors
Found 1 warnings
Finished in 490 ms
OUT
end

it { should warn(/File must end with newline character/) }
end
end

Expand All @@ -64,7 +78,21 @@
OUT
end

it { should fail_hook }
it { should fail_hook(/Use : Unit = for procedures/) }
end

context 'and it reports an error with no line' do
before do
result.stub(stderr: '', stdout: normalize_indent(<<-OUT))
error file=file1.scala message=File must end with newline character
Processed 1 file(s)
Found 1 errors
Found 0 warnings
Finished in 490 ms
OUT
end

it { should fail_hook(/File must end with newline character/) }
end

context 'with a usage message' do
Expand All @@ -83,7 +111,7 @@
OUT
end

it { should fail_hook }
it { should fail_hook(/Usage/) }
end

context 'with a runtime error' do
Expand All @@ -104,7 +132,7 @@
ERR
end

it { should fail_hook }
it { should fail_hook(/Exception/) }
end
end
end