Skip to content

Commit e5433af

Browse files
joke1196sonartech
authored andcommitted
SONARPY-3917 Updated message of S2712 (#963)
GitOrigin-RevId: c5a9eda1075a3fb344321ee046f02509bc02048d
1 parent 6071312 commit e5433af

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void initialize(Context context) {
3737
func.body().accept(returnAndYieldVisitor);
3838

3939
if (returnAndYieldVisitor.hasYield && returnAndYieldVisitor.hasReturn) {
40-
ctx.addIssue(func.name(), "Use only \"return\" or only \"yield\", not both.");
40+
ctx.addIssue(func.name(), "Only yield or return values from this function, not both.");
4141
}
4242
});
4343
}

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
def fun1(n): # Noncompliant {{Use only "return" or only "yield", not both.}}
1+
def fun1(n): # Noncompliant {{Only yield or return values from this function, not both.}}
32
# ^^^^
43
num = 0
54
while num < n:
@@ -22,7 +21,8 @@ def fun3(n):
2221
yield num
2322
num += 1
2423

25-
def fun5(n): # Noncompliant
24+
25+
def fun5(n): # Noncompliant
2626
num = 0
2727
if n == 0:
2828
return
@@ -31,18 +31,23 @@ def fun5(n): # Noncompliant
3131
num += 1
3232
return num
3333

34+
3435
def fun4(n):
3536
num = 0
3637
while num < n:
3738
num += 1
3839
return num
3940

41+
4042
def fun6():
4143
def fun7():
4244
yield 1
45+
4346
return 1
4447

48+
4549
def fun8():
4650
def fun9():
4751
return 1
52+
4853
yield 1

0 commit comments

Comments
 (0)