You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- tests/test_command_integration.py (new file, 11 tests)
38
+
- tests/test_reporters.py (added 6 tests)
39
+
- tests/settings.py (added BASE_DIR)
40
+
- README.md (documented new features)
41
+
- CHANGELOG.md (this entry)
42
+
43
+
Breaking Changes: None
44
+
- All changes are additive and backward compatible
45
+
- Output format unchanged (just fewer false positives)
46
+
- All existing tests continue to pass
47
+
3
48
## v0.1.0 (2025-11-12)
4
49
5
50
### Feature
@@ -28,20 +73,20 @@
28
73
* fix: resolve semantic-release build failure by using pre-built artifacts
29
74
30
75
The release job was failing because python-semantic-release tried to run
31
-
'python -m build' but the build package wasn't installed in its container.
76
+
'python -m build' but the build package wasn't installed in its container.
32
77
33
78
This fix:
34
79
- Downloads the already-built artifacts from the build job
35
80
- Sets build_command to empty string in semantic-release config
36
81
- Avoids duplicate builds and uses tested artifacts
37
82
- More efficient workflow execution
38
83
39
-
Fixes the error: "/usr/local/bin/python: No module named build" ([`064f467`](https://github.com/nanorepublica/django-deadcode/commit/064f46797ccfbb6366f4d31ba078b44a2bab4bf2))
84
+
Fixes the error: "/usr/local/bin/python: No module named build" ([`064f467`](https://github.com/nanorepublica/django-deadcode/commit/064f46797ccfbb6366f4d31ba078b44a2bab4bf2))
40
85
41
86
* fix: resolve all ruff linting errors
42
87
43
88
- Add missing reverse_analyzer parameter to _compile_analysis_data
44
-
- Update type hints: Set -> set, IOError -> OSError
89
+
- Update type hints: Set -> set, IOError -> OSError
45
90
- Fix line length violations (split long lines)
46
91
- Remove unused imports in test files ([`6bb93d3`](https://github.com/nanorepublica/django-deadcode/commit/6bb93d32a14011888cd5e75638ce08afea52885b))
Add GitHub Actions for CI/CD and PyPI publishing ([`c80007f`](https://github.com/nanorepublica/django-deadcode/commit/c80007f33467c76e5ffaaa748d50bc25393427b6))
69
114
70
-
* Merge branch 'claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w' of http://127.0.0.1:57967/git/nanorepublica/django-deadcode into claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w ([`cb2e384`](https://github.com/nanorepublica/django-deadcode/commit/cb2e38413da80dbba2036c4d802f2652f317704d))
115
+
* Merge branch 'claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w' of http://127.0.0.1:57967/git/nanorepublica/django-deadcode into claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w ([`cb2e384`](https://github.com/nanorepublica/django-deadcode/commit/cb2e38413da80dbba2036c4d802f2652f317704d))
71
116
72
-
* Merge branch 'main' into claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w ([`7117dfc`](https://github.com/nanorepublica/django-deadcode/commit/7117dfce628e757082dea55fecfab1ea27eeb74b))
117
+
* Merge branch 'main' into claude/cicd-github-actions-011CV2ofdGATxikzCT7taJ3w ([`7117dfc`](https://github.com/nanorepublica/django-deadcode/commit/7117dfce628e757082dea55fecfab1ea27eeb74b))
73
118
74
119
* Merge pull request #3 from nanorepublica/claude/feature-reverse-redirect-detection-011CV2ofdGATxikzCT7taJ3w
75
120
@@ -88,8 +133,8 @@ New Features:
88
133
89
134
Implementation Details:
90
135
- AST parsing of all Python files (excluding migrations/third-party)
@@ -142,23 +187,23 @@ All tests pass (19/19). All ruff checks now pass. ([`a71a9b5`](https://github.co
142
187
143
188
* Add pythonpath to pytest config to fix module import in CI
144
189
145
-
Added 'pythonpath = ["."]' to pytest configuration to ensure the
190
+
Added 'pythonpath = ["."]' to pytest configuration to ensure the
146
191
project root is on the Python path when pytest-django initializes.
147
192
148
-
This fixes the 'No module named tests' error in GitHub Actions CI.
193
+
This fixes the 'No module named tests' error in GitHub Actions CI.
149
194
The pythonpath setting tells pytest to add the current directory to
150
195
sys.path before importing test modules, allowing pytest-django to
151
-
import 'tests.settings' successfully.
196
+
import 'tests.settings' successfully.
152
197
153
198
Tests pass locally and should now pass in CI. ([`cb66329`](https://github.com/nanorepublica/django-deadcode/commit/cb66329ad91251f4d01d047310c595c99999ce49))
154
199
155
200
* Fix pytest-django configuration for library packages
156
201
157
-
Add 'django_find_project = false' to pytest configuration to prevent
202
+
Add 'django_find_project = false' to pytest configuration to prevent
158
203
pytest-django from looking for manage.py.
159
204
160
205
This is necessary because django-deadcode is a Django package/library,
161
-
not a Django project. Libraries don't have manage.py files, but still
206
+
not a Django project. Libraries don't have manage.py files, but still
162
207
need Django settings for testing.
163
208
164
209
The setting tells pytest-django to use the DJANGO_SETTINGS_MODULE
@@ -173,12 +218,12 @@ Updated testing matrix to focus on currently supported versions:
@@ -259,19 +304,19 @@ Ready for task list creation. ([`3564f2d`](https://github.com/nanorepublica/djan
259
304
260
305
Documented key decisions from requirements gathering phase:
261
306
262
-
Scope & Architecture:
307
+
Scope & Architecture:
263
308
- Analyze all Python files (views, forms, models, utils, etc.)
264
309
- Create separate ReverseAnalyzer class
265
310
- Refactor common AST parsing logic between analyzers
This is useful for understanding how templates are connected but can make reports verbose for large projects.
108
+
97
109
## What It Detects
98
110
99
111
### Unreferenced URL Patterns
@@ -131,14 +143,17 @@ class MyView(UpdateView):
131
143
132
144
### Unused Templates
133
145
134
-
Templates that exist but are not referenced by any view:
146
+
Templates that exist but are not referenced by any view (directly or indirectly through includes/extends):
135
147
136
148
```python
137
149
# views.py - No view renders 'unused_template.html'
150
+
# And no other template includes or extends it
138
151
139
152
# But the file templates/unused_template.html exists
140
153
```
141
154
155
+
**Note**: Templates referenced via `{% include %}` or `{% extends %}` are now correctly identified as used, even if not directly referenced by views.
156
+
142
157
### Template Relationships
143
158
144
159
Tracks which templates include or extend other templates:
@@ -151,6 +166,8 @@ Tracks which templates include or extend other templates:
151
166
{% include 'partials/header.html' %}
152
167
```
153
168
169
+
Use the `--show-template-relationships` flag to see these relationships in your report.
170
+
154
171
## Example Output
155
172
156
173
```
@@ -189,34 +206,37 @@ These templates are not directly referenced by views (may be included/extended):
189
206
190
207
## How It Works
191
208
192
-
1.**Template Analysis**: Scans all template files for:
209
+
1.**Template Analysis**: Scans all template files **within your project's BASE_DIR**for:
193
210
-`{% url 'name' %}` tags
194
211
-`href="/path/"` attributes (internal links)
195
212
-`{% include 'template' %}` tags
196
213
-`{% extends 'template' %}` tags
197
214
198
-
2.**URL Pattern Discovery**: Inspects Django's URL configuration to find all defined URL patterns and their names
215
+
2.**Project Boundary Filtering**: Only templates within your project's `BASE_DIR` are analyzed. Templates from installed packages (e.g., Django admin, third-party apps) are automatically excluded.
199
216
200
-
3.**View Analysis**: Parses Python files to find:
217
+
3.**URL Pattern Discovery**: Inspects Django's URL configuration to find all defined URL patterns and their names
218
+
219
+
4.**View Analysis**: Parses Python files to find:
201
220
-`render(request, 'template.html')` calls
202
221
-`template_name = 'template.html'` in class-based views
203
222
204
-
4.**Reverse/Redirect Analysis**: Uses AST parsing to detect:
223
+
5.**Reverse/Redirect Analysis**: Uses AST parsing to detect:
- Dynamic URL patterns (f-strings, concatenation) are flagged for manual review
210
229
211
-
5.**Relationship Mapping**: Connects templates ↔ URLs ↔ views to identify dead code
230
+
6.**Transitive Template Detection**: Recursively traces template relationships to mark templates as used if they're referenced via `{% include %}` or `{% extends %}` from any used template
231
+
232
+
7.**Relationship Mapping**: Connects templates ↔ URLs ↔ views to identify dead code
212
233
213
234
## Limitations
214
235
215
236
-**Static Analysis Only**: Does not execute code or track runtime behavior
0 commit comments