Skip to content

Commit 3ea00e8

Browse files
maksim-grebeniuk-sonarsourcesonartech
authored andcommitted
SONARPY-2823 [S2201] IgnoredPureOperationsCheck make type checkers non static (#227)
GitOrigin-RevId: 968238f6b73323bfb46810ee720d2c9931e307e5
1 parent d02edac commit 3ea00e8

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@ public class IgnoredPureOperationsCheck extends PythonSubscriptionCheck {
280280
));
281281
}
282282

283-
private static Map<String, TypeCheckBuilder> pureFunctionsCheckers = null;
284-
private static Set<TypeCheckBuilder> pureGetitemTypesCheckers = null;
285-
private static Set<TypeCheckBuilder> pureContainsTypesCheckers = null;
283+
private Map<String, TypeCheckBuilder> pureFunctionsCheckers = null;
284+
private Set<TypeCheckBuilder> pureGetitemTypesCheckers = null;
285+
private Set<TypeCheckBuilder> pureContainsTypesCheckers = null;
286286

287287
@Override
288288
public void initialize(Context context) {
289-
context.registerSyntaxNodeConsumer(Tree.Kind.FILE_INPUT, IgnoredPureOperationsCheck::resetTypeCheckers);
289+
context.registerSyntaxNodeConsumer(Tree.Kind.FILE_INPUT, this::resetTypeCheckers);
290290
context.registerSyntaxNodeConsumer(Tree.Kind.EXPRESSION_STMT, ctx -> {
291291
ExpressionStatement expressionStatement = (ExpressionStatement) ctx.syntaxNode();
292292
if (TreeUtils.firstAncestor(expressionStatement, IgnoredPureOperationsCheck::isInTryBlock) != null) {
@@ -297,13 +297,13 @@ public void initialize(Context context) {
297297
});
298298
}
299299

300-
private static void resetTypeCheckers(SubscriptionContext ctx) {
300+
private void resetTypeCheckers(SubscriptionContext ctx) {
301301
pureFunctionsCheckers = PURE_FUNCTIONS.stream().collect(Collectors.toMap(f -> f, f -> ctx.typeChecker().typeCheckBuilder().isTypeWithName(f)));
302302
pureGetitemTypesCheckers = PURE_GETITEM_TYPES.stream().map(f -> ctx.typeChecker().typeCheckBuilder().isTypeOrInstanceWithName(f)).collect(Collectors.toSet());
303303
pureContainsTypesCheckers = PURE_CONTAINS_TYPES.stream().map(f -> ctx.typeChecker().typeCheckBuilder().isTypeOrInstanceWithName(f)).collect(Collectors.toSet());
304304
}
305305

306-
private static void checkExpression(SubscriptionContext ctx, Expression expression) {
306+
private void checkExpression(SubscriptionContext ctx, Expression expression) {
307307
if (expression.is(Tree.Kind.CALL_EXPR)) {
308308
CallExpression callExpression = (CallExpression) expression;
309309
PythonType pythonType = callExpression.callee().typeV2();

0 commit comments

Comments
 (0)