use of org.sonar.plugins.python.api.tree.ParameterList in project sonar-python by SonarSource.
the class ExitHasBadArgumentsCheck method initialize.
@Override
public void initialize(Context context) {
context.registerSyntaxNodeConsumer(Tree.Kind.FUNCDEF, ctx -> {
FunctionDef funcDef = (FunctionDef) ctx.syntaxNode();
if (!funcDef.name().name().equals("__exit__")) {
return;
}
ParameterList parameters = funcDef.parameters();
int arity = 0;
if (parameters != null) {
if (parameters.nonTuple().stream().anyMatch(ExitHasBadArgumentsCheck::isStarredParam)) {
return;
}
arity = parameters.all().size();
}
raiseIssue(ctx, funcDef, arity);
});
}
Aggregations