Skip to content

Commit 9880cdf

Browse files
joke1196sonartech
authored andcommitted
SONARPY-3238 Rule S7613: Fix FP when return statement is outside of lambda (#430)
GitOrigin-RevId: a0fa3ec2b6a624fd5363b4b0347171aed860b7b0
1 parent d09bc4f commit 9880cdf

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

python-checks/src/main/java/org/sonar/python/checks/AwsLambdaReturnValueAreSerializableCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private void checkReturnStatement(SubscriptionContext ctx) {
120120
}
121121

122122
FunctionDef function = (FunctionDef) parentFunction;
123-
if (!AwsLambdaChecksUtils.isLambdaHandler(ctx, function)) {
123+
if (!AwsLambdaChecksUtils.isOnlyLambdaHandler(ctx, function)) {
124124
return;
125125
}
126126

python-checks/src/test/resources/checks/awslambdaReturnValueAreSerializable.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ def complex_compliant_lambda_handler(event, context):
161161
},
162162
}
163163

164+
@dataclasses.dataclass
165+
class OrderOutput:
166+
id: int
167+
168+
def process():
169+
return OrderOutput(1) # Compliant the value is not returned
170+
171+
def no_return_lambda_handler(event, ctx):
172+
order_output = process()
173+
return {1,2} # Noncompliant
164174

165175
# Non-Lambda functions (should not trigger the rule)
166176
def regular_function_set():

0 commit comments

Comments
 (0)