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

Recommend a linter for Clojure? #14

Closed
kytrinyx opened this issue Aug 17, 2014 · 8 comments
Closed

Recommend a linter for Clojure? #14

kytrinyx opened this issue Aug 17, 2014 · 8 comments

Comments

@kytrinyx
Copy link
Member

See exercism/docs#54 for details.

@kytrinyx kytrinyx changed the title Recommend a linter for Clojure Recommend a linter for Clojure? Aug 17, 2014
@mathias
Copy link
Contributor

mathias commented Oct 21, 2014

One issue that we'll run into with most Clojure code quality tools (I covered a couple in a blog post) is that they expect a proper Leiningen project setup, since the tools themselves are Leiningen plugins. The one exception that does work is kibit. I run it like this:

exercism/clojure/rna-transcription$ lein kibit rna_transcription.clj

As long as the path to the file to check is indicated (and Kibit has been added to the user's ~/.lein/profiles.clj as the instructions for Kibit suggest) it works great as a code smell detector and for suggesting more-idiomatic code. But it isn't quite a linter, in the sense that something like JSHint is. https://github.com/dakrone/lein-bikeshed might be better for traditional linter tasks (line too long, etc.) but it would require changing all the exercises to be proper Leiningen projects. Eastwood is also likely to have helpful feedback for programmers new to Clojure, but it both requires a Leiningen project and can have unexpected results if it can trigger any side effects by loading the code (which, come to think of it, should not be a problem for any of the exercises I've worked on so far, as long as it only loads source files and not tests)

@kytrinyx
Copy link
Member Author

Kibit sounds interesting, even if it's not a completely traditional linter.

We're going to add a "leinify" command to the exercism CLI, so we could point to linters for people who choose to use it.

@canweriotnow
Copy link
Contributor

kibit is also easy to integrate into emacs:

;; kibit

;; Teach compile the syntax of the kibit output
(require 'compile)
(add-to-list 'compilation-error-regexp-alist-alist
             '(kibit "At \\([^:]+\\):\\([[:digit:]]+\\):" 1 2 nil 0))
(add-to-list 'compilation-error-regexp-alist 'kibit)

;; A convenient command to run "lein kibit" in the project to which
;; the current emacs buffer belongs to.
(defun kibit ()
  "Run kibit on the current project.
Display the results in a hyperlinked *compilation* buffer."
  (interactive)
  (compile "lein kibit"))

(defun kibit-current-file ()
  "Run kibit on the current file.
Display the results in a hyperlinked *compilation* buffer."
  (interactive)
  (compile (concat "lein kibit " buffer-file-name)))

But as @mathias pointed out, kibit's more about writing 'idiomatic' code than traditional linting... and it is showing its age... was just discussing this on #clojure IRC yesterday.

@kytrinyx is there a thread on the leinify cmd addition? I'm trying to keep pace with the CLI in exercism-emacs package, and I could see some really useful support from CIDER and clojure-mode in doing an 'enhanced' leinification from within emacs.

FWIW, I liked the lack of a project.clj in the exercises, helped to keep it simple, and removed direct support for 3rd party libs I discussed in #39

@kytrinyx
Copy link
Member Author

kytrinyx commented Apr 9, 2015

We have a thread open here: exercism/cli#102 -- it stalled a bit because I got ridiculously busy, but now that there are 3 core contributors to the CLI package, things have been moving more quickly again.

@canweriotnow
Copy link
Contributor

Ah, gotcha. Just commented there with some suggestions on how to achieve this... it occurs to me after the fact that the lein-template suggestion I made over there would also ease access for exercism-emacs or any other editor packages/tools people wanted to write.

@kytrinyx
Copy link
Member Author

That would be cool. Anything to lower the barrier to tool-writing seems like a good thing in my book.

@canweriotnow
Copy link
Contributor

How about adding squiggly-clojure to the default project.clj, it uses Eastwood and core.typed w/ Flycheck to lint as you type... I guess that's mainly of help to emacs users, but I think there are some similar things for other editors.

It would be interesting to do a survey of editor usage/preference per-track and across the board...

@kytrinyx
Copy link
Member Author

I'm down with that. A survey would be interesting... I wonder what the easiest way to implement that would be (external tool, presumably?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants