Skip to content

Commit

Permalink
CheckstyleBear: Detect errors
Browse files Browse the repository at this point in the history
Since 9227382, errors from checkstyle were ignored.

Also set java files to be native EOL in .gitattributes,
to match default EOL expected by Checkstyle rule
NewlineAtEndOfFile.

Fixes coala#1464
  • Loading branch information
jayvdb committed Mar 21, 2017
1 parent 34f1be4 commit 7c1eb9b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .ci/appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ install:
build: false # Not a C# project, build stuff at the test step instead.

test_script:
# Force DOS format, as Checkstyle configs enable NewlineAtEndOfFile,
# which defaults to CRLF on Windows, and Appveyor CI ignores .gitattributes
# http://help.appveyor.com/discussions/problems/5687-gitattributes-changes-dont-have-any-effect
- unix2dos tests/java/test_files/CheckstyleGood.java
# Clang DLLs x64 were nowadays installed, but the x64 version hangs, so we
# exclude according tests. See https://github.com/appveyor/ci/issues/495 and
# https://github.com/appveyor/ci/issues/688
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.java text eol=native
2 changes: 1 addition & 1 deletion bears/java/CheckstyleBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def known_checkstyle_or_path(setting):

@linter(executable='java',
output_format='regex',
output_regex=r'\[(?P<severity>WARN|INFO)\].*?'
output_regex=r'\[(?P<severity>WARN|INFO|ERROR)\].*?'
r'(?P<line>\d+):?(?P<column>\d+)?. '
r'(?P<message>.*?) *\[(?P<origin>[a-zA-Z]+?)\]')
class CheckstyleBear:
Expand Down
10 changes: 5 additions & 5 deletions tests/java/CheckstyleBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ def setUp(self):
self.empty_config = os.path.join(test_files,
'checkstyle_empty_config.xml')

def test_run(self):
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_google(self):
self.section['checkstyle_configs'] = 'google'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_sun(self):
self.section['checkstyle_configs'] = 'sun'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.good_file, valid=False)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_style_android(self):
self.section['checkstyle_configs'] = 'android-check-easy'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

self.section['checkstyle_configs'] = 'android-check-hard'
self.check_validity(self.uut, [], self.good_file)
self.check_validity(self.uut, [], self.bad_file, valid=False)

def test_config_failure_use_spaces(self):
self.section['checkstyle_configs'] = 'google'
Expand Down

0 comments on commit 7c1eb9b

Please sign in to comment.