Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made rebar_utils:filtermap/2 to call directly lists:filtermap/2 #2907

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/rebar/src/rebar_compiler_erl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ dependencies(Source, _SourceDir, Dirs, DepOpts) ->
%% TODO: check for core transforms?
{_MissIncl, _MissInclLib} =/= {[],[]} andalso
?DIAGNOSTIC("Missing: ~p", [{_MissIncl, _MissInclLib}]),
lists:filtermap(
rebar_utils:filtermap(
fun (Mod) -> rebar_compiler_epp:resolve_source(Mod, Dirs) end,
OptPTrans ++ PTrans ++ Behaviours) ++ AbsIncls
catch
Expand Down
2 changes: 1 addition & 1 deletion apps/rebar/src/rebar_plugins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ install(State, AppInfo) ->
filter_existing_plugins(Plugins, State) ->
PluginNames = lists:zip(Plugins, rebar_state:deps_names(Plugins)),
AllPlugins = rebar_state:all_plugin_deps(State),
lists:filtermap(fun({Plugin, PluginName}) ->
rebar_utils:filtermap(fun({Plugin, PluginName}) ->
case rebar_app_utils:find(PluginName, AllPlugins) of
{ok, _} ->
false;
Expand Down
15 changes: 3 additions & 12 deletions apps/rebar/src/rebar_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,13 @@ sort_deps(Deps) ->
droplast(L) ->
lists:reverse(tl(lists:reverse(L))).

%% @doc filtermap takes in a function that is either or both
%% a predicate and a map, and returns the matching and valid elements.
%% @doc wrapper around lists:filtermap/2
-spec filtermap(F, [In]) -> [Out] when
F :: fun((In) -> boolean() | {true, Out}),
In :: term(),
Out :: term().
filtermap(F, [Hd|Tail]) ->
case F(Hd) of
true ->
[Hd|filtermap(F, Tail)];
{true,Val} ->
[Val|filtermap(F, Tail)];
false ->
filtermap(F, Tail)
end;
filtermap(F, []) when is_function(F, 1) -> [].
filtermap(F, In) ->
lists:filtermap(F, In).

is_arch(ArchRegex) ->
case re:run(get_arch(), ArchRegex, [{capture, none}, unicode]) of
Expand Down
Loading