if
statements can be merged PTC-W0048 44 (vtec.office, vtec.etn, vtec.significance, vtec.phenomena),
45 )
46 row = txn.fetchone()
47 if row["max"] is not None: 48 if (prod.valid - row["max"]).total_seconds() > (21 * 86400):
49 prod.warnings.append(
50 "Possible Duplicated ETN\n"
590 prod.valid,
591 ),
592 )
593 if txn.rowcount != len(segment.ugcs):594 if not prod.is_correction():
595 prod.warnings.append(_debug_warning(prod, txn, vtec, segment, ets))
596
77 "Segment has duplicated VTEC for a "
78 "single phenomena / significance"
79 )
80 if segment.giswkt and not segment.vtec: 81 if self.afos is not None and self.afos[:3] not in ["MWS"]:
82 self.warnings.append(
83 "Product segment has LAT...LON, "
85 # Get the weather phenomena
86 phenomena = []
87 elem = airmet.find("clouds", NS)
88 if elem is not None: 89 if elem.text == "true":
90 phenomena.append("clouds")
91 for elem in airmet.findall(".//weatherPhenomenon", NS):
121 newtext = newtext.replace(f" {token}", "")
122 if newtext != text:
123 text = newtext
124 if str(inst).find("day is out of range for month") > -1:125 if valid.day < 10:
126 valid = valid.replace(day=1) - timedelta(days=1)
127 attempt += 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.