Skip to content

Commit 60be312

Browse files
committed
Remove CodeQL backend; introduce analysis_level option
CodeQL is incompatible with open-source distribution (proprietary CLI, licensed query packs). Replace the using_codeql: bool option with analysis_level: int (1=symbol table only, 2=+call graph). Remove the entire codeanalyzer/semantic_analysis/codeql/ module and all CLI flags, __enter__ setup, and helper methods that depended on it. Provenance literal updated: "codeql" -> "pycg" in PyCallEdge schema. CLI flag updated: --codeql/--no-codeql -> -a/--analysis-level. Signed-off-by: Saurabh Sinha <sinha108@gmail.com>
1 parent 3b3e10e commit 60be312

10 files changed

Lines changed: 18 additions & 707 deletions

File tree

codeanalyzer/__main__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,16 @@ def main(
2727
case_sensitive=False,
2828
),
2929
] = OutputFormat.JSON,
30-
using_codeql: Annotated[
31-
bool, typer.Option("--codeql/--no-codeql", help="Enable CodeQL-based analysis.")
32-
] = False,
30+
analysis_level: Annotated[
31+
int,
32+
typer.Option(
33+
"-a",
34+
"--analysis-level",
35+
help="Analysis depth: 1=symbol table only, 2=+call graph (PyCG+Jedi).",
36+
min=1,
37+
max=2,
38+
),
39+
] = 1,
3340
using_ray: Annotated[
3441
bool,
3542
typer.Option("--ray/--no-ray", help="Enable Ray for distributed analysis."),
@@ -78,7 +85,7 @@ def main(
7885
input=input,
7986
output=output,
8087
format=format,
81-
using_codeql=using_codeql,
88+
analysis_level=analysis_level,
8289
using_ray=using_ray,
8390
rebuild_analysis=rebuild_analysis,
8491
skip_tests=skip_tests,
@@ -143,7 +150,7 @@ def _write_output(artifacts, output_dir: Path, format: OutputFormat):
143150
app = typer.Typer(
144151
callback=main,
145152
name="codeanalyzer",
146-
help="Static Analysis on Python source code using Jedi, CodeQL and Tree sitter.",
153+
help="Static Analysis on Python source code using Jedi, PyCG and Tree sitter.",
147154
invoke_without_command=True,
148155
no_args_is_help=True,
149156
add_completion=False,

codeanalyzer/options/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AnalysisOptions:
1414
input: Path
1515
output: Optional[Path] = None
1616
format: OutputFormat = OutputFormat.JSON
17-
using_codeql: bool = False
17+
analysis_level: int = 1
1818
using_ray: bool = False
1919
rebuild_analysis: bool = False
2020
skip_tests: bool = True

codeanalyzer/schema/py_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class PyCallEdge(BaseModel):
355355
target: str # callee's PyCallable.signature
356356
type: Literal["CALL_DEP"] = "CALL_DEP"
357357
weight: int = 1
358-
provenance: List[Literal["jedi", "codeql", "joern"]] = []
358+
provenance: List[Literal["jedi", "pycg", "joern"]] = []
359359

360360

361361
@builder

codeanalyzer/semantic_analysis/call_graph.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def jedi_call_graph_edges(
173173
174174
Edges are coalesced on ``(source, target)``: ``weight`` is the count of
175175
matching sites. Provenance is always ``["jedi"]``; combine with
176-
CodeQL-derived edges via ``merge_edges``.
176+
PyCG-derived edges via ``merge_edges``.
177177
"""
178178
counts: Counter = Counter()
179179
for caller in iter_callables_in_symbol_table(symbol_table):
@@ -191,7 +191,7 @@ def jedi_call_graph_edges(
191191
def resolve_unresolved_constructors(symbol_table: Dict[str, PyModule]) -> int:
192192
"""Fill in ``PyCallsite.callee_signature`` for unresolved constructor sites.
193193
194-
When both Jedi and CodeQL fail to resolve a constructor call (commonly
194+
When Jedi fails to resolve a constructor call (commonly
195195
for classes nested inside functions or methods, where static-analysis
196196
points-to is weakest), Jedi still flags the site as
197197
``is_constructor_call=True`` with ``method_name`` set to the class's
@@ -251,7 +251,7 @@ def merge_edges(*edge_lists: list) -> list:
251251
252252
Edges with the same ``(source, target)`` are coalesced: weights sum,
253253
provenance is the sorted union. Useful for combining edges produced
254-
by different backends (e.g. Jedi + CodeQL).
254+
by different backends (e.g. Jedi + PyCG).
255255
"""
256256
by_key: Dict[Tuple[str, str], PyCallEdge] = {}
257257
for edges in edge_lists:

codeanalyzer/semantic_analysis/codeql/__init__.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)