Skip to content

Commit

Permalink
[Fix #468] Add include_dirs/1 to elvis_config
Browse files Browse the repository at this point in the history
  • Loading branch information
harenson committed Jul 31, 2017
1 parent 4eb50a1 commit 9020a48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ in the root directory:
[
{config,
[#{dirs => ["src"],
include_dirs => ["include"],
filter => "*.erl",
ruleset => erl_files
},
Expand Down Expand Up @@ -130,6 +131,9 @@ in the root directory:
].
```

The `include_dirs` key is just a list of folders (`[string()]`) where to search for
header files.

The `dirs` key is a list that indicates where `elvis` should look for the
files that match `filter`, which will be run through each of the default rules
in the specified `ruleset`, which is an *atom*. If you want to override the
Expand Down
11 changes: 11 additions & 0 deletions src/elvis_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
normalize/1,
%% Geters
dirs/1,
include_dirs/1,
ignore/1,
filter/1,
files/1,
Expand All @@ -27,6 +28,7 @@
-define(DEFAULT_CONFIG_PATH, "./elvis.config").
-define(DEFAULT_REBAR_CONFIG_PATH, "./rebar.config").
-define(DEFAULT_FILTER, "*.erl").
-define(DEFAULT_INCLUDE_DIRS, ["include"]).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Public
Expand Down Expand Up @@ -116,6 +118,15 @@ dirs(_RuleGroup = #{dirs := Dirs}) ->
dirs(#{}) ->
[].

% Only get `include_dirs' value for erl files RuleGroup, discard other ones.
-spec include_dirs(Config::config() | map()) -> [string()].
include_dirs(Config) when is_list(Config) ->
lists:flatmap(fun include_dirs/1, Config);
include_dirs(_RuleGroup = #{include_dirs := IDirs})->
IDirs;
include_dirs(_) ->
?DEFAULT_INCLUDE_DIRS.

-spec ignore(config() | map()) -> [string()].
ignore(Config) when is_list(Config) ->
lists:flatmap(fun ignore/1, Config);
Expand Down

0 comments on commit 9020a48

Please sign in to comment.