inaka / elvis

Erlang Style Reviewer
Apache License 2.0
426 stars 87 forks source link

Document `-elvis` attribute #535

Closed paulo-ferraz-oliveira closed 3 years ago

paulo-ferraz-oliveira commented 4 years ago

Related to inaka/elvis_core#136.

Edit: can be used to update the Rules wiki. Once the related PR is accepted.

Tentative documentation follows.

The -elvis attribute

Per-module rules can also be configured using attribute -elvis(_)., with the same content as is expected in elvis.config's rules option, e.g.:

-elvis([{elvis_style, no_behavior_info, #{}}]).
-elvis([{elvis_style, no_nested_try_catch}]).

Note: a single attribute with a list of rules is the same as multiples attributes with a list of rules each - the rules are "merged" - as in:

-elvis([{elvis_style, no_behavior_info, #{}}, {elvis_style, no_nested_try_catch}]).

The ignore attribute, in this case, has limited value, since it'll be ignored for "other" modules. You can always play with the following, but results may not be surprising.

-module(mymodule).
-elvis([{elvis_style, nesting_level, #{level => 4, ignore => [mymodule]}}]).
...
elbrujohalcon commented 4 years ago

Haha! The ignore part... I would have forgotten about it entirely. Nice touch. Looks good.

paulo-ferraz-oliveira commented 3 years ago

I've added this to the Rules wiki since it's already available in master.