Skip to content

Commit

Permalink
[#40] Refactor discussed in #40
Browse files Browse the repository at this point in the history
  • Loading branch information
Brujo Benavides committed Mar 18, 2016
1 parent bbcd38f commit d65c44d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/elvis_core.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ rock_this(Path, Config) ->
NewConfig = elvis_config:normalize(Config),
Dirname = filename:dirname(Path),
Filename = filename:basename(Path),
File = case elvis_file:find_files([Dirname], Filename, local) of
File = case elvis_file:find_files([Dirname], Filename) of
[] -> throw({enoent, Path});
[File0] -> File0
end,
Expand Down
11 changes: 1 addition & 10 deletions src/elvis_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
load_file_data/2,

find_files/2,
find_files/3,
filter_files/4
]).

Expand Down Expand Up @@ -67,16 +66,8 @@ load_file_data(Config, File0 = #{path := _Path}) ->
%% that match the pattern Name.
-spec find_files([string()], string()) -> [file()].
find_files(Dirs, Pattern) ->
find_files(Dirs, Pattern, recursive).

-spec find_files([string()], string(), recursive | local) -> [file()].
find_files(Dirs, Pattern, Option) ->
MiddlePath = case Option of
recursive -> "/**/";
local -> "/"
end,
Fun = fun(Dir) ->
filelib:wildcard(Dir ++ MiddlePath ++ Pattern)
filelib:wildcard(filename:join(Dir, Pattern))
end,
[#{path => Path} || Path <- lists:flatmap(Fun, Dirs)].

Expand Down

0 comments on commit d65c44d

Please sign in to comment.