Skip to content

Commit

Permalink
CheckstyleBear: Download checkstyle.jar on demand
Browse files Browse the repository at this point in the history
Fixes coala#47
  • Loading branch information
sils committed May 15, 2016
1 parent 1c2cd39 commit 3c23210
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
20 changes: 9 additions & 11 deletions bears/java/CheckstyleBear.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import os

from coalib.bearlib.abstractions.Linter import linter
from coalib.settings.Setting import path


DIR_PATH = os.path.dirname(os.path.abspath(__file__))

checkstyle_jar_file = os.path.join(DIR_PATH, 'checkstyle.jar')

known_checkstyles = {
"google": "https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/google_checks.xml",
"sun": 'https://raw.githubusercontent.com/checkstyle/checkstyle/master/src/main/resources/sun_checks.xml',
Expand All @@ -27,10 +21,7 @@ def known_checkstyle_or_path(setting):
output_format='regex',
output_regex=r'\[(?P<severity>WARN|INFO)\] *.+:'
r'(?P<line>\d+)(?::(?P<column>\d+))?: *'
r'(?P<message>.*?) *\[(?P<origin>[a-zA-Z]+?)\]',
prerequisite_check_command=('java', '-jar', checkstyle_jar_file, '-v'),
prerequisite_check_fail_message='jar file ' + checkstyle_jar_file +
' not found.')
r'(?P<message>.*?) *\[(?P<origin>[a-zA-Z]+?)\]')
class CheckstyleBear:
"""
Check Java code for possible style, semantic and design issues.
Expand All @@ -41,6 +32,12 @@ class CheckstyleBear:

LANGUAGES = "Java"

def setup_dependencies(self):
type(self).checkstyle_jar_file = self.download_cached_file(
'http://sourceforge.net/projects/checkstyle/files/checkstyle/6.15'
'/checkstyle-6.15-all.jar',
"checkstyle.jar")

def create_arguments(
self, filename, file, config_file,
checkstyle_configs: known_checkstyle_or_path="google"):
Expand Down Expand Up @@ -68,4 +65,5 @@ def create_arguments(
known_checkstyles[checkstyle_configs],
checkstyle_configs + ".xml")

return '-jar', checkstyle_jar_file, '-c', checkstyle_configs, filename
return ('-jar', self.checkstyle_jar_file, '-c',
checkstyle_configs, filename)
4 changes: 0 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ def run(self):


if __name__ == "__main__":
download('http://sourceforge.net/projects/checkstyle/files/checkstyle/'
'6.15/checkstyle-6.15-all.jar',
'bears/java/checkstyle.jar')

download('https://oss.sonatype.org/content/repositories/releases/org/'
'scalastyle/scalastyle_2.10/0.8.0/scalastyle_2.10-0.8.0-batch.jar',
'bears/scala/scalastyle.jar')
Expand Down

0 comments on commit 3c23210

Please sign in to comment.