Skip to content

Commit c3aaad8

Browse files
committed
[#18] Updated config files. Created config/old folder to hold previous configuration file format.
1 parent ff81082 commit c3aaad8

8 files changed

Lines changed: 89 additions & 25 deletions

File tree

config/elvis-test.config

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,36 @@
33
elvis,
44
[
55
{config,
6-
#{src_dirs => ["../../src"],
7-
rules => [{elvis_style, line_length, [80]},
8-
{elvis_style, no_tabs, []},
9-
{elvis_style, macro_names, []},
10-
{elvis_style, macro_module_names, []},
11-
{elvis_style, operator_spaces, [{right, ","},
12-
{right, "++"},
13-
{left, "++"}]},
14-
{elvis_style, nesting_level, [3]},
15-
{elvis_style, god_modules, [25]},
16-
{elvis_style, no_if_expression, []},
17-
{elvis_style, invalid_dynamic_call, [elvis]},
18-
{elvis_style, used_ignored_variable, []},
19-
{elvis_style, no_behavior_info, []},
20-
{
21-
elvis_style,
22-
module_naming_convention,
23-
["^([a-z][a-z0-9]*_?)*(_SUITE)?$", []]
24-
}
25-
]
26-
}
6+
[#{src_dirs => ["../../src"],
7+
rules => [{elvis_style, line_length, [80]},
8+
{elvis_style, no_tabs, []},
9+
{elvis_style, macro_names, []},
10+
{elvis_style, macro_module_names, []},
11+
{elvis_style, operator_spaces, [{right, ","},
12+
{right, "++"},
13+
{left, "++"}]},
14+
{elvis_style, nesting_level, [3]},
15+
{elvis_style, god_modules, [25]},
16+
{elvis_style, no_if_expression, []},
17+
{elvis_style, invalid_dynamic_call, [elvis]},
18+
{elvis_style, used_ignored_variable, []},
19+
{elvis_style, no_behavior_info, []},
20+
{
21+
elvis_style,
22+
module_naming_convention,
23+
["^([a-z][a-z0-9]*_?)*(_SUITE)?$", []]
24+
}
25+
]
26+
},
27+
#{dirs => ["."],
28+
filter => "Makefile",
29+
rules => [{elvis_project, no_deps_master_erlang_mk, []}]
30+
},
31+
#{dirs => ["."],
32+
filter => "rebar.config",
33+
rules => [{elvis_project, no_deps_master_rebar, []}]
34+
}
35+
]
2736
}
2837
]
2938
}

config/elvis.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
module_naming_convention,
2424
["^([a-z][a-z0-9]*_?)*(_SUITE)?$", []]
2525
}
26-
]},
26+
]
27+
},
2728
#{dirs => ["."],
2829
filter => "Makefile",
2930
rules => [{elvis_project, no_deps_master_erlang_mk, []}]

config/old/elvis-test.config

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[
2+
{
3+
elvis,
4+
[
5+
{config,
6+
#{src_dirs => ["../../src"],
7+
rules => [{elvis_style, line_length, [80]},
8+
{elvis_style, no_tabs, []},
9+
{elvis_style, macro_names, []},
10+
{elvis_style, macro_module_names, []},
11+
{elvis_style, operator_spaces, [{right, ","},
12+
{right, "++"},
13+
{left, "++"}]},
14+
{elvis_style, nesting_level, [3]},
15+
{elvis_style, god_modules, [25]},
16+
{elvis_style, no_if_expression, []},
17+
{elvis_style, invalid_dynamic_call, [elvis]},
18+
{elvis_style, used_ignored_variable, []},
19+
{elvis_style, no_behavior_info, []},
20+
{
21+
elvis_style,
22+
module_naming_convention,
23+
["^([a-z][a-z0-9]*_?)*(_SUITE)?$", []]
24+
}
25+
]
26+
}
27+
}
28+
]
29+
}
30+
].

config/test.config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
module_naming_convention,
2424
["^([a-z][a-z0-9]*_?)*(_SUITE)?$", []]
2525
}
26-
]},
26+
]
27+
},
2728
#{dirs => ["."],
2829
filter => "Makefile",
2930
rules => [{elvis_project, no_deps_master_erlang_mk, []}]

src/elvis_utils.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ filter_files(Files, Filter) ->
185185
-spec glob_to_regex(iodata()) -> iodata().
186186
glob_to_regex(Glob) ->
187187
Regex1 = re:replace(Glob, "\\.", "\\\\."),
188-
re:replace(Regex1,"\\*",".*").
188+
re:replace(Regex1,"\\*", ".*").
189189

190190
%% @doc Takes a line, a character and a count, returning the indentation level
191191
%% invalid if the number of character is not a multiple of count.

test/elvis_SUITE.erl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
rock_with_incomplete_config/1,
1414
rock_with_list_config/1,
1515
rock_with_file_config/1,
16+
rock_with_old_config/1,
1617
%% Webhook
1718
run_webhook/1,
1819
run_webhook_ping/1,
@@ -118,6 +119,26 @@ rock_with_file_config(_Config) ->
118119
check_some_line_output(Fun, Expected, fun matches_regex/2),
119120
ok.
120121

122+
-spec rock_with_old_config(config()) -> ok.
123+
rock_with_old_config(_Config) ->
124+
ConfigPath = "../../config/old/elvis.config",
125+
ElvisConfig = elvis_config:load_file(ConfigPath),
126+
ok = try
127+
elvis:rock(ElvisConfig),
128+
ok
129+
catch
130+
throw:{invalid_config, _} -> fail
131+
end,
132+
133+
ConfigPath1 = "../../config/old/elvis-test.config",
134+
ElvisConfig1 = elvis_config:load_file(ConfigPath1),
135+
ok = try
136+
elvis:rock(ElvisConfig1),
137+
ok
138+
catch
139+
throw:{invalid_config, _} -> fail
140+
end.
141+
121142
%%%%%%%%%%%%%%%
122143
%%% Webhook
123144

test/git_SUITE.erl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ check_staged_files(_Config) ->
7070
file:write_file(Filename, <<"sdsds">>, [append]),
7171

7272
os:cmd("git add " ++ Filename),
73-
[#{path := "temp_file_test"}] = elvis_git:staged_files(),
73+
StagedFiles = elvis_git:staged_files(),
74+
FilterFun = fun (#{path := Path}) -> Path == "temp_file_test" end,
75+
[_] = lists:filter(FilterFun, StagedFiles),
7476
os:cmd("git reset " ++ Filename),
7577

7678
file:delete(Filename).

0 commit comments

Comments
 (0)