[ANN] kibit, A static code analyzer

381 views
Skip to first unread message

Jonas

unread,
Mar 4, 2012, 2:23:03 PM3/4/12
to clo...@googlegroups.com
Kibit[1] is a simple code analysis tool (and leiningen plugin) which
someone hopefully will find interesting or useful. The purpose of the
tool is to tell its users that "Hey, There's already a function for
that!".

Kibit uses the core.logic[2] unifier to search for patterns of code
for which there might exist simpler functions. For example, if the
analyzer finds

    (apply concat (apply map ...)

It will notify its user about the availability of `mapcat`.

James Reeves

unread,
Mar 4, 2012, 2:29:21 PM3/4/12
to clo...@googlegroups.com
On 4 March 2012 19:23, Jonas <jonas....@gmail.com> wrote:
> Kibit[1] is a simple code analysis tool (and leiningen plugin) which
> someone hopefully will find interesting or useful. The purpose of the
> tool is to tell its users that "Hey, There's already a function for
> that!".

That sounds really cool.

I did spot a few odd rules in control_structures.clj, though:

(if ?x ?y nil) when
(if ?x nil ?y) when-not
(if (not ?x) ?y ?z) if-not

The when form is usually use in place of (if x (do y z)). It's
perfectly valid to write (if x y), which is semantically equivalent to
(if x y nil).

- James

David Nolen

unread,
Mar 4, 2012, 2:39:19 PM3/4/12
to clo...@googlegroups.com
This is just ... fantastic! :D

David

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Alex Baranosky

unread,
Mar 4, 2012, 5:14:22 PM3/4/12
to clo...@googlegroups.com
Indeed very cool idea.  Thanks.

Alex Baranosky

unread,
Mar 4, 2012, 5:44:14 PM3/4/12
to clo...@googlegroups.com
Hi Jonas,

Kibit just helped me find some good uses for inc, pos? when and when-not in Midje, thanks :)
https://github.com/marick/Midje/commit/b0525b7237bf615e3013317d2a0c2fc56f14bfe2

On Sun, Mar 4, 2012 at 5:14 PM, Alex Baranosky <alexander...@gmail.com> wrote:
Indeed very cool idea.  Thanks.

Moritz Ulrich

unread,
Mar 4, 2012, 6:31:01 PM3/4/12
to clo...@googlegroups.com
It would be awesome if this would be integrated in the REPL of in
Clojure itself so it automatically checks *every* form it compiles.

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

--
Moritz Ulrich

Ambrose Bonnaire-Sergeant

unread,
Mar 4, 2012, 8:05:50 PM3/4/12
to clo...@googlegroups.com
What an awesome idea! Nice work Jonas.

Ambrose

--

Jonas

unread,
Mar 4, 2012, 11:25:23 PM3/4/12
to clo...@googlegroups.com


On Sunday, March 4, 2012 9:39:19 PM UTC+2, David Nolen wrote:
This is just ... fantastic! :D


David, quick question about the core.logic unifier. Is it possible to unify on a sequence? For example (when ?x ??body) would unify with both 

    (when (some pred)
       a)

and 
 
    (when (some pred)
       a 
       b 
       c)

Thanks,
Jonas

Jonas

unread,
Mar 4, 2012, 11:26:46 PM3/4/12
to clo...@googlegroups.com


On Monday, March 5, 2012 12:44:14 AM UTC+2, Alex Baranosky wrote:
Hi Jonas,

Kibit just helped me find some good uses for inc, pos? when and when-not in Midje, thanks :)

That's very nice to hear!
 

Tassilo Horn

unread,
Mar 5, 2012, 2:13:17 AM3/5/12
to clo...@googlegroups.com
Jonas <jonas....@gmail.com> writes:

Hi Jonas,

> Kibit[1] is a simple code analysis tool (and leiningen plugin) which
> someone hopefully will find interesting or useful. The purpose of the
> tool is to tell its users that "Hey, There's already a function for
> that!".

It's awesome!

It even caught a rather exotic case

[Kibit] Consider clojure.string/join instead of (apply str (interpose \, (for [...] ...)))

Thanks a lot,
Tassilo

David Nolen

unread,
Mar 5, 2012, 7:51:23 AM3/5/12
to clo...@googlegroups.com
It should unify:

(foo ?x . ?y)

If it doesn't we should open up a ticket for that.

Jonas

unread,
Mar 5, 2012, 9:49:38 AM3/5/12
to clo...@googlegroups.com


On Monday, March 5, 2012 2:51:23 PM UTC+2, David Nolen wrote:
It should unify:

(foo ?x . ?y)

If it doesn't we should open up a ticket for that.

It seems to work, thanks! 



Chip Collier

unread,
Mar 5, 2012, 12:42:12 AM3/5/12
to clo...@googlegroups.com
I'm picturing flymake-clojure in our futures.
Reply all
Reply to author
Forward
0 new messages