clj-kondo

skylize 2025-01-01T01:36:49.000069Z

clojure.string/capitalize --> Unresolved namespace clojure.string. Are you missing a require? This seems incorrect. In my mind this doesn't even warrant a warning, but in any case it seems to resolve just fine.

2025-01-01T01:44:35.706419Z

The set of clojure.* namespaces that are loaded by clojure itself so they do not need to be required has changed in the past (but it has been a while). It is best to require whatever you use beyond clojure.core

πŸ‘ 1
skylize 2025-01-01T01:50:02.755749Z

I can understand that. Still seems like an incorrect warning to me, especially in a .cljc file, which limits how old a version of clojure can be supported.

skylize 2025-01-01T01:52:41.782189Z

Maybe we need a unique warning for clojure built-ins warning you "shouldn't rely on Clojure to always provide this namespace without a require"?

seancorfield 2025-01-01T02:22:34.680889Z

I don't think it's good practice to use a namespace qualifier without requiring it, regardless of whether it just happens to "always" be already loaded by the time your code runs... I think it's a perfectly reasonable warning.

skylize 2025-01-01T02:25:04.758329Z

Thanks for reiterating that. Still (not= good-practice correct-warning)

seancorfield 2025-01-01T02:25:56.900009Z

FWIW, it varies between -M -e and what is loaded by the time a bare REPL is up and running, so it's very much an implementation detail and not to be relied on.

skylize 2025-01-01T02:31:23.363399Z

I don't think it's reasonable to expect the average coder to know such gritty details as "it's an implementation detail". I opened this thread thinking it doesn't even deserve a warning, and have been corrected. But as someone who has not been coding in Clojure since it's inceptions, I still hold this deserves a warning unique from just "unresolved".

dpsutton 2025-01-01T02:34:59.247279Z

Are you arguing this linter should not be default on or this linter should not exist?

seancorfield 2025-01-01T02:41:58.943149Z

Given that (loaded-libs) changes across contexts, how is clj-kondo to know that an ns is already loaded? And how is this different to requiring some library ns and then using nses that ns just happened to require without explicitly requiring it yourself? I don't think clj-kondo can tell, in general, whether there's a missing require or not, when it finds an ns being used that you have not required.

2025-01-01T02:45:26.920549Z

I am kind of at a loss, clj-kondo is a linter, linters commonly encourage good style

skylize 2025-01-01T02:46:01.399999Z

I'm not arguing to quit warning. I'm arguing that clojure.* namespaces, which one would expect to load in on their own (but theoretically might not) need their own linter.

seancorfield 2025-01-01T02:46:51.286789Z

Create an issue on GH -- but I don't think clj-kondo can reliably tell what's loaded, even for clojure.* nses.

skylize 2025-01-01T02:49:39.764929Z

Since we started as a thread, I'm just waiting for agreement from borkdude that he's willing to implement it, or allow implementing it, or at least hammock the idea, before opening an issue.

seancorfield 2025-01-01T02:50:59.993879Z

My point is that clj-kondo can't tell whether clojure.something is loaded before it is used -- that's runtime behavior.

skylize 2025-01-01T02:52:06.483629Z

But it can certainly tell that it's clojure.something and I'm sure a list can be put together of which of those are usually loaded.

skylize 2025-01-01T03:05:09.108079Z

Essentially, I'm asking for more info, so that "I" (the next person to come along thinking the same) know this is not just an oversight in clj-kondo to be ignored, without needing to fix "my" own code.

seancorfield 2025-01-01T03:05:17.425669Z

I was curious so I checked earlier Clojure versions: β€’ 1.0 and 1.1 only loaded clojure.main β€’ 1.2 added http://clojure.java.io (unchanged in 1.3) β€’ 1.4 added clojure.string β€’ 1.5 added three more (unchanged in 1.6 and 1.7) β€’ 1.8 added two more β€’ 1.9 added three more (unchanged in 1.10, 1.11, and 1.12) That's just -e '(loaded-libs)' -- what you get in the REPL is different and what you get in a running program is different (more things are loaded by the implementation in the REPL than in running a program).

skylize 2025-01-01T03:07:48.037279Z

Should be based primarily on larger set from the repl, I think, for all the versions. Cover all the cases where a user might see that warning, but say "but it's resolving just fine".

seancorfield 2025-01-01T03:12:08.549709Z

If your code "satisfies" the REPL context, it might break when you run it for real, if you ignore the warning...

skylize 2025-01-01T03:13:00.964859Z

Yeah, which one might hope clj-kondo could save you from. Right?

skylize 2025-01-01T03:13:23.158269Z

Not if you ignore the warning because it's seems b.s.

dpsutton 2025-01-01T03:14:01.680869Z

Yeah. Wondering what happens in an uberjar context. Which contexts is it valid to rely on the namespace being loaded

seancorfield 2025-01-01T03:17:15.757189Z

The uberjar context has fewer nses loaded than the -M -m context, both of which have fewer than the REPL.

dpsutton 2025-01-01T03:19:08.703049Z

I like the idea of a linter around the typically loaded namespaces. Not just clojure.* since that would get edn and others. Have a way to disable it. But I would never disable this linter

seancorfield 2025-01-01T03:27:24.820999Z

@dpsutton Do you think folks can use clojure.edn without requiring it? (since you mentioned it) -- no peeking in the REPL or the source code! πŸ™‚

dpsutton 2025-01-01T03:27:44.827739Z

No I don’t think so

seancorfield 2025-01-01T03:28:06.871409Z

Yup, you can.

dpsutton 2025-01-01T03:28:45.948909Z

today-i-learned

seancorfield 2025-01-01T03:28:51.828059Z

Here's the 1.12 list for an uberjar with a minimal main ns and -main fn: clojure.core.protocols clojure.core.server clojure.edn clojure.instant http://clojure.java.io clojure.main clojure.spec.alpha clojure.spec.gen.alpha clojure.string clojure.uuid clojure.walk

seancorfield 2025-01-01T03:29:22.626779Z

(as noted above, that's version dependent -- although it hasn't changed for a few versions at this point)

skylize 2025-01-01T03:51:15.651779Z

Since bork doesn't seem to be around right now, and I got at least 1 clear thumbs up, went ahead and filed it. https://github.com/clj-kondo/clj-kondo/issues/2460

seancorfield 2025-01-01T04:48:30.819849Z

Yes! While I may seem very "anti", it's always worth creating an issue for discussion with the maintainer (and other community members who might care).

skylize 2025-01-01T07:13:46.647399Z

Still glad I held off. Arguing about it moved me from a vague "this doesn't seem right" to a clear "this is what's wrong, and what to do about it."

seancorfield 2025-01-01T07:33:13.955939Z

Clarifying the problem statement is important...

borkdude 2025-01-01T09:39:05.566949Z

replied in the issue

borkdude 2025-01-01T09:39:17.214009Z

happy new year

skylize 2025-01-01T17:28:08.300549Z

happy new year to you too

skylize 2025-01-01T01:44:57.037849Z

Having a lot of trouble with a :local/root dependency. When I save changes in the dependency, clj-kondo usually seems to forget it knows how to resolve all the symbols from that module, and often requiring a cache deletion to get things working again. Any tips for managing parallel coding between a dependency and its dependent more cleanly than constant cache deletion?

seancorfield 2025-01-01T02:44:10.665559Z

Is this in the editor? Which editor?

seancorfield 2025-01-01T02:45:24.847759Z

(I ask because I use Polylith at work and it's all :local/root deps everywhere and I don't have this problem with clj-kondo and changes in VS Code)

skylize 2025-01-01T03:10:25.563129Z

Calva

skylize 2025-01-01T03:12:16.973919Z

It's inconsistent whether it fails. Can't give accurate frequency, but feels like around 90% of saves.

borkdude 2025-01-01T09:41:05.695379Z

I can't remember having seen behavior like this before. Perhaps you can make a repro? Preferably using linting from the command line, so we can have the editor out of the equation.

skylize 2025-01-01T17:27:40.354149Z

I'll see what I can do. thx