if
statements can be merged PTC-W004842 if isdt(df[column]):
43 df[column] = df[column].dt.strftime(ISO8601)
44 res = ""
45 if fmt != SupportedFormats.geojson:46 if "geom" in df.columns:
47 # Means to covert a GeoDataFrame to DataFrame
48 df = DataFrame(df.drop("geom", axis=1))
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.