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

Update README for custom rules #141

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ to analyze a Leiningen project's namespaces. Kibit will automatically pick up so

If 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/).

## Custom rules

Kibit supports specifying custom rules.

You can define custom rule as follows:

```clojure
(ns custom.rules.ns
(:require [kibit.rules.util :refer [defrules]]))


(defrules rules
[(remove nil? ?coll) (keep identity ?coll)])
```


To use custom rules in your project, add the following in your project.clj:

```clojure
kibit {:rules (merge kibit.rules/rule-map
{:ctrl custom.rules.ns/rules})
:source-paths ["rules"]}
```

All the rules files must be in directories specified in the `source-paths`. Specifying `source-paths` is important. Kibit will run `require` on all namespaces found in `source-paths`.


## Exit codes

If `lein kibit` returns any suggestions to forms then it's exit code will be 1. Otherwise it will exit 0. This can be useful to add in a build step for automated testing.
Expand Down Expand Up @@ -174,11 +201,6 @@ Bugs can be reported using the GitHub [issue tracker](https://github.com/jonase/

Thanks to all who have [contributed](https://github.com/jonase/kibit/graphs/contributors) to kibit!

## TODO

* Leiningen project.clj setting for rule exclusion
* Leiningen project.clj setting for a directory of rules to include

## License

Copyright © 2012 Jonas Enlund
Expand Down