Apply Tidier suggestions

This commit is contained in:
Tuncer Ayaz 2011-06-02 21:03:09 +02:00
parent 8eb1fc8308
commit 1e342faee8
5 changed files with 18 additions and 24 deletions

View file

@ -324,17 +324,15 @@ is_command_name_sub_word_candidate(Command, Candidate) ->
%% Allow for parts of commands to be abbreviated, i.e. create-app %% 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 %% can be shortened to "create-a", "c-a" or "c-app" (but not
%% "create-" since that would be ambiguous). %% "create-" since that would be ambiguous).
CommandSubWords = re:split(Command, "-", [{return, list}]), ReOpts = [{return, list}],
CandidateSubWords = re:split(Candidate, "-", [{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(CommandSubWords, CandidateSubWords).
is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs], [CandSW | CandSWs]) -> is_command_name_sub_word_candidate_aux([CmdSW | CmdSWs],
case lists:prefix(CmdSW, CandSW) of [CandSW | CandSWs]) ->
true -> lists:prefix(CmdSW, CandSW) andalso
is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs); is_command_name_sub_word_candidate_aux(CmdSWs, CandSWs);
false ->
false
end;
is_command_name_sub_word_candidate_aux([], []) -> is_command_name_sub_word_candidate_aux([], []) ->
true; true;
is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) -> is_command_name_sub_word_candidate_aux(_CmdSWs, _CandSWs) ->

View file

@ -63,9 +63,7 @@
filename:join([NewName, "lib"]), "^.*.appup$"), filename:join([NewName, "lib"]), "^.*.appup$"),
%% Convert the list of appup files into app names %% Convert the list of appup files into app names
AppUpApps = lists:map(fun(File) -> AppUpApps = [file_to_name(File) || File <- NewAppUpFiles],
file_to_name(File)
end, NewAppUpFiles),
%% Create a list of apps that don't already have appups %% Create a list of apps that don't already have appups
UpgradeApps = genappup_which_apps(Upgraded, AppUpApps), UpgradeApps = genappup_which_apps(Upgraded, AppUpApps),
@ -115,7 +113,7 @@ upgraded_app(_, _, _) ->
app_list_diff(List1, List2) -> app_list_diff(List1, List2) ->
List3 = lists:umerge(lists:sort(proplists:get_keys(List1)), List3 = lists:umerge(lists:sort(proplists:get_keys(List1)),
lists:sort(proplists:get_keys(List2))), lists:sort(proplists:get_keys(List2))),
lists:subtract(List3, proplists:get_keys(List2)). List3 -- proplists:get_keys(List2).
file_to_name(File) -> file_to_name(File) ->
filename:rootname(filename:basename(File)). filename:rootname(filename:basename(File)).
@ -180,13 +178,10 @@ generate_instruction_advanced(Name, _, _) ->
get_behavior(List) -> get_behavior(List) ->
Attributes = proplists:get_value(attributes, List), Attributes = proplists:get_value(attributes, List),
Behavior = case proplists:get_value(behavior, Attributes) of case proplists:get_value(behavior, Attributes) of
undefined -> undefined -> proplists:get_value(behaviour, Attributes);
proplists:get_value(behaviour, Attributes); Else -> Else
Else -> end.
Else
end,
Behavior.
is_code_change(List) -> is_code_change(List) ->
Exports = proplists:get_value(exports, List), Exports = proplists:get_value(exports, List),

View file

@ -362,7 +362,7 @@ os_env() ->
Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) || Os = [list_to_tuple(re:split(S, "=", [{return, list}, {parts, 2}])) ||
S <- os:getenv()], S <- os:getenv()],
%% Drop variables without a name (win32) %% Drop variables without a name (win32)
[{K, V} || {K, V} <- Os, K =/= []]. [T1 || {K, _V} = T1 <- Os, K =/= []].
default_env() -> default_env() ->
[ [

View file

@ -302,7 +302,7 @@ execute_overlay([{template_wildcard, Wildcard, OutDir} | Rest], Vars, BaseDir, T
[{template, F, filename:join(OutDir, filename:basename(F))} | Acc0] [{template, F, filename:join(OutDir, filename:basename(F))} | Acc0]
end, end,
NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)), NewInstrs = lists:foldl(Ifun, Rest, filelib:wildcard(Wildcard, BaseDir)),
case length(NewInstrs) == length(Rest) of case length(NewInstrs) =:= length(Rest) of
true -> true ->
?WARN("template_wildcard: ~s did not match any files!\n", [Wildcard]); ?WARN("template_wildcard: ~s did not match any files!\n", [Wildcard]);
false -> false ->

View file

@ -81,7 +81,8 @@ run_checks(OldVerPath, ReltoolFile) ->
true = rebar_utils:prop_check(filelib:is_dir(NamePath), true = rebar_utils:prop_check(filelib:is_dir(NamePath),
"Release directory doesn't exist (~p)~n", [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), {OldName, OldVer} = rebar_rel_utils:get_rel_release_info(Name, OldVerPath),
true = rebar_utils:prop_check(NewName == OldName, true = rebar_utils:prop_check(NewName == OldName,
@ -93,7 +94,7 @@ run_checks(OldVerPath, ReltoolFile) ->
true = rebar_utils:prop_check(Ver == NewVer, true = rebar_utils:prop_check(Ver == NewVer,
"Reltool and .rel versions do not match~n", []), "Reltool and .rel versions do not match~n", []),
{NewName, NewVer}. NewNameAndVer.
setup(OldVerPath, NewName, NewVer, NameVer) -> setup(OldVerPath, NewName, NewVer, NameVer) ->
NewRelPath = filename:join([".", NewName]), NewRelPath = filename:join([".", NewName]),