diff --git a/.gitignore b/.gitignore index 70547b3..7ba3e05 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ priv *.plt ebin _build +.elvis diff --git a/Makefile b/Makefile index e465514..5529151 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +ELVIS_IN_PATH := $(shell elvis --version 2> /dev/null) +ELVIS_LOCAL := $(shell .elvis/_build/default/bin/elvis --version 2> /dev/null) + all: compile compile: @@ -6,6 +9,12 @@ compile: clean: rebar3 clean +eunit: + rebar3 eunit + +ct: + rebar3 ct -v + xref: rebar3 xref @@ -20,3 +29,30 @@ unlock: lock: rebar3 lock + +elvis: +ifdef ELVIS_IN_PATH + elvis git-branch origin/HEAD -V +else ifdef ELVIS_LOCAL + .elvis/_build/default/bin/elvis git-branch origin/HEAD -V +else + $(MAKE) compile_elvis + .elvis/_build/default/bin/elvis git-branch origin/HEAD -V +endif + +elvis_rock: +ifdef ELVIS_IN_PATH + elvis rock +else ifdef ELVIS_LOCAL + .elvis/_build/default/bin/elvis rock +else + $(MAKE) compile_elvis + .elvis/_build/default/bin/elvis rock +endif + +compile_elvis: + git clone https://github.com/inaka/elvis.git .elvis && \ + cd .elvis && \ + rebar3 compile && \ + rebar3 escriptize && \ + cd .. diff --git a/elvis.config b/elvis.config new file mode 100644 index 0000000..7fe968d --- /dev/null +++ b/elvis.config @@ -0,0 +1,81 @@ +%% -*- erlang -*- +[ {elvis, + [ {config, + [ #{dirs => [ "src/*" + , "src" + ], + filter => "*.erl", + ignore => [], + rules => [ {elvis_style, line_length, + #{ limit => 80, + skip_comments => false + }} + , {elvis_style, no_tabs} + , {elvis_style, no_trailing_whitespace} + , {elvis_style, macro_module_names} + , {elvis_style, nesting_level, + #{ level => 3, + ignore => [ + ] + }} + , {elvis_style, god_modules, + #{ limit => 25, + ignore => [ + ] + }} + , {elvis_style, no_nested_try_catch, + #{ignore => [ + ] + }} + , {elvis_style, invalid_dynamic_call, + #{ignore => [ + ] + }} + , {elvis_style, used_ignored_variable} + , {elvis_style, no_behavior_info} + , {elvis_style, module_naming_convention, + #{ ignore => [], + regex => "^([a-z][a-z0-9]*_?)([a-z0-9]*_?)*$" + }} + , {elvis_style, function_naming_convention, + #{ regex => "^([a-z][a-z0-9]*_?)([a-z0-9]*_?)*$" + }} + , {elvis_style, variable_naming_convention, + #{ regex => "^_?([A-Z][0-9a-zA-Z_]*)$" + }} + , {elvis_style, state_record_and_type} + , {elvis_style, no_spec_with_records} + , {elvis_style, dont_repeat_yourself, + #{ min_complexity => 25, + ignore => [ + ] + }} + ] + }, + #{dirs => [ "test" + ], + filter => "*.erl", + rules => [ {elvis_style, line_length, + #{ limit => 80, + skip_comments => false + }} + , {elvis_style, no_tabs} + , {elvis_style, no_trailing_whitespace} + , {elvis_style, macro_module_names} + , {elvis_style, no_debug_call, + #{ignore => [ + ] + }} + ] + } + ] + } + ] + } +]. + +%%%_* Emacs ==================================================================== +%%% Local Variables: +%%% allout-layout: t +%%% erlang-indent-level: 2 +%%% End: