-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelvis.config
More file actions
92 lines (92 loc) · 4.37 KB
/
Copy pathelvis.config
File metadata and controls
92 lines (92 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
%% Style rules enforced by `rebar3 lint'.
%%
%% Formatting proper — indentation, line breaks, spacing — belongs to erlfmt
%% (`make format'), so the rules kept here are the ones a formatter cannot
%% check: naming, module size, nesting, and common correctness smells.
%%
%% Written for elvis_core 5.x, which dropped the `{elvis, [...]}' wrapper and
%% replaced each entry's `dirs' + `filter' with a `files' glob list. Rule
%% names also changed (`god_modules' -> `no_god_modules',
%% `line_length' -> `max_line_length', and friends),
%% and elvis only *warns* and skips when it meets an old name — a stale name
%% silently stops applying instead of failing. `rebar3_lint' is pinned in
%% rebar.config so that cannot drift underneath us again.
[
{config, [
#{
files => ["src/**/*.erl"],
ruleset => erl_files,
rules => [
%% erlfmt wraps at 96; allow slack for spec and doc lines
%% it will not break.
{elvis_text_style, max_line_length, #{limit => 100}},
%% The default pattern rejects `_Ignored', which is the
%% standard way to name an unused argument in Erlang.
{elvis_style, variable_naming_convention, #{
regex => "^_?([A-Z][0-9a-zA-Z]*)$"
}},
%% The defaults forbid a digit right after an underscore,
%% which rules out names built around JSON-RPC codes and
%% HTTP statuses.
{elvis_style, function_naming_convention, #{
regex => "^[a-z][a-z0-9_]*$"
}},
{elvis_style, atom_naming_convention, #{
regex => "^[a-z][a-z0-9_]*$"
}},
%% `throw/1' is how a handler raises a JSON-RPC error from
%% inside nested code; json_rpc_error:throw_error/2,3 is
%% that documented API.
{elvis_style, no_throw, disable},
%% The exported types here are the library's public
%% vocabulary: other modules name them in their specs, and
%% callers pattern match on them (a handler destructures the
%% context as `#{connection_pid := Pid}'). Making them opaque
%% would break exactly the use they exist for.
{elvis_style, private_data_types, disable},
%% Dispatch exists to call registered handlers, so the
%% dynamic call in it is the entire point.
{elvis_style, no_invalid_dynamic_calls, #{
ignore => [json_rpc_dispatcher]
}},
%% json_rpc_worker waits for a DOWN it has already guaranteed
%% by calling exit/2 while holding the monitor. A timeout
%% there could only mask a broken invariant.
{elvis_style, no_receive_without_timeout, #{
ignore => [json_rpc_worker]
}}
]
},
#{
files => ["test/**/*.erl"],
ruleset => erl_files,
rules => [
{elvis_text_style, max_line_length, #{limit => 100}},
{elvis_style, variable_naming_convention, #{
regex => "^_?([A-Z][0-9a-zA-Z]*)$"
}},
{elvis_style, function_naming_convention, #{
regex => "^[a-z][a-z0-9_]*$"
}},
{elvis_style, atom_naming_convention, #{
regex => "^[a-z][a-z0-9_]*$"
}},
{elvis_style, no_throw, disable},
{elvis_style, private_data_types, disable},
%% ?assertMatch expands its pattern into a guard, so elvis
%% reads every `_Ignored' binding in an assertion as used.
{elvis_style, no_used_ignored_variables, disable},
%% A suite is one exported function per case by design.
{elvis_style, no_god_modules, disable},
%% Suites repeat their setup shape on purpose: each case
%% should read on its own without chasing a helper.
{elvis_style, dont_repeat_yourself, disable},
{elvis_style, no_block_expressions, disable}
]
},
#{
files => ["rebar.config"],
ruleset => rebar_config
}
]}
].