Skip to content
Snippets Groups Projects
Unverified Commit 3d0bc85a authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Kondo linter tests for `:metabase/validate-logging` (#43104)

* PoC Kondo linter test

* Log linter tests

* Remove fail-test
parent a3f19cd8
No related branches found
No related tags found
No related merge requests found
Showing
with 10 additions and 40 deletions
;; -*- comment-column: 100; -*-
{:config-paths ["macros"]
{:config-paths ["macros" "src"]
:linters
{:aliased-namespace-symbol {:level :warning}
:invalid-arity {:skip-args [metabase.lib.util.match/match]} ; TODO (cam): can we fix these?
......
......@@ -376,8 +376,15 @@
(when (hooks/token-node? node)
(let [sexpr (hooks/sexpr node)]
(when (symbol? sexpr)
(when-let [resolved (hooks/resolve {:name sexpr})]
(symbol (name (:ns resolved)) (name (:name resolved)))))))
(let [resolved (hooks/resolve {:name sexpr})]
(cond
(and resolved (:ns resolved))
(symbol (name (:ns resolved)) (name (:name resolved)))
;; if it wasn't resolved but is still qualified it's probably using the full namespace name rather than an
;; alias.
(qualified-symbol? sexpr)
sexpr)))))
;; some symbols like `*count/Integer` aren't resolvable.
(catch Exception _
nil)))
......
......@@ -124,40 +124,3 @@
(check-for-i18n-format-specifiers node format-string)
(check-format-string-arg-count node format-string args)))
x)
(comment
;; should fail, missing a format arg
(infof
{:node (api/parse-string
(str '(log/warnf "Migration lock was acquired after %d retries.")))})
(infof
{:node (api/parse-string
(str '(log/warnf e "Migration lock was acquired after %d retries.")))})
;; should fail, too many format args
(infof
{:node (api/parse-string
(str '(log/warnf "Migration lock was acquired after %d retries." 1 2)))})
(infof
{:node (api/parse-string
(str '(log/warnf e "Migration lock was acquired after %d retries." 1 2)))})
(infof
{:node (api/parse-string
(str '(log/warnf "Migration lock was acquired after {0} retries." 1)))})
;; should fail, has format args but is warn rather than warnf
(info
{:node (api/parse-string
(str '(log/warn e "Migration lock was acquired after %d retries." 1 2)))})
;; should fail -- should not use i18n/tru or i18n/trs
(infof
{:node (api/parse-string
(str '(log/warnf (metabase.util.i18n/tru "Migration lock was acquired after {0} retries." 1))))})
(info
{:node (api/parse-string
(str '(log/warn (metabase.util.i18n/trs "Migration lock was acquired after {0} retries." 1))))}))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment