From 8788a4e425f89137b1410ec66e55c1467f37a9ec Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Tue, 3 Oct 2023 17:44:48 -0300 Subject: [PATCH] Improve our Clojure linter to hide warnings by default Warnings can be printed by: make lint CLJ_LINTER_PRINT_WARNINGS=true --- Makefile | 12 +++++++++++- ci/Jenkinsfile.tests | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 17bf25f43330..967d928f51a9 100644 --- a/Makefile +++ b/Makefile @@ -308,11 +308,21 @@ define find_all_clojure_files $$(comm -23 <(sort <(git ls-files --cached --others --exclude-standard)) <(sort <(git ls-files --deleted)) | grep -e \.clj$$ -e \.cljs$$ -e \.cljc$$ -e \.edn) endef +# Lint Clojure files with clj-kondo. +# +# Args: +# $1: When equal to true, print warnings. +define lint_clojure_files + $(if $(filter true,$1), \ + clj-kondo --config .clj-kondo/config.edn --cache false --fail-level error --lint src, \ + clj-kondo --config .clj-kondo/config.edn --cache false --fail-level error --lint src | grep -v ': warning: ') +endef + lint: export TARGET := clojure lint: ##@test Run code style checks @sh scripts/lint-re-frame-in-quo-components.sh && \ sh scripts/lint-old-quo-usage.sh && \ - clj-kondo --config .clj-kondo/config.edn --cache false --fail-level error --lint src && \ + $(call lint_clojure_files, $(CLJ_LINTER_PRINT_WARNINGS)) && \ ALL_CLOJURE_FILES=$(call find_all_clojure_files) && \ zprint '{:search-config? true}' -sfc $$ALL_CLOJURE_FILES && \ sh scripts/lint-trailing-newline.sh && \ diff --git a/ci/Jenkinsfile.tests b/ci/Jenkinsfile.tests index 7fe70c0d9427..0c4eb0679f52 100644 --- a/ci/Jenkinsfile.tests +++ b/ci/Jenkinsfile.tests @@ -48,7 +48,7 @@ pipeline { steps { sh """#!/bin/bash set -eo pipefail - make lint 2>&1 | tee ${LOG_FILE} + make lint CLJ_LINTER_PRINT_WARNINGS=true 2>&1 | tee ${LOG_FILE} """ } }