summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mustache.erl4
-rw-r--r--src/rebar_app_utils.erl11
-rw-r--r--src/rebar_base_compiler.erl2
-rw-r--r--src/rebar_config.erl7
-rw-r--r--src/rebar_core.erl19
-rw-r--r--src/rebar_deps.erl7
-rw-r--r--src/rebar_dialyzer.erl4
-rw-r--r--src/rebar_erlc_compiler.erl10
-rw-r--r--src/rebar_erlydtl_compiler.erl22
-rw-r--r--src/rebar_eunit.erl9
-rw-r--r--src/rebar_neotoma_compiler.erl22
-rw-r--r--src/rebar_port_compiler.erl5
-rw-r--r--src/rebar_protobuffs_compiler.erl8
-rw-r--r--src/rebar_reltool.erl35
-rw-r--r--src/rebar_templater.erl8
-rw-r--r--src/rebar_utils.erl4
16 files changed, 78 insertions, 99 deletions
diff --git a/src/mustache.erl b/src/mustache.erl
index a713bd8..df81aed 100644
--- a/src/mustache.erl
+++ b/src/mustache.erl
@@ -171,13 +171,13 @@ get(Key, Ctx, Mod) ->
error ->
case erlang:function_exported(Mod, Key, 1) of
true ->
- Val = to_s(apply(Mod, Key, [Ctx])),
+ Val = to_s(Mod:Key(Ctx)),
% io:format("From Mod/1 {~p, ~p}~n", [Key, Val]),
Val;
false ->
case erlang:function_exported(Mod, Key, 0) of
true ->
- Val = to_s(apply(Mod, Key, [])),
+ Val = to_s(Mod:Key()),
% io:format("From Mod/0 {~p, ~p}~n", [Key, Val]),
Val;
false ->
diff --git a/src/rebar_app_utils.erl b/src/rebar_app_utils.erl
index 4d56ab2..9574775 100644
--- a/src/rebar_app_utils.erl
+++ b/src/rebar_app_utils.erl
@@ -63,7 +63,7 @@ is_app_dir(Dir) ->
is_app_src(Filename) ->
%% If removing the extension .app.src yields a shorter name,
%% this is an .app.src file.
- Filename /= filename:rootname(Filename, ".app.src").
+ Filename =/= filename:rootname(Filename, ".app.src").
app_src_to_app(Filename) ->
filename:join("ebin", filename:basename(Filename, ".app.src") ++ ".app").
@@ -101,14 +101,15 @@ app_vsn(AppFile) ->
%% ===================================================================
load_app_file(Filename) ->
- case erlang:get({app_file, Filename}) of
+ AppFile = {app_file, Filename},
+ case erlang:get(AppFile) of
undefined ->
case file:consult(Filename) of
{ok, [{application, AppName, AppData}]} ->
- erlang:put({app_file, Filename}, {AppName, AppData}),
+ erlang:put(AppFile, {AppName, AppData}),
{ok, AppName, AppData};
- {error, Reason} ->
- {error, Reason};
+ {error, _} = Error ->
+ Error;
Other ->
{error, {unexpected_terms, Other}}
end;
diff --git a/src/rebar_base_compiler.erl b/src/rebar_base_compiler.erl
index a83ffe5..aea55df 100644
--- a/src/rebar_base_compiler.erl
+++ b/src/rebar_base_compiler.erl
@@ -66,7 +66,7 @@ run(Config, FirstFiles, SourceDir, SourceExt, TargetDir, TargetExt,
%% Remove first files from found files
RestFiles = [Source || Source <- FoundFiles,
- lists:member(Source, FirstFiles) == false],
+ not lists:member(Source, FirstFiles)],
%% Check opts for flag indicating that compile should check lastmod
CheckLastMod = proplists:get_bool(check_last_mod, Opts),
diff --git a/src/rebar_config.erl b/src/rebar_config.erl
index 8528d5f..ccabed0 100644
--- a/src/rebar_config.erl
+++ b/src/rebar_config.erl
@@ -96,12 +96,7 @@ get_global(Key, Default) ->
end.
is_verbose() ->
- case get_global(verbose, "0") of
- "1" ->
- true;
- _ ->
- false
- end.
+ get_global(verbose, "0") =:= "1".
get_jobs() ->
get_global(jobs, 3).
diff --git a/src/rebar_core.erl b/src/rebar_core.erl
index a89510c..510732e 100644
--- a/src/rebar_core.erl
+++ b/src/rebar_core.erl
@@ -86,20 +86,21 @@ run(RawArgs) ->
process_commands(CommandAtoms).
skip_dir(Dir) ->
- case erlang:get({skip_dir, Dir}) of
+ SkipDir = {skip_dir, Dir},
+ case erlang:get(SkipDir) of
undefined ->
?DEBUG("Adding skip dir: ~s\n", [Dir]),
- erlang:put({skip_dir, Dir}, true);
+ erlang:put(SkipDir, true);
true ->
ok
end.
is_skip_dir(Dir) ->
case erlang:get({skip_dir, Dir}) of
- undefined ->
- false;
- true ->
- true
+ undefined ->
+ false;
+ true ->
+ true
end.
skip_dirs() ->
@@ -465,7 +466,7 @@ restore_code_path(no_change) ->
restore_code_path({old, Path}) ->
%% Verify that all of the paths still exist -- some dynamically add paths
%% can get blown away during clean.
- true = code:set_path(lists:filter(fun filelib:is_file/1, Path)),
+ true = code:set_path([F || F <- Path, filelib:is_file(F)]),
ok.
@@ -495,8 +496,8 @@ run_modules([Module | Rest], Command, Config, File) ->
case Module:Command(Config, File) of
ok ->
run_modules(Rest, Command, Config, File);
- {error, Reason} ->
- {error, Reason}
+ {error, _} = Error ->
+ Error
end.
diff --git a/src/rebar_deps.erl b/src/rebar_deps.erl
index 3e26812..fcc1436 100644
--- a/src/rebar_deps.erl
+++ b/src/rebar_deps.erl
@@ -201,11 +201,8 @@ delete_dep(D) ->
end.
require_source_engine(Source) ->
- case source_engine_avail(Source) of
- true ->
- ok
- end.
-
+ true = source_engine_avail(Source),
+ ok.
is_app_available(App, VsnRegex) ->
case code:lib_dir(App) of
diff --git a/src/rebar_dialyzer.erl b/src/rebar_dialyzer.erl
index d2b89aa..3fe9b7e 100644
--- a/src/rebar_dialyzer.erl
+++ b/src/rebar_dialyzer.erl
@@ -142,8 +142,8 @@ dialyze(Config, File) ->
%% @spec app_dirs(Apps::[atom()]) -> [string()]
-spec app_dirs(Apps::[atom()]) -> [string()].
app_dirs(Apps) ->
- [filename:join(Path, "ebin") ||
- Path <- lists:map(fun(App) -> code:lib_dir(App) end, Apps), erlang:is_list(Path)].
+ [filename:join(Path, "ebin")
+ || Path <- [code:lib_dir(App) || App <- Apps], erlang:is_list(Path)].
%% @doc Render the warnings on the console.
%% @spec output_warnings(Warnings::[warning()]) -> 'ok'
diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl
index e0d4def..50e890c 100644
--- a/src/rebar_erlc_compiler.erl
+++ b/src/rebar_erlc_compiler.erl
@@ -104,11 +104,11 @@ doterl_compile(Config, OutDir, MoreSources) ->
ErlOpts = filter_defines(rebar_config:get(Config, erl_opts, []), []),
?DEBUG("erl_opts ~p~n",[ErlOpts]),
%% Support the src_dirs option allowing multiple directories to
- %% contain erlang source. This might be used, for example, should eunit tests be
- %% separated from the core application source.
+ %% contain erlang source. This might be used, for example, should
+ %% eunit tests be separated from the core application source.
SrcDirs = src_dirs(proplists:append_values(src_dirs, ErlOpts)),
RestErls = [Source || Source <- gather_src(SrcDirs, []) ++ MoreSources,
- lists:member(Source, FirstErls) == false],
+ not lists:member(Source, FirstErls)],
% Split RestErls so that parse_transforms and behaviours are instead added
% to erl_first_files, parse transforms first.
@@ -131,8 +131,8 @@ doterl_compile(Config, OutDir, MoreSources) ->
CurrPath = code:get_path(),
true = code:add_path("ebin"),
rebar_base_compiler:run(Config, NewFirstErls, OtherErls,
- fun(S, C) -> internal_erl_compile(S, C, OutDir,
- ErlOpts)
+ fun(S, C) ->
+ internal_erl_compile(S, C, OutDir, ErlOpts)
end),
true = code:set_path(CurrPath),
ok.
diff --git a/src/rebar_erlydtl_compiler.erl b/src/rebar_erlydtl_compiler.erl
index 32c50a7..b3cbd98 100644
--- a/src/rebar_erlydtl_compiler.erl
+++ b/src/rebar_erlydtl_compiler.erl
@@ -149,31 +149,27 @@ module_name(Target) ->
needs_compile(Source, Target, Config) ->
LM = filelib:last_modified(Target),
- case LM < filelib:last_modified(Source) of
- true -> true;
- false ->
- lists:any(fun(D) -> LM < filelib:last_modified(D) end,
- referenced_dtls(Source, Config))
- end.
+ LM < filelib:last_modified(Source) orelse
+ lists:any(fun(D) -> LM < filelib:last_modified(D) end,
+ referenced_dtls(Source, Config)).
referenced_dtls(Source, Config) ->
Set = referenced_dtls1([Source], Config,
sets:add_element(Source, sets:new())),
- Final = sets:to_list(sets:del_element(Source, Set)),
- Final.
+ sets:to_list(sets:del_element(Source, Set)).
referenced_dtls1(Step, Config, Seen) ->
DtlOpts = erlydtl_opts(Config),
ExtMatch = re:replace(option(source_ext, DtlOpts), "\.", "\\\\\\\\.",
[{return, list}]),
AllRefs = lists:append(
- [ string:tokens(
- os:cmd(["grep -o [^\\\"]*",ExtMatch," ",F]),
- "\n")
- || F <- Step]),
+ [string:tokens(
+ os:cmd(["grep -o [^\\\"]*",ExtMatch," ",F]),
+ "\n")
+ || F <- Step]),
DocRoot = option(doc_root, DtlOpts),
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
- Existing = lists:filter(fun filelib:is_file/1, WithPaths),
+ Existing = [F || F <- WithPaths, filelib:is_file(F)],
New = sets:subtract(sets:from_list(Existing), Seen),
case sets:size(New) of
0 -> Seen;
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index 138b4f5..1341f9d 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -286,9 +286,8 @@ is_eunitized(Mod) ->
has_header(Mod, "include/eunit.hrl").
has_eunit_test_fun(Mod) ->
- length([F || {exports, Funs} <- Mod:module_info(),
- {F, 0} <- Funs,
- F == test]) =/= 0.
+ [F || {exports, Funs} <- Mod:module_info(),
+ {F, 0} <- Funs, F =:= test] =/= [].
has_header(Mod, Header) ->
Mod1 = case code:which(Mod) of
@@ -300,8 +299,8 @@ has_header(Mod, Header) ->
L -> L
end,
{ok, {_, [{abstract_code, {_, AC}}]}} = beam_lib:chunks(Mod1, [abstract_code]),
- length([F || {attribute, 1, file, {F, 1}} <- AC,
- string:str(F, Header) =/= 0]) =/= 0.
+ [F || {attribute, 1, file, {F, 1}} <- AC,
+ string:str(F, Header) =/= 0] =/= [].
align_notcovered_count(Module, Covered, NotCovered, false) ->
{Module, Covered, NotCovered};
diff --git a/src/rebar_neotoma_compiler.erl b/src/rebar_neotoma_compiler.erl
index 586b102..89cd089 100644
--- a/src/rebar_neotoma_compiler.erl
+++ b/src/rebar_neotoma_compiler.erl
@@ -108,31 +108,27 @@ do_compile(Source, _Target, Config) ->
needs_compile(Source, Target, Config) ->
LM = filelib:last_modified(Target),
- case LM < filelib:last_modified(Source) of
- true -> true;
- false ->
- lists:any(fun(D) -> LM < filelib:last_modified(D) end,
- referenced_pegs(Source, Config))
- end.
+ LM < filelib:last_modified(Source) orelse
+ lists:any(fun(D) -> LM < filelib:last_modified(D) end,
+ referenced_pegs(Source, Config)).
referenced_pegs(Source, Config) ->
Set = referenced_pegs1([Source], Config,
sets:add_element(Source, sets:new())),
- Final = sets:to_list(sets:del_element(Source, Set)),
- Final.
+ sets:to_list(sets:del_element(Source, Set)).
referenced_pegs1(Step, Config, Seen) ->
NeoOpts = neotoma_opts(Config),
ExtMatch = re:replace(option(source_ext, NeoOpts), "\.", "\\\\\\\\.",
[{return, list}]),
AllRefs = lists:append(
- [ string:tokens(
- os:cmd(["grep -o [^\\\"]*",ExtMatch," ",F]),
- "\n")
- || F <- Step]),
+ [string:tokens(
+ os:cmd(["grep -o [^\\\"]*",ExtMatch," ",F]),
+ "\n")
+ || F <- Step]),
DocRoot = option(doc_root, NeoOpts),
WithPaths = [ filename:join([DocRoot, F]) || F <- AllRefs ],
- Existing = lists:filter(fun filelib:is_file/1, WithPaths),
+ Existing = [F || F <- WithPaths, filelib:is_file(F)],
New = sets:subtract(sets:from_list(Existing), Seen),
case sets:size(New) of
0 -> Seen;
diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl
index d962b28..732965c 100644
--- a/src/rebar_port_compiler.erl
+++ b/src/rebar_port_compiler.erl
@@ -137,9 +137,8 @@ expand_sources([Spec | Rest], Acc) ->
expand_sources(Rest, Acc2).
expand_objects(Sources) ->
- lists:map(fun(File) ->
- filename:join([filename:dirname(File),filename:basename(File) ++ ".o"])
- end, Sources).
+ [filename:join([filename:dirname(F), filename:basename(F) ++ ".o"])
+ || F <- Sources].
run_precompile_hook(Config, Env) ->
case rebar_config:get(Config, port_pre_script, undefined) of
diff --git a/src/rebar_protobuffs_compiler.erl b/src/rebar_protobuffs_compiler.erl
index 6118562..122440c 100644
--- a/src/rebar_protobuffs_compiler.erl
+++ b/src/rebar_protobuffs_compiler.erl
@@ -74,13 +74,7 @@ clean(_Config, _AppFile) ->
%% ===================================================================
protobuffs_is_present() ->
- case code:which(protobuffs_compile) of
- non_existing ->
- false;
- _ ->
- true
- end.
-
+ code:which(protobuffs_compile) =/= non_existing.
beam_file(Proto) ->
filename:basename(Proto, ".proto") ++ "_pb.beam".
diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl
index d01dbd0..024870e 100644
--- a/src/rebar_reltool.erl
+++ b/src/rebar_reltool.erl
@@ -106,9 +106,9 @@ load_config(ReltoolFile) ->
%% can't run reltool.
%%
sys_tuple(ReltoolConfig) ->
- case lists:keysearch(sys, 1, ReltoolConfig) of
- {value, {sys, Data}} ->
- {sys, Data};
+ case lists:keyfind(sys, 1, ReltoolConfig) of
+ {sys, _} = SysTuple ->
+ SysTuple;
false ->
?ABORT("Failed to find {sys, [...]} tuple in reltool.config.", [])
end.
@@ -120,13 +120,13 @@ sys_tuple(ReltoolConfig) ->
target_dir(ReltoolConfig) ->
case rebar_config:get_global(target_dir, undefined) of
undefined ->
- case lists:keysearch(target_dir, 1, ReltoolConfig) of
- {value, {target_dir, TargetDir}} ->
+ case lists:keyfind(target_dir, 1, ReltoolConfig) of
+ {target_dir, TargetDir} ->
filename:absname(TargetDir);
false ->
{sys, SysInfo} = sys_tuple(ReltoolConfig),
- case lists:keysearch(rel, 1, SysInfo) of
- {value, {rel, Name, _Vsn, _Apps}} ->
+ case lists:keyfind(rel, 1, SysInfo) of
+ {rel, Name, _Vsn, _Apps} ->
filename:absname(Name);
false ->
filename:absname("target")
@@ -144,8 +144,8 @@ target_dir(ReltoolConfig) ->
overlay_vars(ReltoolConfig) ->
case rebar_config:get_global(overlay_vars, undefined) of
undefined ->
- case lists:keysearch(overlay_vars, 1, ReltoolConfig) of
- {value, {overlay_vars, File}} ->
+ case lists:keyfind(overlay_vars, 1, ReltoolConfig) of
+ {overlay_vars, File} ->
File;
false ->
undefined
@@ -156,8 +156,10 @@ overlay_vars(ReltoolConfig) ->
validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
- case lists:keysearch(rel, 1, ReltoolConfig) of
- {value, {rel, _Name, _Vsn, Apps}} ->
+ case lists:keyfind(rel, 1, ReltoolConfig) of
+ false ->
+ ok;
+ {rel, _Name, _Vsn, Apps} ->
%% Identify all the apps that do NOT exist, based on what's available
%% from the reltool server
Missing = lists:sort([App || App <- Apps,
@@ -168,11 +170,9 @@ validate_rel_apps(ReltoolServer, {sys, ReltoolConfig}) ->
_ ->
?ABORT("Apps in {rel, ...} section not found by reltool: ~p\n", [Missing])
end;
- {value, Rel} ->
+ Rel ->
%% Invalid release format!
- ?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel]);
- false ->
- ok
+ ?ABORT("Invalid {rel, ...} section in reltools.config: ~p\n", [Rel])
end.
app_exists(App, Server) when is_atom(App) ->
@@ -330,9 +330,10 @@ execute_overlay([Other | _Rest], _Vars, _BaseDir, _TargetDir) ->
%% Render a binary to a string, using mustache and the specified context
%%
render(Bin, Context) ->
+ ReOpts = [global, {return, list}],
%% Be sure to escape any double-quotes before rendering...
- Str0 = re:replace(Bin, "\\\\", "\\\\\\", [global, {return, list}]),
- Str1 = re:replace(Str0, "\"", "\\\\\"", [global, {return,list}]),
+ Str0 = re:replace(Bin, "\\\\", "\\\\\\", ReOpts),
+ Str1 = re:replace(Str0, "\"", "\\\\\"", ReOpts),
mustache:render(Str1, Context).
diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl
index 56ea1e4..4aa5ed6 100644
--- a/src/rebar_templater.erl
+++ b/src/rebar_templater.erl
@@ -84,8 +84,8 @@ create(_Config, _) ->
%% Load the template definition as is and get the list of variables the
%% template requires.
TemplateTerms = consult(load_file(Type, Template)),
- case lists:keysearch(variables, 1, TemplateTerms) of
- {value, {variables, Vars}} ->
+ case lists:keyfind(variables, 1, TemplateTerms) of
+ {variables, Vars} ->
case parse_vars(Vars, dict:new()) of
{error, Entry} ->
Context0 = undefined,
@@ -270,8 +270,8 @@ write_file(Output, Data, Force) ->
%% Execute each instruction in a template definition file.
%%
execute_template([], _TemplateType, _TemplateName, _Context, _Force, ExistingFiles) ->
- case length(ExistingFiles) of
- 0 ->
+ case ExistingFiles of
+ [] ->
ok;
_ ->
Msg = lists:flatten([io_lib:format("\t* ~p~n", [F]) || F <- lists:reverse(ExistingFiles)]),
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index c9ab3bc..32f08bd 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -205,6 +205,6 @@ emulate_escript_foldl(Fun, Acc, File) ->
{archive, ArchiveBin} ->
zip:foldl(Fun, Acc, {File, ArchiveBin})
end;
- {error, Reason} ->
- {error, Reason}
+ {error, _} = Error ->
+ Error
end.