This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-10
Channels
- # announcements (10)
- # aws (5)
- # babashka (81)
- # babashka-sci-dev (4)
- # beginners (100)
- # calva (60)
- # clj-kondo (34)
- # clojars (1)
- # clojure (30)
- # clojure-austin (12)
- # clojure-berlin (1)
- # clojure-europe (45)
- # clojure-italy (5)
- # clojure-losangeles (9)
- # clojure-nl (3)
- # clojure-norway (10)
- # clojure-spec (1)
- # clojurescript (8)
- # community-development (2)
- # conjure (5)
- # cursive (10)
- # data-science (2)
- # datalog (1)
- # emacs (4)
- # events (10)
- # fulcro (6)
- # jobs-discuss (8)
- # lambdaisland (3)
- # leiningen (2)
- # luminus (5)
- # membrane (61)
- # off-topic (8)
- # portal (5)
- # releases (20)
- # sci (25)
- # scittle (6)
- # shadow-cljs (25)
- # testing (6)
- # xtdb (11)
Is there a way to use the repl to launch the clj-kondo? When I use Calva to Jack-in, and then evaluate main.clj, I get
clj꞉clj-kondo.main꞉>
; Evaluating file: main.clj
; Syntax error (ClassNotFoundException) compiling at (src/clj_kondo/main.clj:1:1).
; clj-kondo.main
; Evaluation of file main.clj failed: class clojure.lang.Compiler$CompilerException
I've been looking into https://github.com/clj-kondo/clj-kondo/issues/1824 and it would be great to either use the REPL when making code changes, or to debug the code with something like flow-storm. I can do builds as they are described on https://github.com/clj-kondo/clj-kondo/blob/master/doc/build.md, but doing a full build is slow.Yes, of course, you can use clj-kondo from the REPL:
$ clj
Clojure 1.11.0
user=> (require '[clj-kondo.main])
nil
user=> (require '[clj-kondo.core :as clj-kondo])
nil
user=> (:findings (with-in-str "(+ :foo)" (clj-kondo/run! {:lint ["-"]})))
[{:filename "<stdin>", :row 1, :col 4, :end-row 1, :end-col 8, :type :type-mismatch, :message "Expected: number, received: keyword.", :level :warning}]
Thanks! This is among my first dive into a real-world clojure project, so I appreciate the guidance
hey y’all, I’ve added this to my config.edn yet I’m still getting a warning:
{:linters
{:unresolved-symbol
{:exclude [(clojure.test/is [match?])]}}}
Any idea what might be going on here? One place I’m getting a warning is https://github.com/donut-power/datapotato/blob/main/datapotato/test/donut/datapotato/atom_test.cljc#L74adding cljs.test fixed it! thank you
I have been trying to figure out how to resolve an unexpected inline def warning related clojure.spec. The :inline-def
occurs when using inline keys
specs inside a def
or defn
, for example:
(require '[clojure.spec.alpha :as s])
;; Simplified case
(def foo (s/keys :req-un [::abc] :opt-un [::xyz]))
;; Basic use case
(defn gen-my-map [] (s/gen (s/keys :req-un [::abc] :opt-un [::xyz])))
I get warnings for these using version 2022.10.05
and other recent versions. I know the specs are macro driven, but I don't see any signs that keys
generates any def
s.I can't reproduce this locally. Can you make a standalone file including extension and upload it here? Back in an hour.
Ugh, I created a test file and get the warning in one project, but not in another, even with the config.edn
moved out of the way. Looks like I need to work a little more on reproducing this.
Here is the example as a file. Sometimes I get warnings, sometimes I don't, still trying to figure out what triggers the different results. (cache, configuration, copied configurations, etc.)
Usually I get the following output when checking the file above, but sometimes I don't. Haven't found a clear pattern yet.
$ clj-kondo --version
clj-kondo v2022.10.05
$ clj-kondo --lint inline_spec.clj
inline_spec.clj:4:10: warning: inline def
inline_spec.clj:7:28: warning: inline def
linting took 12ms, errors: 0, warnings: 2
Nevermind, I found the following nonsense in my global config.edn
file.
{:lint-as {clojure.spec.alpha/keys clojure.core/def}}
Don't know how that got there. Thanks for looking into this.Fulcro has a large collection of generated DOM element factory https://github.com/fulcrologic/fulcro/blob/d9f6090219900798fb2f6640cf44d6c319a4f99f/src/main/com/fulcrologic/fulcro/dom.cljs#L17 with server and client support. clj-kondo doesn't provide arglists or docstrings for these factories in the :var-definition analysis. Is there a recommended way of dealing with things like this?
Here is the definition for it:
[{:end-row 30
:meta nil
:name-end-col 11
:name-end-row 17
:name-row 17
:ns com.fulcrologic.fulcro.dom
:name a
:defined-by cljs.core/declare
:filename "fulcrologic/fulcro/src/main/com/fulcrologic/fulcro/dom.cljs"
:col 1
:name-col 10
:end-col 45
:row 17}
Whereas the generated docstring for all of them is like this:
*com.fulcrologic.fulcro.dom/div*
[& args]
Returns a React DOM element. Can be invoked in several ways
These two are made equivalent at compile time
(div "hello")
(div nil "hello")
These two are made equivalent at compile time
(div {:onClick f} "hello")
(div #js {:onClick f} "hello")
There is also a shorthand for CSS id and class names
(div :#the-id.klass.other-klass "hello")
(div :#the-id.klass.other-klass {:onClick f} "hello"))
The :var-usages info also does not include :arity
:
{:end-row 6
:name-end-col 51
:name-end-row 6
:name-row 6
:name div
:filename "ui/reports/function_profile.cljs"
:from ui.reports.function-profile
:col 48
:name-col 48
:end-col 51
:refer true
:row 6
:to com.fulcrologic.fulcro.dom}
That is produced from this code:
(div :.sixteen.wide.column.segment "test")
To make this more tooling friendly, one could choose to generate the code to disk instead of only via a macro at compile time
Or write a hook which expands this call into stuff that clj-kondo understands better
Is there a way to write a single hook that would cover all of those generated items? They essentially expand to the same kind of form and all have the same (almost) docstring.
a single hook yes, but you would need to have a mapping for all of those vars in the config currently
that would help with var-definition since you can expand this into a hook which generates the right var definition
Alright, thank you. I will do it for these Fulcro items. Are you otherwise interested in receiving reports about such analysis peculiarities? I'm running clj-kondo analysis on many libraries and trying to fit the results into a normalized SQL schema. In most cases things work just as they should but there are quite a number of mismatches across the ecosystem. By mismatches I mean cases where a var usage doesn't match up to some expected var definition foreign key.