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 b7273a5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 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,17 @@ 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 = #{ruleset := "erl_files"}) when is_map(RuleGroup) ->
maps:get(include_dirs, RuleGroup, ?DEFAULT_INCLUDE_DIRS);
include_dirs(RuleGroup = #{filter := "*.erl"}) when is_map(RuleGroup) ->
maps:get(include_dirs, RuleGroup, ?DEFAULT_INCLUDE_DIRS);
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 b7273a5

Please sign in to comment.