-
Notifications
You must be signed in to change notification settings - Fork 133
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
Enumerating rules #175
Comments
Yep, I've thought this would be a handy feature to have for lots of different purposes. Happy to see a PR for this. |
Yes just a few questions/ideas: Are all the equivalences considered equal? Or some "mistakes" can be considered worse than others (as for linting, where you have errors/warnings). So for the implementation I think one way could be to define each rule like this instead:
That would give an identifier and another potential string with a more verbose explanation. |
I haven't looked for a while, but I'm 99% sure that all of the rules are transformations on code which should be transparent to any callers, i.e. Kibit suggests style changes, but doesn't catch broken code. One possibility for syntax: (defrules rules
;; clojure.string
{:rule [(apply str (interpose ?x ?y)) (clojure.string/join ?x ?y)]
:id :interpose->string-join
:name "string/join instead of interpose"
:explanation "Prefer clojure.string/join instead of interpose for string building."}
{:rule [(apply str (reverse ?x)) (clojure.string/reverse ?x)]
:id :reverse->string-reverse
:name "string/reverse instead of reverse"
:explanation "Prefer clojure.string/reverse instead of clojure.core/reverse"}
[(apply str ?x) (clojure.string/join ?x)] ) The nice thing about this layout is that the rules can be converted and upgraded over time. Thoughts about the metadata:
Perhaps hold off on implementation for a little bit longer so we can see what other use cases come up that we need to take into account? |
Thanks for mentioning me @danielcompton. What we might use a field like It looks like we presently build this content from the before/after snippets: https://github.com/codeclimate/codeclimate-kibit/blob/master/src/codeclimate/kibit.clj#L19 I'm not a heavy Kibit user, but the current approach seems reasonable to me. So I wouldn't add an |
I think there might be quite a bit of repetition between id/name/explanation potentially, specially for the very simple sustitutions. And the other thing is that normally most linting tools define some alphanumeric (shorter) identifier for each warning, which I think generally makes it easier to skip/filter/etc.
And explanation can also be there sure but could probably be optional.. It's easy to then have a table lookup in the docs to check what each id mean and use them for all the filtering you want.. I'm afraid otherwise just using names could potentially generate confusing/very long names/ What do you think @danielcompton @pbrisbin ? |
And by the way how would you think about doing a change like this @danielcompton ?
Do the rules need to be annotated all together? |
Any news on this? |
Hey, that sounds like a pretty good starting point. It's a little bit hard to imagine without seeing the output/configuration, but I think it's a good place to start from.
I don't think so, possibly defrules syntax similar to what I showed in #175 (comment) could be good? |
Mm well @danielcompton as I mentioning #175 (comment) That example you gave is a bit repetitive, and the :id is not alphanumeric, which for me generally makes it much easier to make the ids unique and enumerate all the rules.. |
Oh sure, I agree with your plans, I was just meaning this syntax: (defrules rules
;; clojure.string
<map or vector repeated here>
[(apply str ?x) (clojure.string/join ?x)] ) would allow you to migrate things over slowly. |
Related to:
#174
I just wanted to see myself where was this rule defined and if I could simply fix it maybe.
Differently from most other linting tools however the kibit report doesn't contain any code on each error, making it more complicated to know what it's referring to exactly.
I think it would be great to give a unique identifier to each rule and output that as well in the report.
This would also allow other cool things like filtering on certain rules, excluding checks and so on and so forth..
The text was updated successfully, but these errors were encountered: