Skip to content

Commit

Permalink
Improve our Clojure linter to hide warnings by default
Browse files Browse the repository at this point in the history
Warnings can be printed by:

    make lint CLJ_LINTER_PRINT_WARNINGS=true
  • Loading branch information
ilmotta committed Oct 3, 2023
1 parent 2f29d3e commit 8788a4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion ci/Jenkinsfile.tests
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""
}
}
Expand Down

0 comments on commit 8788a4e

Please sign in to comment.