Skip to content
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
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
Expand All @@ -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)

Expand Down
13 changes: 10 additions & 3 deletions src/python/review/inspectors/checkstyle/checkstyle.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'


Expand All @@ -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),
]
Expand Down
Binary file not shown.