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

SONARPY-2215 Document absence of types when CFG is invalid #2101

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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 @@ -130,7 +130,6 @@ private Map<SymbolV2, Set<PythonType>> inferTypesAndMemberAccessSymbols(Tree sco

ControlFlowGraph cfg = controlFlowGraphSupplier.get();
if (cfg == null) {
// TODO SONARPY-2215: fix me
return Map.of();
}
assignedNames.addAll(annotatedParameterNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,16 @@ void typesBySymbol_declaration_without_assignment() {
assertThat(typesBySymbol).isEmpty();
}

@Test
void typeBySymbol_invalidCfg() {
// No types will be retrieved when the CFG is invalid
var typesBySymbol = inferTypesBySymbol("""
class A: ...
continue
""");
assertThat(typesBySymbol).isEmpty();
}

private static Map<SymbolV2, Set<PythonType>> inferTypesBySymbol(String lines) {
FileInput root = parse(lines);
var symbolTable = new SymbolTableBuilderV2(root).build();
Expand Down