if
statements can be merged PTC-W0048 37 if repeat_val_type == SubPattern:
38 repeat_val = repeat_val.data
39
40 if len(repeat_val) == 1: 41 if _pair_eq(repeat_val[0], (tok, val)):
42 if prev_val[0] != MAXREPEAT and prev_val[1] != MAXREPEAT:
43 prev_val = prev_val[0] + 1, prev_val[1] + 1, prev_val[2]
50 if repeat_val_type == SubPattern:
51 repeat_val = repeat_val.data
52
53 if len(repeat_val) == 1: 54 if _pair_eq(repeat_val[0], (prev_tok, prev_val)):
55 prev_tok = MAX_REPEAT
56 if val[0] != MAXREPEAT and val[1] != MAXREPEAT:
142 elif tok == SUBPATTERN:
143 return _pair_eq(a, b)
144
145 elif length == 3:146 if types_a[2] == SubPattern:
147 subpattern_a = a[2]
148 subpattern_b = b[2]
Nested if
statements can be collapsed into a single if
statement by separating their condition using and
operator.
Merging collapsible if
statements increases the code's readability.
if condition1:
if condition2:
dosomething()
if condition1 and condition2:
dosomething()
DeepSource will not raise this issue when the nested if
statements have comments in between them, as it could be explaining why the nested if
is in place.