use of org.sonar.plugins.python.api.tree.Tree.Kind.SUBSCRIPTION in project sonar-python by SonarSource.
the class CorsCheck method checkAllowOriginProperty.
private static void checkAllowOriginProperty(SubscriptionContext ctx) {
AssignmentStatement assignment = (AssignmentStatement) ctx.syntaxNode();
Optional<Expression> lhs = getOnlyAssignedLhs(assignment);
if (lhs.isPresent() && lhs.get().is(SUBSCRIPTION)) {
SubscriptionExpression subscription = (SubscriptionExpression) lhs.get();
List<Expression> subscripts = subscription.subscripts().expressions();
if (subscripts.size() != 1) {
return;
}
if (subscription.object().is(NAME) && TYPES_TO_CHECK.stream().anyMatch(t -> subscription.object().type().canOnlyBe(t))) {
reportIfAllowOriginIsSet(ctx, assignment, subscripts.get(0));
} else {
checkAllowOriginPropertyQualifiedExpr(ctx, assignment, subscription, subscripts);
}
}
}
Aggregations