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
Make kibit configurable via .kibit/config.edn #236
base: master
Are you sure you want to change the base?
Make kibit configurable via .kibit/config.edn #236
Conversation
It also bothers me, that an initial intention (per the project README) was to have these features configurable via
This is necessary for running kibit with exclusions/custom rules in a CI server environment. |
@@ -41,17 +42,60 @@ | |||
(sort-by #(.getAbsolutePath ^File %) | |||
(filter clojure-file? (file-seq dir)))) | |||
|
|||
(declare read-edn-file) | |||
|
|||
(defn- opts [^java.io.File cfg-file] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to know what this fn is necessary for. Could you, please, add a docstring?
(recur parent))))))) | ||
|
||
(defn- get-config-map [] | ||
(let [cfg-dir (config-dir (io/file (System/getProperty "user.dir")))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicates line 65. Just call (config-dir)
here?
(eval rule#) ;; raw rule, no need to compile | ||
(compile-rule rule#)))] | ||
{:form rule# | ||
:compiled (if (raw-rule? rule#) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes perfect sense to extract this (if (raw-rule? ...) ...)
into a dedicated fn + reuse it in check.clj
.
@danielcompton any thoughts on improving this any further? |
Reading a separate file for configuration instead of extending command line args seems like a bad idea |
The way most cli tools work is having a set of locations they look for the configuration and an order of applying them so that the "latest" wins out. clj-kondo, for example, does it this way: it merges left to right $HOME, the current project, command-line args, and then the config metadata in the current namespace. I think doing something similar would be fine. Should probably wait until we've named the rules, however. |
@danielcompton I created this fork myself, hope that helps others too.