diff --git a/Dockerfile b/Dockerfile index aa6980bc..de432d97 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,8 @@ RUN pip install --no-cache-dir \ ./review ENV LINTERS_DIRECTORY /opt/linters + +ENV CHECKSTYLE_VERSION 8.44 ENV CHECKSTYLE_DIRECTORY ${LINTERS_DIRECTORY}/checkstyle ENV DETEKT_VERSION 1.14.2 @@ -29,4 +31,7 @@ RUN curl -sSLO https://github.com/detekt/detekt/releases/download/v${DETEKT_VERS && unzip detekt-cli-${DETEKT_VERSION}.zip -d ${DETEKT_DIRECTORY} \ && curl -H "Accept: application/zip" https://repo.maven.apache.org/maven2/io/gitlab/arturbosch/detekt/detekt-formatting/${DETEKT_VERSION}/detekt-formatting-${DETEKT_VERSION}.jar -o ${DETEKT_DIRECTORY}/detekt-formatting-${DETEKT_VERSION}.jar +# Install Checkstyle +RUN curl -L https://github.com/checkstyle/checkstyle/releases/download/checkstyle-${CHECKSTYLE_VERSION}/checkstyle-${CHECKSTYLE_VERSION}-all.jar > ${CHECKSTYLE_DIRECTORY}/checkstyle-${CHECKSTYLE_VERSION}-all.jar + CMD ["/bin/bash"] diff --git a/README.md b/README.md index 7f8b70df..2b76b2d7 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ The source code of **hyperstyle** is distributed under the Apache 2.0 License. The 3rd party software we use in this project has its own licenses. -Python language: +Python language (all versions can be found in the (requirements.txt)[requirements.txt] file): - [x] flake8 [MIT] * [Site and docs](https://flake8.pycqa.org/en/latest/) @@ -40,11 +40,11 @@ Python language: Java language: -- [x] PMD [BSD] +- [x] PMD [BSD] * [Site and docs](https://pmd.github.io/) * [Repository](https://github.com/pmd/pmd) -- [x] Checkstyle [GNU LGPL v2.1] (Version: 6.36.0) +- [x] Checkstyle [GNU LGPL v2.1] (Version: 8.44) * [Site and docs](https://checkstyle.sourceforge.io/) * [Repository](https://github.com/checkstyle/checkstyle) diff --git a/src/python/review/inspectors/checkstyle/checkstyle.py b/src/python/review/inspectors/checkstyle/checkstyle.py index 127ec9cb..bc841676 100644 --- a/src/python/review/inspectors/checkstyle/checkstyle.py +++ b/src/python/review/inspectors/checkstyle/checkstyle.py @@ -1,8 +1,9 @@ import logging +import os from pathlib import Path from typing import Any, Dict, List -from src.python.review.common.file_system import new_temp_dir +from src.python.review.common.file_system import check_set_up_env_variable, new_temp_dir from src.python.review.common.subprocess_runner import run_in_subprocess from src.python.review.inspectors.base_inspector import BaseInspector from src.python.review.inspectors.checkstyle.issue_types import CHECK_CLASS_NAME_TO_ISSUE_TYPE @@ -12,8 +13,14 @@ logger = logging.getLogger(__name__) +CHECKSTYLE_DIRECTORY_ENV = 'CHECKSTYLE_DIRECTORY' +check_set_up_env_variable(CHECKSTYLE_DIRECTORY_ENV) +CHECKSTYLE_VERSION_ENV = 'CHECKSTYLE_VERSION' +check_set_up_env_variable(CHECKSTYLE_VERSION_ENV) + +PATH_CHECKSTYLE_JAR = f'{os.environ[CHECKSTYLE_DIRECTORY_ENV]}/checkstyle-{os.environ[CHECKSTYLE_VERSION_ENV]}-all.jar' + PATH_TOOLS_PMD_FILES = Path(__file__).parent / 'files' -PATH_TOOLS_CHECKSTYLE_JAR = PATH_TOOLS_PMD_FILES / 'checkstyle.jar' PATH_TOOLS_CHECKSTYLE_CONFIG = PATH_TOOLS_PMD_FILES / 'config.xml' @@ -37,7 +44,7 @@ class CheckstyleInspector(BaseInspector): @classmethod def _create_command(cls, path: Path, output_path: Path) -> List[str]: return [ - 'java', '-jar', PATH_TOOLS_CHECKSTYLE_JAR, + 'java', '-jar', PATH_CHECKSTYLE_JAR, '-c', PATH_TOOLS_CHECKSTYLE_CONFIG, '-f', 'xml', '-o', output_path, str(path), ] diff --git a/src/python/review/inspectors/checkstyle/files/checkstyle.jar b/src/python/review/inspectors/checkstyle/files/checkstyle.jar deleted file mode 100644 index 9b6d6e7d..00000000 Binary files a/src/python/review/inspectors/checkstyle/files/checkstyle.jar and /dev/null differ