From 1e342faee804924a79e5ac9a9120a327809448b3 Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 2 Jun 2011 21:03:09 +0200 Subject: Apply Tidier suggestions --- src/rebar.erl | 16 +++++++--------- src/rebar_appups.erl | 17 ++++++----------- src/rebar_port_compiler.erl | 2 +- src/rebar_reltool.erl | 2 +- src/rebar_upgrade.erl | 5 +++-- 5 files changed, 18 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/rebar.erl b/src/rebar.erl index 36114cf..1d53622 100644 --- a/src/rebar.erl +++ b/src/rebar.erl @@ -324,17 +324,15 @@ is_command_name_sub_word_candidate(Command, Candidate) -> %% Allow for parts of commands to be abbreviated, i.e. create-app %% can be shortened to "create-a", "c-a" or "c-app" (but not %% "create-" since that would be ambiguous). - CommandSubWords = re:split(Command, "-", [{return, list}]), - CandidateSubWords = re:split(Candidate, "-", [{return, list}]), + ReOpts = [{return, list}], + CommandSubWords = re:split(Command, "-", ReOpts), + CandidateSubWords = re:split(Candidate, "-", ReOpts), is_command_name_sub_word_candidate_aux(CommandSubWords, CandidateSubWords). -is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs], [CandSW | CandSWs]) -> - case lists:prefix(CmdSW, CandSW) of - true -> - is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs); - false -> - false - end; +is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs], + [CandSW | CandSWs]) -> + lists:prefix(CmdSW, CandSW) andalso + is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs); is_command_name_sub_word_candidate_aux([], []) -> true; is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) -> diff --git a/src/rebar_appups.erl b/src/rebar_appups.erl index df20e43..871c426 100644 --- a/src/rebar_appups.erl +++ b/src/rebar_appups.erl @@ -63,9 +63,7 @@ filename:join([NewName, "lib"]), "^.*.appup$"), %% Convert the list of appup files into app names - AppUpApps = lists:map(fun(File) -> - file_to_name(File) - end, NewAppUpFiles), + AppUpApps = [file_to_name(File) || File <- NewAppUpFiles], %% Create a list of apps that don't already have appups UpgradeApps = genappup_which_apps(Upgraded, AppUpApps), @@ -115,7 +113,7 @@ upgraded_app(_, _, _) -> app_list_diff(List1, List2) -> List3 = lists:umerge(lists:sort(proplists:get_keys(List1)), lists:sort(proplists:get_keys(List2))), - lists:subtract(List3, proplists:get_keys(List2)). + List3 -- proplists:get_keys(List2). file_to_name(File) -> filename:rootname(filename:basename(File)). @@ -180,13 +178,10 @@ generate_instruction_advanced(Name, _, _) -> get_behavior(List) -> Attributes = proplists:get_value(attributes, List), - Behavior = case proplists:get_value(behavior, Attributes) of - undefined -> - proplists:get_value(behaviour, Attributes); - Else -> - Else - end, - Behavior. + case proplists:get_value(behavior, Attributes) of + undefined -> proplists:get_value(behaviour, Attributes); + Else -> Else + end. is_code_change(List) -> Exports = proplists:get_value(exports, List), diff --git a/src/rebar_port_compiler.erl b/src/rebar_port_compiler.erl index 61dbef9..b9c2ea4 100644 --- a/src/rebar_port_compiler.erl +++ b/src/rebar_port_compiler.erl @@ -362,7 +362,7 @@ os_env() -> Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) || S <- os:getenv()], %% Drop variables without a name (win32) - [{K, V} || {K, V} <- Os, K =/= []]. + [T1 || {K, _V} = T1 <- Os, K =/= []]. default_env() -> [ diff --git a/src/rebar_reltool.erl b/src/rebar_reltool.erl index 5e71814..72bfe49 100644 --- a/src/rebar_reltool.erl +++ b/src/rebar_reltool.erl @@ -302,7 +302,7 @@ execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars, BaseDir, T [{template, F, filename:join(OutDir, filename:basename(F))} | Acc0] end, NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)), - case length(NewInstrs) == length(Rest) of + case length(NewInstrs) =:= length(Rest) of true -> ?WARN("template_wildcard: ~s did not match any files!\n", [Wildcard]); false -> diff --git a/src/rebar_upgrade.erl b/src/rebar_upgrade.erl index 39b2c61..0bf0338 100644 --- a/src/rebar_upgrade.erl +++ b/src/rebar_upgrade.erl @@ -81,7 +81,8 @@ run_checks(OldVerPath, ReltoolFile) -> true = rebar_utils:prop_check(filelib:is_dir(NamePath), "Release directory doesn't exist (~p)~n", [NamePath]), - {NewName, NewVer} = rebar_rel_utils:get_rel_release_info(Name, NamePath), + {NewName, NewVer} = NewNameAndVer = + rebar_rel_utils:get_rel_release_info(Name, NamePath), {OldName, OldVer} = rebar_rel_utils:get_rel_release_info(Name, OldVerPath), true = rebar_utils:prop_check(NewName == OldName, @@ -93,7 +94,7 @@ run_checks(OldVerPath, ReltoolFile) -> true = rebar_utils:prop_check(Ver == NewVer, "Reltool and .rel versions do not match~n", []), - {NewName, NewVer}. + NewNameAndVer. setup(OldVerPath, NewName, NewVer, NameVer) -> NewRelPath = filename:join([".", NewName]), -- cgit v1.1