Skip to content

Commit

Permalink
Made rebar_utils:filtermap/2 to call directly lists:filtermap/2
Browse files Browse the repository at this point in the history
* local implementation introduced by a4d4c6c
* introduced to work around releases prior R16 not having `lists:filtermap/2` [1]
* CI/CD nows runs wtih R25 to R27.

[1] https://www.erlang.org/doc/apps/stdlib/lists.html#filtermap/2

Signed-off-by: Ariel Otilibili <[email protected]>
  • Loading branch information
Ariel Otilibili committed Jul 29, 2024
1 parent fbb8263 commit 24aa18b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
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

0 comments on commit 24aa18b

Please sign in to comment.