Skip to content

Commit

Permalink
Replace 'or'/'and' with 'orelse'/'andalso' respectively
Browse files Browse the repository at this point in the history
  • Loading branch information
richcarl committed Nov 26, 2024
1 parent e45f20e commit aa1be07
Show file tree
Hide file tree
Showing 97 changed files with 286 additions and 285 deletions.
4 changes: 2 additions & 2 deletions erts/preloaded/src/prim_zip.erl
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ splitter(Left, Right, 0) ->
{Left, Right};
splitter(<<>>, Right, RelPos) ->
split_iolist(Right, RelPos);
splitter(Left, [A | Right], RelPos) when is_list(A) or is_binary(A) ->
splitter(Left, [A | Right], RelPos) when is_list(A) orelse is_binary(A) ->
Sz = erlang:iolist_size(A),
case Sz > RelPos of
true ->
Expand All @@ -629,7 +629,7 @@ skip_iolist(L, Pos) when is_list(L) ->

skipper(Right, 0) ->
Right;
skipper([A | Right], RelPos) when is_list(A) or is_binary(A) ->
skipper([A | Right], RelPos) when is_list(A) orelse is_binary(A) ->
Sz = erlang:iolist_size(A),
case Sz > RelPos of
true ->
Expand Down
12 changes: 6 additions & 6 deletions lib/common_test/src/ct_framework.erl
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ add_defaults1(Mod,Func, GroupPath, SuiteInfo) ->
SuiteReqs =
[SDDef || SDDef <- SuiteInfo,
((require == element(1,SDDef))
or (default_config == element(1,SDDef)))],
orelse (default_config == element(1,SDDef)))],
case check_for_clashes(TestCaseInfo, GroupPathInfo,
SuiteReqs) of
[] ->
Expand Down Expand Up @@ -461,11 +461,11 @@ remove_info_in_prev(Terms, [[] | Rest]) ->
[[] | remove_info_in_prev(Terms, Rest)];
remove_info_in_prev(Terms, [Info | Rest]) ->
UniqueInInfo = [U || U <- Info,
((timetrap == element(1,U)) and
(not lists:keymember(timetrap,1,Terms))) or
((require == element(1,U)) and
(not lists:member(U,Terms))) or
((default_config == element(1,U)) and
((timetrap == element(1,U)) andalso
(not lists:keymember(timetrap,1,Terms))) orelse
((require == element(1,U)) andalso
(not lists:member(U,Terms))) orelse
((default_config == element(1,U)) andalso
(not keysmember([default_config,1,
element(2,U),2], Terms)))],
OtherTermsInInfo = [T || T <- Info,
Expand Down
2 changes: 1 addition & 1 deletion lib/common_test/src/ct_groups.erl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ find_groups1(Mod, GrNames, TCs, GroupDefs) ->
Path ->
{Path,true}
end,
TCs1 = if (is_atom(TCs) and (TCs /= all)) or is_tuple(TCs) ->
TCs1 = if (is_atom(TCs) andalso (TCs /= all)) orelse is_tuple(TCs) ->
[TCs];
true ->
TCs
Expand Down
6 changes: 3 additions & 3 deletions lib/common_test/src/ct_logs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ logger_loop(State) ->
end,
if Importance >= (100-VLvl) ->
CtLogFd = State#logger_state.ct_log_fd,
DoEscChars = State#logger_state.tc_esc_chars and EscChars,
DoEscChars = State#logger_state.tc_esc_chars andalso EscChars,
case get_groupleader(Pid, GL, State) of
{tc_log,TCGL,TCGLs} ->
case erlang:is_process_alive(TCGL) of
Expand Down Expand Up @@ -1494,7 +1494,7 @@ make_one_index_entry1(SuiteName, Link, Label, Success, Fail, UserSkip, AutoSkip,
integer_to_list(NotBuilt),"</a></td>\n"]
end,
FailStr =
if (Fail > 0) or (NotBuilt > 0) or
if (Fail > 0) orelse (NotBuilt > 0) orelse
((Success+Fail+UserSkip+AutoSkip) == 0) ->
["<font color=\"red\">",
integer_to_list(Fail),"</font>"];
Expand Down Expand Up @@ -2273,7 +2273,7 @@ runentry(Dir, undefined, _) ->
runentry(Dir, Totals={Node,Label,Logs,
{TotSucc,TotFail,UserSkip,AutoSkip,NotBuilt}}, Index) ->
TotFailStr =
if (TotFail > 0) or (NotBuilt > 0) or
if (TotFail > 0) orelse (NotBuilt > 0) orelse
((TotSucc+TotFail+UserSkip+AutoSkip) == 0) ->
["<font color=\"red\">",
integer_to_list(TotFail),"</font>"];
Expand Down
38 changes: 19 additions & 19 deletions lib/common_test/src/ct_run.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1272,23 +1272,23 @@ run_dir(Opts = #opts{logdir = LogDir,
true -> D end || D <- Dirs],
reformat_result(catch do_run(tests(Dirs1), [], Opts1, StartOpts));

{Dir=[Hd|_],undefined,[]} when is_list(Dir) and is_integer(Hd) ->
{Dir=[Hd|_],undefined,[]} when is_list(Dir) andalso is_integer(Hd) ->
reformat_result(catch do_run(tests(Dir), [], Opts1, StartOpts));

{Dir,undefined,[]} when is_atom(Dir) and (Dir /= undefined) ->
{Dir,undefined,[]} when is_atom(Dir) andalso (Dir /= undefined) ->
reformat_result(catch do_run(tests(atom_to_list(Dir)),
[], Opts1, StartOpts));

{undefined,Suites=[Hd|_],[]} when not is_integer(Hd) ->
Suites1 = [suite_to_test(S) || S <- Suites],
reformat_result(catch do_run(tests(Suites1), [], Opts1, StartOpts));

{undefined,Suite,[]} when is_atom(Suite) and
{undefined,Suite,[]} when is_atom(Suite) andalso
(Suite /= undefined) ->
{Dir,Mod} = suite_to_test(Suite),
reformat_result(catch do_run(tests(Dir, Mod), [], Opts1, StartOpts));

{undefined,Suite,GsAndCs} when is_atom(Suite) and
{undefined,Suite,GsAndCs} when is_atom(Suite) andalso
(Suite /= undefined) ->
{Dir,Mod} = suite_to_test(Suite),
reformat_result(catch do_run(tests(Dir, Mod, GsAndCs),
Expand All @@ -1298,8 +1298,8 @@ run_dir(Opts = #opts{logdir = LogDir,
exit({error,multiple_suites_and_cases});

{undefined,Suite=[Hd|Tl],GsAndCs} when is_integer(Hd) ;
(is_list(Hd) and (Tl == [])) ;
(is_atom(Hd) and (Tl == [])) ->
(is_list(Hd) andalso (Tl == [])) ;
(is_atom(Hd) andalso (Tl == [])) ->
{Dir,Mod} = suite_to_test(Suite),
reformat_result(catch do_run(tests(Dir, Mod, GsAndCs),
[], Opts1, StartOpts));
Expand All @@ -1311,18 +1311,18 @@ run_dir(Opts = #opts{logdir = LogDir,
exit({error,incorrect_start_options});

{Dir,Suite,GsAndCs} when is_integer(hd(Dir)) ;
(is_atom(Dir) and (Dir /= undefined)) ;
((length(Dir) == 1) and is_atom(hd(Dir))) ;
((length(Dir) == 1) and is_list(hd(Dir))) ->
(is_atom(Dir) andalso (Dir /= undefined)) ;
((length(Dir) == 1) andalso is_atom(hd(Dir))) ;
((length(Dir) == 1) andalso is_list(hd(Dir))) ->
Dir1 = if is_atom(Dir) -> atom_to_list(Dir);
true -> Dir end,
if Suite == undefined ->
exit({error,incorrect_start_options});

is_integer(hd(Suite)) ;
(is_atom(Suite) and (Suite /= undefined)) ;
((length(Suite) == 1) and is_atom(hd(Suite))) ;
((length(Suite) == 1) and is_list(hd(Suite))) ->
(is_atom(Suite) andalso (Suite /= undefined)) ;
((length(Suite) == 1) andalso is_atom(hd(Suite))) ;
((length(Suite) == 1) andalso is_list(hd(Suite))) ->
{Dir2,Mod} = suite_to_test(Dir1, Suite),
case GsAndCs of
[] ->
Expand Down Expand Up @@ -1608,20 +1608,20 @@ suite_to_test(Dir, Suite) when is_list(Suite) ->
{DirName,list_to_atom(filename:rootname(File))}
end.

groups_and_cases(Gs, Cs) when ((Gs == undefined) or (Gs == [])) and
((Cs == undefined) or (Cs == [])) ->
groups_and_cases(Gs, Cs) when ((Gs == undefined) orelse (Gs == [])) andalso
((Cs == undefined) orelse (Cs == [])) ->
[];
groups_and_cases(Gs, Cs) when Gs == undefined ; Gs == [] ->
if (Cs == all) or (Cs == [all]) or (Cs == ["all"]) -> all;
if (Cs == all) orelse (Cs == [all]) orelse (Cs == ["all"]) -> all;
true -> [ensure_atom(C) || C <- listify(Cs)]
end;
groups_and_cases(GOrGs, Cs) when (is_atom(GOrGs) orelse
(is_list(GOrGs) andalso
(is_atom(hd(GOrGs)) orelse
(is_list(hd(GOrGs)) andalso
is_atom(hd(hd(GOrGs))))))) ->
if (Cs == undefined) or (Cs == []) or
(Cs == all) or (Cs == [all]) or (Cs == ["all"]) ->
if (Cs == undefined) orelse (Cs == []) orelse
(Cs == all) orelse (Cs == [all]) orelse (Cs == ["all"]) ->
[{GOrGs,all}];
true ->
[{GOrGs,[ensure_atom(C) || C <- listify(Cs)]}]
Expand All @@ -1630,7 +1630,7 @@ groups_and_cases(Gs, Cs) when is_integer(hd(hd(Gs))) ->
%% if list of strings, this comes from 'ct_run -group G1 G2 ...' and
%% we need to parse the strings
Gs1 =
if (Gs == [all]) or (Gs == ["all"]) ->
if (Gs == [all]) orelse (Gs == ["all"]) ->
all;
true ->
lists:map(fun(G) ->
Expand Down Expand Up @@ -2358,7 +2358,7 @@ start_cover(Opts=#opts{coverspec=CovData,cover_stop=CovStop},LogDir) ->
[TsCoverInfo]),

%% start cover on specified nodes
if (CovNodes /= []) and (CovNodes /= undefined) ->
if (CovNodes /= []) andalso (CovNodes /= undefined) ->
ct_logs:log("COVER INFO",
"Nodes included in cover "
"session: ~tw",
Expand Down
2 changes: 1 addition & 1 deletion lib/common_test/src/ct_slave.erl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ do_start(Host, Node, Options) ->
{ok, ENode}->
ok;
{error, Timeout, ENode}
when ((Timeout==init_timeout) or (Timeout==startup_timeout)) and
when ((Timeout==init_timeout) orelse (Timeout==startup_timeout)) andalso
Options#options.kill_if_fail->
do_stop(ENode);
_-> ok
Expand Down
2 changes: 1 addition & 1 deletion lib/common_test/src/ct_telnet.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ teln_expect(Name,Pid,Data,Pattern0,Prx,Opts) ->
end.

convert_pattern(Pattern0,Seq)
when Pattern0==[] orelse (is_list(Pattern0) and not is_integer(hd(Pattern0))) ->
when Pattern0==[] orelse (is_list(Pattern0) andalso not is_integer(hd(Pattern0))) ->
Pattern =
case Seq of
true -> Pattern0;
Expand Down
18 changes: 9 additions & 9 deletions lib/common_test/src/ct_testspec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,10 @@ replace_names(Terms) ->
throw({illegal_name_in_testspec,Name});
true ->
[First|_] = atom_to_list(Name),
if ((First == $?) or (First == $$)
or (First == $_)
or ((First >= $A)
and (First =< $Z))) ->
if ((First == $?) orelse (First == $$)
orelse (First == $_)
orelse ((First >= $A)
andalso (First =< $Z))) ->
[Def];
true ->
throw({illegal_name_in_testspec,
Expand Down Expand Up @@ -1297,14 +1297,14 @@ insert_groups(Node,Dir,Suite,Group,Cases,Tests,MergeTests)
when is_atom(Group); is_tuple(Group) ->
insert_groups(Node,Dir,Suite,[Group],Cases,Tests,MergeTests);
insert_groups(Node,Dir,Suite,Groups,Cases,Tests,false) when
((Cases == all) or is_list(Cases)) and is_list(Groups) ->
((Cases == all) orelse is_list(Cases)) andalso is_list(Groups) ->
Groups1 = [if is_list(Gr) -> % preserve group path
{[Gr],Cases};
true ->
{Gr,Cases} end || Gr <- Groups],
append({{Node,Dir},[{Suite,Groups1}]},Tests);
insert_groups(Node,Dir,Suite,Groups,Cases,Tests,true) when
((Cases == all) or is_list(Cases)) and is_list(Groups) ->
((Cases == all) orelse is_list(Cases)) andalso is_list(Groups) ->
Groups1 = [if is_list(Gr) -> % preserve group path
{[Gr],Cases};
true ->
Expand Down Expand Up @@ -1416,11 +1416,11 @@ skip_groups(Node,Dir,Suite,Groups,Case,Cmt,Tests,MergeTests)
when is_atom(Case),Case =/= all ->
skip_groups(Node,Dir,Suite,Groups,[Case],Cmt,Tests,MergeTests);
skip_groups(Node,Dir,Suite,Groups,Cases,Cmt,Tests,false) when
((Cases == all) or is_list(Cases)) and is_list(Groups) ->
((Cases == all) orelse is_list(Cases)) andalso is_list(Groups) ->
Suites1 = skip_groups1(Suite,[{Gr,Cases} || Gr <- Groups],Cmt,[]),
append({{Node,Dir},Suites1},Tests);
skip_groups(Node,Dir,Suite,Groups,Cases,Cmt,Tests,true) when
((Cases == all) or is_list(Cases)) and is_list(Groups) ->
((Cases == all) orelse is_list(Cases)) andalso is_list(Groups) ->
{Tests1,Done} =
lists:foldr(fun({{N,D},Suites0},{Merged,_}) when N == Node,
D == Dir ->
Expand Down Expand Up @@ -1577,7 +1577,7 @@ is_node([master|_],_Nodes) ->
is_node(What={N,H},Nodes) when is_atom(N), is_atom(H) ->
is_node([What],Nodes);
is_node([What|_],Nodes) ->
case lists:keymember(What,1,Nodes) or
case lists:keymember(What,1,Nodes) orelse
lists:keymember(What,2,Nodes) of
true ->
true;
Expand Down
10 changes: 5 additions & 5 deletions lib/common_test/src/test_server_ctrl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2329,15 +2329,15 @@ run_test_cases(TestSpec, Config, TimetrapData) ->

run_test_cases_loop([{SkipTag,CaseData={Type,_Ref,_Case,_Comment}}|Cases],
Config, TimetrapData, Mode, Status) when
((SkipTag==auto_skip_case) or (SkipTag==skip_case)) and
((Type==conf) or (Type==make)) ->
((SkipTag==auto_skip_case) orelse (SkipTag==skip_case)) andalso
((Type==conf) orelse (Type==make)) ->
run_test_cases_loop([{SkipTag,CaseData,Mode}|Cases],
Config, TimetrapData, Mode, Status);

run_test_cases_loop([{SkipTag,{Type,Ref,Case,Comment},SkipMode}|Cases],
Config, TimetrapData, Mode, Status) when
((SkipTag==auto_skip_case) or (SkipTag==skip_case)) and
((Type==conf) or (Type==make)) ->
((SkipTag==auto_skip_case) orelse (SkipTag==skip_case)) andalso
((Type==conf) orelse (Type==make)) ->
ok = file:set_cwd(filename:dirname(get(test_server_dir))),
CurrIOHandler = get(test_server_common_io_handler),
ParentMode = tl(Mode),
Expand Down Expand Up @@ -2802,7 +2802,7 @@ run_test_cases_loop([{conf,Ref,Props,{Mod,Func}}|_Cases]=Cs0,
stop_minor_log_file(),
run_test_cases_loop(Cases2, Config1, TimetrapData, Mode, Status3);

{_,{Skip,Reason},_} when StartConf and ((Skip==skip) or (Skip==skipped)) ->
{_,{Skip,Reason},_} when StartConf andalso ((Skip==skip) orelse (Skip==skipped)) ->
ReportAbortRepeat(skipped),
print(minor, "~n*** ~tw skipped.~n"
" Skipping all cases.", [Func]),
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/src/beam_dict.erl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ line([{location,Name,Line}|_], #asm{lines=Lines,num_lines=N,
when is_atom(Instr) ->
{FnameIndex,Dict1} = fname(Name, Dict0),
Key = {FnameIndex,Line},
ExecLine = ExecLine0 or (Instr =:= executable_line),
ExecLine = ExecLine0 orelse (Instr =:= executable_line),
case Lines of
#{Key := Index} ->
{Index,Dict1#asm{num_lines=N+1,exec_line=ExecLine}};
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/src/beam_ssa_opt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ unfold_literals([], _, _, Blocks) ->
Blocks.

unfold_update_succ([S|Ss], Safe, SafeMap0) ->
F = fun(Prev) -> Prev and Safe end,
F = fun(Prev) -> Prev andalso Safe end,
SafeMap = maps:update_with(S, F, Safe, SafeMap0),
unfold_update_succ(Ss, Safe, SafeMap);
unfold_update_succ([], _, SafeMap) ->
Expand Down
8 changes: 4 additions & 4 deletions lib/compiler/src/beam_types.erl
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ glb(#t_atom{elements=any}, #t_atom{elements=[_|_]}=T) ->
T;
glb(#t_bitstring{size_unit=U1,appendable=A1},
#t_bitstring{size_unit=U2,appendable=A2}) ->
#t_bitstring{size_unit=U1 * U2 div gcd(U1, U2),appendable=A1 or A2};
#t_bitstring{size_unit=U1 * U2 div gcd(U1, U2),appendable=A1 orelse A2};
glb(#t_bitstring{size_unit=UnitA,appendable=Appendable}=T,
#t_bs_matchable{tail_unit=UnitB}) ->
Unit = UnitA * UnitB div gcd(UnitA, UnitB),
Expand Down Expand Up @@ -971,7 +971,7 @@ glb_tuples(#t_tuple{size=Sz1,exact=Ex1}, #t_tuple{size=Sz2,exact=Ex2})
glb_tuples(#t_tuple{size=Sz1,exact=Ex1,elements=Es1},
#t_tuple{size=Sz2,exact=Ex2,elements=Es2}) ->
Size = max(Sz1, Sz2),
Exact = Ex1 or Ex2,
Exact = Ex1 orelse Ex2,
case glb_elements(Es1, Es2) of
none ->
none;
Expand Down Expand Up @@ -1036,7 +1036,7 @@ lub(#t_atom{elements=any}=T, #t_atom{elements=[_|_]}) -> T;
lub(#t_atom{elements=[_|_]}, #t_atom{elements=any}=T) -> T;
lub(#t_bitstring{size_unit=U1,appendable=A1},
#t_bitstring{size_unit=U2,appendable=A2}) ->
#t_bitstring{size_unit=gcd(U1, U2),appendable=A1 and A2};
#t_bitstring{size_unit=gcd(U1, U2),appendable=A1 andalso A2};
lub(#t_bitstring{size_unit=U1}, #t_bs_context{tail_unit=U2}) ->
#t_bs_matchable{tail_unit=gcd(U1, U2)};
lub(#t_bitstring{size_unit=UnitA}, #t_bs_matchable{tail_unit=UnitB}) ->
Expand Down Expand Up @@ -1106,7 +1106,7 @@ lub(#t_map{super_key=SKeyA,super_value=SValueA},
#t_map{super_key=SKey,super_value=SValue};
lub(#t_tuple{size=Sz,exact=ExactA,elements=EsA},
#t_tuple{size=Sz,exact=ExactB,elements=EsB}) ->
Exact = ExactA and ExactB,
Exact = ExactA andalso ExactB,
Es = lub_tuple_elements(Sz, EsA, EsB),
#t_tuple{size=Sz,exact=Exact,elements=Es};
lub(#t_tuple{size=SzA,elements=EsA}, #t_tuple{size=SzB,elements=EsB}) ->
Expand Down
8 changes: 4 additions & 4 deletions lib/compiler/src/cerl_inline.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ i_call(E, Ctxt, Ren, Env, S) ->
%% Check if the name of the called function is static. If so,
%% discard the size counts performed above, since the values will
%% not cause any runtime cost.
Static = is_c_atom(M) and is_c_atom(F),
Static = is_c_atom(M) andalso is_c_atom(F),
S3 = case Static of
true ->
revert_size(S, S2);
Expand Down Expand Up @@ -2274,7 +2274,7 @@ equivalent(E1, E2, Env) ->
end.

equivalent_lists([E1 | Es1], [E2 | Es2], Env) ->
equivalent(E1, E2, Env) and equivalent_lists(Es1, Es2, Env);
equivalent(E1, E2, Env) andalso equivalent_lists(Es1, Es2, Env);
equivalent_lists([], [], _) ->
true;
equivalent_lists(_, _, _) ->
Expand All @@ -2287,7 +2287,7 @@ reduce_bif_call(M, F, As, Env) ->
reduce_bif_call_1(M, F, length(As), As, Env).

reduce_bif_call_1(erlang, element, 2, [X, Y], _Env) ->
case is_c_int(X) and is_c_tuple(Y) of
case is_c_int(X) andalso is_c_tuple(Y) of
true ->
%% We are free to change the relative evaluation order of
%% the elements, so lifting out a particular element is OK.
Expand Down Expand Up @@ -2330,7 +2330,7 @@ reduce_bif_call_1(erlang, list_to_tuple, 1, [X], _Env) ->
false
end;
reduce_bif_call_1(erlang, setelement, 3, [X, Y, Z], Env) ->
case is_c_int(X) and is_c_tuple(Y) of
case is_c_int(X) andalso is_c_tuple(Y) of
true ->
%% Here, unless `Z' is a simple expression, we must bind it
%% to a new variable, because in that case, `Z' must be
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/src/sys_pre_attributes.erl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ report_verbose(Format, Args, S) ->
end.

is_warning(S) ->
lists:member(report_warnings, S#state.options) or is_verbose(S).
lists:member(report_warnings, S#state.options) orelse is_verbose(S).

is_verbose(S) ->
lists:member(verbose, S#state.options).
Loading

0 comments on commit aa1be07

Please sign in to comment.