Skip to content

Commit 30389b5

Browse files
ghislainpiotsonartech
authored andcommitted
SONARPY-2983 Fix quality issues (#292)
GitOrigin-RevId: 8dc0a6f60d438dcc35a0546621fc930a68e42bc6
1 parent 7342717 commit 30389b5

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@ private String isOffendingException(Expression exception) {
116116

117117
}
118118

119-
private static boolean isReRaise(RaiseStatement raiseStatement, ExceptClause exceptClause) {
120-
var isBareRaise = raiseStatement.expressions().isEmpty();
121-
var exceptionInstanceName = TreeUtils.toOptionalInstanceOf(Name.class, exceptClause.exceptionInstance());
122-
123-
var isReRaise = raiseStatement.expressions().size() == 1 && exceptionInstanceName.isPresent()
124-
&& raiseStatement.expressions().get(0).is(Kind.NAME)
125-
&& ((Name) raiseStatement.expressions().get(0)).name().equals(exceptionInstanceName.get().name());
126-
127-
return isBareRaise || isReRaise;
128-
}
129-
130119
static class ComplianceChecker extends BaseTreeVisitor {
131120
private final ExceptClause exceptClause;
132121
private boolean hasRaiseStatement = false;
@@ -141,6 +130,17 @@ boolean isCompliant() {
141130
return isCompliant && hasRaiseStatement;
142131
}
143132

133+
private static boolean isReRaise(RaiseStatement raiseStatement, ExceptClause exceptClause) {
134+
var isBareRaise = raiseStatement.expressions().isEmpty();
135+
var exceptionInstanceName = TreeUtils.toOptionalInstanceOf(Name.class, exceptClause.exceptionInstance());
136+
137+
var isReRaise = raiseStatement.expressions().size() == 1 && exceptionInstanceName.isPresent()
138+
&& raiseStatement.expressions().get(0).is(Kind.NAME)
139+
&& ((Name) raiseStatement.expressions().get(0)).name().equals(exceptionInstanceName.get().name());
140+
141+
return isBareRaise || isReRaise;
142+
}
143+
144144
@Override
145145
public void visitRaiseStatement(RaiseStatement raiseStatement) {
146146
hasRaiseStatement = true;

0 commit comments

Comments
 (0)