Skip to content

Commit be1d6a9

Browse files
committed
Fix JavaCheckstyle message processing regex
Error lines now start with `[ERROR]`, which was apparently not always the case. This was causing errors like the following: No such file or directory @ rb_sysopen - [ERROR] /path/to/src/... Fix it by expanding the regex to ignore an optional prefix in square brackets. Fixes sds#358.
1 parent 42bb495 commit be1d6a9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* Fix `AuthorName`/`AuthorEmail` pre-commit hooks to respect
66
`GIT_AUTHOR_NAME`/`GIT_AUTHOR_EMAIL` environment variables, respectively
7+
* Fix `JavaCheckstyle` pre-commit hook to ignore `[ERROR]` prefix when parsing
8+
output messages
79

810
## 0.32.0
911

lib/overcommit/hook/pre_commit/java_checkstyle.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Overcommit::Hook::PreCommit
33
#
44
# @see http://checkstyle.sourceforge.net/
55
class JavaCheckstyle < Base
6-
MESSAGE_REGEX = /^(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
6+
MESSAGE_REGEX = /^(\[[^\]]+\]\s+)?(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
77

88
def run
99
result = execute(command, args: applicable_files)

0 commit comments

Comments
 (0)