Introduction & Features

jfacorro edited this page Nov 21, 2014 · 7 revisions

Elvis is a code style checker that can be used to enforce common guidelines in your Erlang project hosted on GitHub by detecting where these are not being met. Once Elvis is activated for your repository then every time a pull request is created or updated, rules will be run and Elvis will add comments on those lines that break any single one of these rules.

One of the advantages of enabling this verification for your project is that by automating part of the reviewing process, only the most important details are left to the reviewer. Since only those lines that have been modified in the pull request are considered when adding comments, it is possible to use Elvis as part of an incremental improvement of your code base.

Rules

The following list is an example of only some of the rules that have been already implemented for Elvis:

  • Nesting Level: there shouldn't be any nested expressions that exceed the limit specified in the configuration.
  • God Modules: there shouldn't be any modules that export a number of functions greater than the limit specified in the configuration.
  • Used Ignored Variable: don't use a variable whose name indicates it is actually an ignored variable (i.e. it starts with an underscore _Var).

Many more rules are available, a complete list can be found in the Elvis GitHub repository's wiki.

Customisation

The set of rules that are run can be selected by specifying a configuration file in your project named elvis.config. In turn, some of these rules accept one or more configuration values that allow for a lot of flexibility when applying them.