Fork me on GitHub
#clj-kondo
<
2023-02-27
>
Carlo12:02:09

I'm writing code using the https://github.com/rm-hull/infix library, for a module with heavy mathematical content. For a simple example, consider:

(infix bpm0 * (1 + percent-bpm-change))
this yields the warning: a number is not a function [not-a-function] . I tried to edit the clj-kondo config.edn like:
{:linters {:not-a-function {:exclude [(infix.macros/infix)]}}}
but I can't get the warning to go away. What am I missing?

borkdude12:02:38

Can you try:

:config-in-call {library/infix {:linters {:not-a-function {:level :off}}}}

❤️ 2
borkdude12:02:55

replace library/infix with the appropriate namespace

Carlo12:02:16

Yes thank you @U04V15CAJ that immediately fixed the issue! I'll look :config-in-call in the documentation, if you have pointers feel free to share! 🙂

borkdude12:02:37

The documentation should have that covered :)

🙌 2
🎉 2
prnc16:02:25

Hello 👋 I’m seeing clj-kondo v2023.01.20 reporting issues with re-frame layer 3 subscriptions (taking other subs as input) in the presence of :rename . It’s something I’ve not seen in previous versions

prnc16:02:14

What’s interesting if I just :rename that one thing [reg-sub sub] it seems to be OK with that 😉

borkdude16:02:22

Doesn't ring a bell. Feel free to provide an issue + repro, preferably something that I can just copy/paste into my editor with the full namespace form

prnc16:02:58

Sure, will do—thank you!

Noah Bogart22:02:31

#expectations’s expectations.clojure.test/defexpect can do a short-circuit check, where if a name symbol and two forms, wraps the two forms in an (expect) call. So you can write (defexpect some-func-test :ret-val (some-func)) and it will work like a normal (deftest some-func-test (is (= :ret-val (some-func)))). However, if you want to test against a string and you have :lint-as {expectations.clojure.test/defexpect clojure.test/deftest}, then clj-kondo throws a warning/error saying "misplaced docstring", even tho clojure.test/deftest doesn't accept a docstring either. is this worth a github issue or is there a smarter way to lint defexpect calls?

borkdude22:02:58

:config-in-call {foo/defexpect {:linters {:missing-docstring {:level :off}}}}
is maybe a good workaround

👍 2
seancorfield22:02:15

@UEENNMX0T Can you add that as an example to https://github.com/clojure-expectations/clojure-test/issues/29 so I can provide better hooks for that library?

👍 2
borkdude22:02:04

I can't really repro your problem @UEENNMX0T

(ns foo
  {:clj-kondo/config '{:linters {:missing-docstring {:level :warning}}
                       :lint-as {foo/deftest clojure.test/deftest}}})

(defmacro deftest "docs" [& _args])
(deftest foo)
I don't see a warning for a missing docstring for foo there

Noah Bogart01:02:56

minimal reproduction

Noah Bogart01:02:01

one might say it's an unused value, but it's not a docstring:

(meta #'docstring-error)
; {:test #function[noahtheduke.spat-test/fn--24046],
;  :line 373,
;  :column 1,
;  :file "/home/noah/personal/spat/test/noahtheduke/spat_test.clj",
;  :name docstring-error,
;  :ns #namespace[noahtheduke.spat-test]}

borkdude08:02:45

Ah I see, :misplaced-docstring . Yeah, I think that should never happen in deftest :)

👍 2
borkdude08:02:49

Issue welcome

👍 2
Noah Bogart16:02:55

I gave it a go but it relies on analyze-defn and I couldn't figure out how to wrap the body without triggering other linting errors lol (like a do or a let block)

borkdude16:02:51

@UEENNMX0T I think misplaced docstring should only be emitted when the resolved-var is defn, not when it's deftest

Noah Bogart16:02:51

ah, so check for :test metadata in analyze-defn?

borkdude16:02:59

probably yes

👍 2
borkdude19:02:28

definded-by is probably better since a regular defn may also have test metadata (and I'm not sure if it will be at the name symbol when linting applies)

👍 2