Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-JIRA test bottleneck #2245

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
import org.sonar.plugins.python.api.symbols.Symbol;
import org.sonar.plugins.python.api.tree.BaseTreeVisitor;
import org.sonar.plugins.python.api.tree.CallExpression;
import org.sonar.plugins.python.api.tree.Expression;
import org.sonar.plugins.python.api.tree.FileInput;
import org.sonar.plugins.python.api.tree.Name;
import org.sonar.plugins.python.api.tree.QualifiedExpression;
import org.sonar.plugins.python.api.tree.RegularArgument;
import org.sonar.python.index.AmbiguousDescriptor;
import org.sonar.python.index.Descriptor;
Expand Down Expand Up @@ -246,10 +249,24 @@ public void visitCallExpression(CallExpression callExpression) {
}

private boolean isCallRegisteringDjangoView(CallExpression callExpression) {
if (!isCallToPath(callExpression)) {
return false;
}
TypeChecker typeChecker = new TypeChecker(new BasicTypeTable(new ProjectLevelTypeTable(ProjectLevelSymbolTable.this)));
TriBool isConfPathCall = typeChecker.typeCheckBuilder().isTypeWithName("django.urls.conf.path").check(callExpression.callee().typeV2());
TriBool isPathCall = typeChecker.typeCheckBuilder().isTypeWithName("django.urls.path").check(callExpression.callee().typeV2());
return isConfPathCall.equals(TriBool.TRUE) || isPathCall.equals(TriBool.TRUE);
}

private boolean isCallToPath(CallExpression callExpression) {
Expression callee = callExpression.callee();
if (callee instanceof QualifiedExpression qualifiedExpression) {
return qualifiedExpression.name().name().equals("path");
}
if (callee instanceof Name name) {
return name.name().equals("path");
}
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,6 @@ void test_typeshed_stubs_information_is_saved_to_cache() {
// typing comes from TypeCheckBuilder querying the ProjectLevelType table (by looking for TypeVar) in its checks, which then queries & cache info in TypeShedDescriptorsProvider
assertThat(resolvedTypeshedModules).containsExactlyInAnyOrder(
"typing", "math",
"django", "django.urls.conf", "django.urls",
"fastapi", "fastapi.responses"
);
}
Expand Down