Skip to content

Commit

Permalink
Simplify maintenance of Elvis linter rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kivra-pauoli committed Aug 29, 2024
1 parent be59210 commit 4ea5d9d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 92 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ _build
rebar3.crashdump
*~
.edts
.elvis
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
erlang 25.3.2.13
29 changes: 1 addition & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ELVIS_IN_PATH := $(shell elvis --version 2> /dev/null)
ELVIS_LOCAL := $(shell .elvis/_build/default/bin/elvis --version 2> /dev/null)

all: compile

compile:
Expand Down Expand Up @@ -33,29 +30,5 @@ 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 ..
rebar3 lint
65 changes: 3 additions & 62 deletions elvis.config
Original file line number Diff line number Diff line change
@@ -1,74 +1,15 @@
%% -*- erlang -*-
[ {elvis,
[ {config,
[ #{dirs => [ "src/*"
, "src"
[ #{dirs => [ "src"
],
filter => "*.erl",
ignore => [],
ruleset => [{elvis_style, state_record_and_type, disable}],
rules => [ {elvis_text_style, line_length,
#{ limit => 100,
skip_comments => false
}}
, {elvis_text_style, no_tabs}
, {elvis_text_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 => [
]
}}
]
ruleset => erl_files
},
#{dirs => [ "test"
],
filter => "*.erl",
rules => [ {elvis_text_style, line_length,
#{ limit => 100,
skip_comments => false
}}
, {elvis_text_style, no_tabs}
, {elvis_text_style, no_trailing_whitespace}
, {elvis_style, macro_module_names}
, {elvis_style, no_debug_call,
#{ignore => [ prop_pubkeys_storage,
prop_id_token_sign
]
}}
]
ruleset => erl_files
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
{apps, [id_token]}
]}.

{project_plugins, [rebar3_proper]}.
{project_plugins, [
{rebar3_proper, "0.12.1"},
{rebar3_lint, "3.2.6"}
]}.

{profiles,
[{test, [
Expand Down

0 comments on commit 4ea5d9d

Please sign in to comment.