File .deepsource.toml
not found in the default branch of the repository root. Please refer to the docs.
if
statements can be merged PTC-W0048 588 user = self.request.user
589 else:
590 user = None
591 if user: 592 if instance.status == PLAN_STATUS.ARCHIVED:
593 action.send(
594 user,
10
11 def validate(self, attrs):
12 token = self.context.get("token", None)
13 if not token:14 if attrs["company_name"] is None:
15 raise serializers.ValidationError(
16 "Company name is required for registration"
907 day = convert_to_date(day)
908 if day < period:
909 continue
910 if less_than: 911 if day >= less_than:
912 break
913 if usage > last_value:
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.