{"id":13568433,"url":"https://github.com/clj-commons/kibit","last_synced_at":"2025-12-12T01:08:53.582Z","repository":{"id":2632457,"uuid":"3620296","full_name":"clj-commons/kibit","owner":"clj-commons","description":"There's a function for that!","archived":false,"fork":false,"pushed_at":"2024-05-22T00:06:30.000Z","size":471,"stargazers_count":1764,"open_issues_count":54,"forks_count":132,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-03T07:09:00.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clj-commons.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-03-04T18:57:05.000Z","updated_at":"2025-04-10T03:07:22.000Z","dependencies_parsed_at":"2024-05-22T01:25:49.757Z","dependency_job_id":null,"html_url":"https://github.com/clj-commons/kibit","commit_stats":{"total_commits":342,"total_committers":60,"mean_commits":5.7,"dds":0.760233918128655,"last_synced_commit":"be27e6db625564d045e71a6e13e459eb7651813b"},"previous_names":["jonase/kibit"],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clj-commons%2Fkibit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clj-commons%2Fkibit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clj-commons%2Fkibit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clj-commons%2Fkibit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clj-commons","download_url":"https://codeload.github.com/clj-commons/kibit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254044174,"owners_count":22005093,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T14:00:25.797Z","updated_at":"2025-12-12T01:08:48.553Z","avatar_url":"https://github.com/clj-commons.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# kibit\n\n*There's a function for that!*\n\n`kibit` is a static code analyzer for Clojure, ClojureScript, [cljx](https://github.com/lynaghk/cljx)\n and other Clojure variants. It uses [`core.logic`](https://github.com/clojure/core.logic)\n  to search for patterns of code that could be rewritten with a more idiomatic function\nor macro. For example if kibit finds the code\n\n```clojure\n(if (some test)\n  (some action)\n  nil)\n```\n\nit will suggest using `when` instead:\n\n```clojure\n(when (some test)\n  (some action))\n```\n\n## Maintenance Status\n\n`kibit` is currently in maintenance. It will receive bug fixes and support for new versions of Clojure, but there are no plans for major changes or additions to the core functionality. Why not? `core.logic` is very clever but quite slow, and the existing architecture is such that to move away from `core.logic` would be to rewrite almost the entire library.\n\n[Splint](https://github.com/NoahTheDuke/splint) is such a rewrite, built from the ground-up to be fast and extensible. It supports all of `kibit`'s rules (and many others), runs in a fraction of the time, can be configured from a file, and can output warnings in `kibit`-like text and markdown, as well as clj-kondo-compatible, json, and edn.\n\nFor other Clojure linters, see [clj-kondo](https://github.com/borkdude/clj-kondo) and [Eastwood](https://github.com/jonase/eastwood).\n\n## Usage\n\nAdd `[lein-kibit \"0.1.11\"]` to your `:plugins` vector in your `:user` profile. Then you can run\n\n    $ lein kibit\n\nto analyze a Leiningen project's namespaces. Kibit will automatically pick up source paths from your project.clj from the following keyseqs: `[:source-paths]`, `[:cljsbuild :builds]`, and `[:cljx :builds]`. You can also run Kibit manually on individual files or folders (even if there is no Leiningen `project.clj`) by running:\n\n    $ lein kibit path/to/some/file.clj #or\n    $ lein kibit path/to/src/ #or\n    $ lein kibit path/to/src/clj/ path/to/src/cljs/util.cljs some/combo/of/files/and/folders.cljx\n\n\nIf you want to know how the Kibit rule system works there are some slides available at [http://jonase.github.io/kibit-demo/](http://jonase.github.io/kibit-demo/).\n\n## Exit codes\n\nIf `lein kibit` returns any suggestions to forms then its exit code will be 1. Otherwise it will exit 0. This can be useful to add in a build step for automated testing.\n\n\n    $ lein kibit\n    ... suggestions follow\n\n    $ echo $?\n    1\n\n## Automatically rerunning when files change\n\nYou can use [lein-auto](https://github.com/weavejester/lein-auto) to run kibit automatically when files change. Visit\nlein-auto's README for installation instructions. Note that this will run kibit over all of your files, not just the\nones that have changed.\n\n    $ lein auto kibit\n    auto\u003e Files changed: project.clj, [...]\n    auto\u003e Running: lein kibit\n    ... suggestions follow\n    auto\u003e Failed.\n    auto\u003e Files changed: test/my/test/misc.clj\n    auto\u003e Running: lein kibit\n    ... suggestions follow\n    auto\u003e Failed.\n\n## Automatically replacing suggestions in source file\n\nYou can have kibit automatically apply suggestions to your source files.\n\nGiven a file:\n\n```clojure\n(ns example)\n\n(+ 1 a)\n```\n\n    $ lein kibit --replace\n\nwill rewrite the file as:\n\n```clojure\n(ns example)\n\n(inc a)\n```\n\nReplacement can also be run interactively:\n\n    $ lein kibit --replace --interactive\n     Would you like to replace\n       (+ 1 a)\n      with\n       (inc a)\n     in example.clj:3? [yes/no]\n\n## Reporters\n\nKibit comes with two reporters, the default plaintext reporter, and a GitHub Flavoured Markdown reporter. To specify a reporter, use the `-r` or `--reporter` commandline argument. For example:\n\n    lein kibit --reporter markdown\n    ----\n    ##### `test/project/core.clj:31`\n    Consider using:\n    ```clojure\n      (when true (println \"hi\"))\n    ```\n    instead of:\n    ```clojure\n      (if true (do (println \"hi\")))\n    ```\n\n    ----\n    ##### `test/project/core.clj:32`\n    Consider using:\n    ```clojure\n      (println \"hi\")\n    ```\n    instead of:\n    ```clojure\n      (do (println \"hi\"))\n    ```\n\nwhich renders to:\n\n----\n##### `test/project/core.clj:31`\nConsider using:\n```clojure\n  (when true (println \"hi\"))\n```\ninstead of:\n```clojure\n  (if true (do (println \"hi\")))\n```\n...\n----\n\n## Usage from deps.edn\n\nAdd the following to your aliases\n\n```clojure\n:kibit {:extra-deps {jonase/kibit {:mvn/version \"0.1.11\"}}\n        :exec-fn kibit.driver/exec\n        :exec-args {:paths [\".\"]}}\n```\n\nThen run `clojure -X:kibit`. For more options, please see the\ndocstring on `kibit.driver/exec`.\n\n**NOTE:** At least Clojure v1.9 and Kibit v0.1.11 are required to use this\nexec-fn method.\n\n## Usage from inside Emacs\n\nIf you use Emacs for hacking Clojure, here's a way to use kibit from\ninside Emacs with all the fanciness you are used to from `M-x compile`.\nThe [kibit-helper](https://github.com/brunchboy/kibit-helper) package\navailable from [MELPA](http://melpa.org/) provides several handy\ncommands. First, make sure you have MELPA available as a source of\npackages (which you may well already have done). As described in their\n[Getting started](http://melpa.org/#/getting-started) section, put the\nfollowing into your `~/.emacs`:\n\n```elisp\n(add-to-list 'package-archives\n             '(\"melpa-stable\" . \"http://stable.melpa.org/packages/\") t)\n```\n\n(If you want to be more on the cutting edge, you can include unreleased\nversions of packages using the non-stable URL, as explained in the\nMELPA instructions, but kibit-helper is also available from the less\nexciting stable repository.)\n\nThis will give you three new commands,\n\n    M-x kibit\n    M-x kibit-current-file\n    M-x kibit-accept-proposed-change\n\nThe first two cause the properly highlighted and hyperlinked kibit output to be\npresented in a `*Kibit Suggestions*` buffer. The third lets you automatically\napply most of those suggestions to your source. (Suggestions which cite large\nblocks of code including comments cannot be automatically applied, as Kibit\ndiscards comments during processing.)\n\nYou will likely want to bind the last function to \u003ckbd\u003eC-x\u003c/kbd\u003e\n\u003ckbd\u003eC-\\`\u003c/kbd\u003e so it is easy to alternate with the `next-error`\nfunction (conventionally \u003ckbd\u003eC-x\u003c/kbd\u003e \u003ckbd\u003e\\`\u003c/kbd\u003e) as you walk\nthrough the suggestions made by Kibit:\n\n```elisp\n(global-set-key (kbd \"C-x C-`\") 'kibit-accept-proposed-change)\n```\n\n## Usage from inside vim (through Leiningen plugin)\n\n[kibit-vim](https://github.com/fbeline/kibit-vim) allows you to analyze the current opened file by running:\n\n`:Kibit`\n\n## Usage from inside vim (with vim-fireplace)\n\nIf you have [vim-fireplace](https://github.com/tpope/vim-fireplace/) installed, you can use [vim-kibit](https://github.com/humorless/vim-kibit) to run Kibit on your current buffer through the running REPL session.\n\nvim-kibit is invoked by running:\n\n`:Kibit`\n\n## Known limitations\n\nKibit\n[reads](http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/read)\nsource code without any macro expansion or evaluation. A macro can\ntherefore easily invalidate a rule. Also, kibit will not know if the\nsymbol `+` in the form `(+ x 1)` actually refers to a local or to a\nfunction in a namespace other than `clojure.core`. Expect\nsome false positives.\n\n## Contributing\n\nIt is very easy to write new patterns for `kibit`. Take a look at\n[`control-structures.clj`](https://github.com/clj-commons/kibit/blob/master/src/kibit/rules/control_structures.clj)\nto see how new patterns are created. If you know of a recurring\npattern of code that can be simplified, please consider sending me a\npull request.\n\nBugs can be reported using the GitHub [issue tracker](https://github.com/clj-commons/kibit/issues/).\n\n## Contributors\n\nThanks to all who have [contributed](https://github.com/clj-commons/kibit/graphs/contributors) to kibit!\n\n## TODO\n\n* Leiningen project.clj setting for rule exclusion\n* Leiningen project.clj setting for a directory of rules to include\n\n## License\n\nCopyright © 2012 Jonas Enlund\n\nDistributed under the Eclipse Public License, the same as Clojure.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclj-commons%2Fkibit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclj-commons%2Fkibit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclj-commons%2Fkibit/lists"}