Fork me on GitHub
Drew Verlee02:02:51

would there be a way to use clj-kondo to read clojure and sort of expand regular clojure the same way you do macro expand? Like (defn foo [x] x) (defn bar [x] (foo x)) -> expand "(foo x)" -> (defn bar [x] x)


cool, idea. something like "term rewrite" but in clojure such analyser have to take in account that foo is not static value, it is a reference that can be redefined in runtime


Hi all! I just had a situation that caught me off guard. I had a test that should fail, but didn’t when running the tests from the command line (poly test in my case). The reason turned out to be that the namespace name of the test file did not match the file name. I was surprised that clj-kondo didn’t catch this. Do you think this would be a good linter to add to clj-kondo? I.e.: check whether the namespace name matches the filename + path of the file?


@stefan.van.den.oord Absolutely and there is already an issue for it. It might be a relatively easy one if you want to hack on it.


Cool, I will definitely keep that in mind. I think I might pick that up quite soon.


@U04V15CAJ Could you jump-start me by telling roughly where I should add my code?


Somewhere here: In the ctx is a key called :file that you can use to compare to the name of the namespace


For the unit test I think it would be easiest to create a couple of test resource files that I then read in in the unit test, is that ok with you? (Just checking because this way of testing by reading actual files doesn’t seem to be used yet.)


yes, there is a directory called "corpus" for this


A right I just found that, sorry for asking too quickly.


@stefan.van.den.oord you can disable the linter for all of the other tests in test_utils


Yeah thanks, that’s indeed the strategy that I’m working on 🙂 I didn’t know about the base config there, that’s going to make it a lot easier, thanks! 🙂


How should it behave (in real-life) when there are multiple ns-forms in a file?


Currently it will report the ones that don’t match the file name. I think that’s desired behaviour, do you agree @U04V15CAJ?


Perhaps just take the first one?


That does make the linter more complex of course. I’m not sure what the use case would be for this. You can always silence the warnings with comments in the file…


I’m calling it the day. 🛏️ There’s a few failing tests remaining that I have to look into, I will followup soon.


Re multiple ns forms: the question is I think: in cases where this occurs in real life, is it by accident or on purpose most of the time? I have never felt the need to have multiple ns forms in one file.


Ok, then why the question? Did this come up in the tests?


I saw it in corpus/use.clj.


Not after disabling my linter in base test setup of course, but that’s why it made me think.


yeah, ok. I think it's ok to just keep it simple and lint it always


we can change it when we need to.

👍 1

Now locally all tests are passing, but not in CI. Not sure what’s going on. But that will have to wait till tomorrow. Good night!


Good night!



(->> '("Mike" "Tom" "Jerry")
     (map (fn [x] (count x)))
     (cond->> true (map str)))
gives the same warning to me, so your lint-as seems to be working :)


Oh, right, cond->> might not be a good linter for ?>>. Nope, I did not 😬


The example doesn't run, but throws an exception


sorry @U04V15CAJ, I was too eager and added a unnecessary lint-as statements for ?>>. There is no issue. Sorry.


Have you tried executing that example?


For exported config (in our case marick/midge/config.edn) is it expected that we would add this to source control or gitignore it and let each user's computer generate it for them?


@danielcompton I prefer to check it into source control so everyone has the same consistent linting results

👍 2

also when you don't scan your classpath in a clean checkout