if
statements can be merged PTC-W0048149 for ee in pygame.event.get():
150 if ee.type == pygame.QUIT:
151 pygame.quit()
152 elif ee.type == pygame.KEYDOWN:153 if ee.key == pygame.K_SPACE:
154 pause = False
155 if __name__ == '__main__':
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.