diff --git a/.github/workflows/check-style.yml b/.github/workflows/check-style.yml index e907ab6207..1ba9db4f9e 100644 --- a/.github/workflows/check-style.yml +++ b/.github/workflows/check-style.yml @@ -24,4 +24,4 @@ jobs: - name: Install shellcheck and checkbashisms run: sudo apt update && sudo apt install shellcheck devscripts - name: Check style - run: make style + run: make check-style diff --git a/Makefile b/Makefile index 6801fc44bf..df9008fc30 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ all: style gradle-assemble -style: shell-script-style python-style java-style +fix-style: fix-python-style fix-java-style + +check-style: check-shell-script-style check-python-style check-java-style SH_SCRIPTS = $(shell grep --exclude-dir=build --exclude-dir=repos --exclude-dir=cache -r -l '^\#! \?\(/bin/\|/usr/bin/env \)sh' * | grep -v 'git-hires-merge' | grep -v /.git/ | grep -v '~$$' | grep -v '\.tar$$' | grep -v gradlew) BASH_SCRIPTS = $(shell grep --exclude-dir=build --exclude-dir=repos --exclude-dir=cache -r -l '^\#! \?\(/bin/\|/usr/bin/env \)bash' * | grep -v /.git/ | grep -v '~$$' | grep -v '\.tar$$' | grep -v gradlew) @@ -13,16 +15,16 @@ CSV_RESULTS = $(CSV_RESULTS_COMBINED) NUM_PROCESSES = 0 -shell-script-style: - shellcheck -e SC2153 -x -P SCRIPTDIR --format=gcc ${SH_SCRIPTS} ${BASH_SCRIPTS} - checkbashisms ${SH_SCRIPTS} - showvars: @echo "SH_SCRIPTS=${SH_SCRIPTS}" @echo "BASH_SCRIPTS=${BASH_SCRIPTS}" @echo "PYTHON_FILES=${PYTHON_FILES}" -python-style: +check-shell-script-style: + shellcheck -e SC2153 -x -P SCRIPTDIR --format=gcc ${SH_SCRIPTS} ${BASH_SCRIPTS} + checkbashisms ${SH_SCRIPTS} + +fix-python-style: ruff format ${PYTHON_FILES} ruff check ${PYTHON_FILES} --fix @@ -30,6 +32,13 @@ check-python-style: ruff format ${PYTHON_FILES} --check ruff check ${PYTHON_FILES} +fix-java-style: + ./gradlew -q spotlessApply -g ../.gradle/ + +check-java-style: + ./gradlew -q spotlessCheck javadoc requireJavadoc -g ../.gradle/ + + # This target deletes files that are not committed to version control. clean: ${MAKE} clean-workdir @@ -163,9 +172,6 @@ check-merges-reproducibility: protect-repos: find repos -mindepth 1 -type d -exec chmod a-w {} + -java-style: - ./gradlew -q spotlessCheck javadoc requireJavadoc -g ../.gradle/ - download-merge-tools: jars/IntelliMerge-1.0.9-all.jar jars/spork.jar jars/IntelliMerge-1.0.9-all.jar: