clojure-emacs / refactor-nrepl

nREPL middleware to support refactorings in an editor agnostic way
Eclipse Public License 1.0
257 stars 69 forks source link

Add setting that allows keeping unused unaliased requires #386

Closed OknoLombarda closed 2 years ago

OknoLombarda commented 2 years ago

https://github.com/clojure-emacs/refactor-nrepl/issues/292 https://github.com/clojure-emacs/refactor-nrepl/issues/359

Add setting that allows keeping unused unaliased requires, disabled by default

Thanks!

OknoLombarda commented 2 years ago

I'll add tests and update readme if you have no comments regarding the code

vemv commented 2 years ago

The resolution of https://github.com/clojure-emacs/refactor-nrepl/issues/359#issuecomment-1032401701 is quite more recent than the one of the other issue.

I'd like refactor-nrepl to contribute to a more explicit, standarized tooling landscape.

The lack of an alias does't mean much in official Clojure terms. The extra semantic is a clj-kondo invention, that precedes its more explicit :unused-namespace config.

So I'd prefer that people write explicit .clj-kondo config. It's something that refactor-nrepl currently reads. It also is something that other tools (e.g. Eastwood) could also eventually read.

It's a much better approach than reading magic comments (#_,,,) or making up semantics. For users and tool makers alike.

vemv commented 2 years ago

Also, non trivially, one approach is naturally more prone to false positives than the other.

If I add an entry to my .clj-kondo file, then my intent is certain.

Contrariwise, adding [some-lib] without an alias is an everyday action, it can happen for any reason, from any person. So we can easily get a false positive.

For that reason alone, e.g. making our tools correct I think the right approach is clear now. It's not just aesthetics or 'standards'.

Will be moving this PR to draft (with the intent of closing it if there isn't much opposition)

OknoLombarda commented 2 years ago

Yeah, I just though that'd be convenient, but you're right, picking convenience in some situations over correctness is not worth it 【⸟ ͟ʖ⸟】

magnars commented 2 years ago

Any reason this could not be extended to actually using the clj-kondo file? Or is that already supported?

OknoLombarda commented 2 years ago

It is already supported https://github.com/clojure-emacs/refactor-nrepl/pull/361

magnars commented 2 years ago

Excellent 👍👍

vemv commented 2 years ago

Thank you both for the understanding! 🍻