Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

:config-in-call for :aliased-namespace-var-usage ineffective in quoted forms #1962

Closed
colin-p-hill opened this issue Jan 19, 2023 · 1 comment
Projects

Comments

@colin-p-hill
Copy link

colin-p-hill commented Jan 19, 2023

version

clj-kondo v2023.01.16

platform

Windows 11, native, scoop.

problem

Inside quoted forms, such as a typical macro's body, :config-in-call does not seem capable of disabling the :aliased-namespace-var-usage linter. This can make it difficult to weed out false positives when using macros that can validly accept :as-alias-qualified symbols.

repro

(ns repro
  (:require [clojure.test.check.generators :as-alias gen]))

(defn resolve-alias [sym]
  (let [ns-sym   (symbol (namespace sym))
        sym-name (name sym)]
    (symbol (or (some-> *ns* ns-aliases ns-sym ns-name str)
                (namespace sym))
            sym-name)))

(defmacro res [sym]
  `@(requiring-resolve (resolve-alias '~sym)))

(defmacro sample [sym]
  `((res gen/sample) (res ~sym))) ; warning here

`(res gen/string)                 ; warning here

(sample gen/string)               ; no warning here
> clj-kondo --lint .
.\repro.clj:15:10: warning: Namespace only aliased but wasn't loaded: clojure.test.check.generators
.\repro.clj:17:7: warning: Namespace only aliased but wasn't loaded: clojure.test.check.generators
linting took 34ms, errors: 0, warnings: 2

config

{:config-in-call {repro/res    {:linters {:aliased-namespace-var-usage {:level :off}}}
                  repro/sample {:linters {:aliased-namespace-var-usage {:level :off}}}}}

expected behavior

I expect the configuration provided above to disable these warnings, as it did for the final line.

@borkdude
Copy link
Member

Yeah, this should be disabled by default, using vars like that in syntax-quote is valid without loading the namespace

@borkdude borkdude added this to Needs triage in clj-kondo via automation Jan 19, 2023
@borkdude borkdude moved this from Needs triage to High priority (next release) in clj-kondo Jan 19, 2023
@borkdude borkdude moved this from High priority (next release) to In progress in clj-kondo Jan 20, 2023
clj-kondo automation moved this from In progress to Done Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
clj-kondo
  
Done
Development

No branches or pull requests

2 participants