Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setting that allows keeping unused unaliased requires #386

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/refactor_nrepl/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
;; sort etc
:prune-ns-form true

;; When true `clean-ns` will not remove unused requires without aliases
:keep-unused-unaliased-requires false

;; Should `clean-ns` favor prefix forms in the ns macro?
:prefix-rewriting false

Expand Down
7 changes: 5 additions & 2 deletions src/refactor_nrepl/ns/prune_dependencies.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[refactor-nrepl.core :as core]
[refactor-nrepl.find.symbols-in-file :as symbols-in-file]
[refactor-nrepl.ns.libspec-allowlist :as libspec-allowlist]
[refactor-nrepl.util :as util]))
[refactor-nrepl.util :as util]
[refactor-nrepl.config :as config]))

(defn- lookup-symbol-ns
([ns symbol]
Expand Down Expand Up @@ -60,7 +61,9 @@
symbols-in-file)
(some (partial libspec-in-use-without-refer-all? libspec)
symbols-in-file))
(libspec-in-use-with-rename? libspec symbols-in-file))
(libspec-in-use-with-rename? libspec symbols-in-file)
(and (not libspec-as)
Copy link
Member

@expez expez Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example in clj-kondo linters file is (ns foo (:require [foo.specs])).

In other words, this will allow both foo.specs and [foo.specs] to remain, but isn't the wrapping what's used to signal that it's side-effecting in the clj-kondo convention?

Copy link
Contributor Author

@OknoLombarda OknoLombarda Sep 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem like clj-kondo cares about brackets
image
image

(:keep-unused-unaliased-requires config/*config*)))
libspec)))

(defn- referred-symbol-in-use?
Expand Down