Skip to content

Commit d978d48

Browse files
committed
fix(core): fixed the FP dead code detector for popular frameworks (FastAPI/Starlette route and dependency registration, Django URL patterns, Dependency Injector providers, Typer/Click commands, and Celery tasks), as well as CI tests.
1 parent e06b514 commit d978d48

39 files changed

Lines changed: 2186 additions & 75 deletions

.github/actions/codeclone/_action_impl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from typing import Literal
2626

2727
COMMENT_MARKER = "<!-- codeclone-report -->"
28-
DEFAULT_CODECLONE_PACKAGE_VERSION = "2.0.0"
28+
DEFAULT_CODECLONE_PACKAGE_VERSION = "2.0.1b1"
2929

3030

3131
@dataclass(frozen=True, slots=True)

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ from another doc.** Current values (verified at write time):
144144
|-----------------------------------|-----------------------------------|---------------|
145145
| `BASELINE_SCHEMA_VERSION` | `codeclone/contracts/__init__.py` | `2.1` |
146146
| `BASELINE_FINGERPRINT_VERSION` | `codeclone/contracts/__init__.py` | `1` |
147-
| `CACHE_VERSION` | `codeclone/contracts/__init__.py` | `2.6` |
148-
| `REPORT_SCHEMA_VERSION` | `codeclone/contracts/__init__.py` | `2.10` |
147+
| `CACHE_VERSION` | `codeclone/contracts/__init__.py` | `2.7` |
148+
| `REPORT_SCHEMA_VERSION` | `codeclone/contracts/__init__.py` | `2.11` |
149149
| `METRICS_BASELINE_SCHEMA_VERSION` | `codeclone/contracts/__init__.py` | `1.2` |
150150

151151
When updating any doc that mentions a version, re-read `codeclone/contracts/__init__.py` first. Do not derive

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Dead code
6+
7+
- Add framework-aware runtime reachability facts for dead-code analysis: FastAPI/Starlette routes and dependencies,
8+
Django URL patterns, Dependency Injector providers, Typer/Click commands, and Celery tasks.
9+
- Keep the model evidence-based and deterministic: supported registrations suppress false dead-code findings, while the
10+
new cache `2.7` and report schema `2.11` carry the reachability facts for cold/warm parity and report explainability.
11+
312
## [2.0.0] - 2026-04-30
413

514
`2.0.0` promotes the completed 2.0 release line to the stable public contract.

codeclone/analysis/ast_helpers.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this
3+
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
# SPDX-License-Identifier: MPL-2.0
5+
# Copyright (c) 2026 Den Rozhnovskiy
6+
7+
from __future__ import annotations
8+
9+
import ast
10+
11+
12+
def ast_node_start_line(node: ast.AST) -> int | None:
13+
line = getattr(node, "lineno", None)
14+
if isinstance(line, int) and line > 0:
15+
return line
16+
return None
17+
18+
19+
def ast_node_end_line(node: ast.AST) -> int:
20+
start_line = ast_node_start_line(node)
21+
if start_line is None:
22+
return 0
23+
end_line = getattr(node, "end_lineno", None)
24+
return (
25+
end_line if isinstance(end_line, int) and end_line >= start_line else start_line
26+
)

0 commit comments

Comments
 (0)