Skip to content

Commit f756840

Browse files
author
cowork-bot
committed
cowork-bot: merge master into cowork/improve-deadcode; resolve conflicts toward canonical scanner/tests
2 parents f41f880 + 4684832 commit f756840

18 files changed

Lines changed: 1169 additions & 313 deletions

.github/CODEOWNERS

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Code Owners for DeadCode repository
2+
# These individuals/teams are automatically requested for review on PRs
3+
4+
# Global owners
5+
* @Coding-Dev-Tools/engineers
6+
7+
# Python package
8+
src/deadcode/ @Coding-Dev-Tools/engineers
9+
10+
# Tests
11+
tests/ @Coding-Dev-Tools/engineers
12+
13+
# CI/CD workflows
14+
.github/workflows/ @Coding-Dev-Tools/engineers
15+
16+
# Documentation
17+
README.md @Coding-Dev-Tools/marketing
18+
CHANGELOG.md @Coding-Dev-Tools/marketing
19+
CONTRIBUTING.md @Coding-Dev-Tools/engineers
20+
SECURITY.md @Coding-Dev-Tools/engineers
21+
AGENTS.md @Coding-Dev-Tools/engineers
22+
23+
# Configuration
24+
pyproject.toml @Coding-Dev-Tools/engineers
25+
.deadcode.yml @Coding-Dev-Tools/engineers
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug to help us improve
4+
title: "[BUG] "
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
**Describe the Bug**
10+
A clear and concise description of what the bug is.
11+
12+
**To Reproduce**
13+
Steps to reproduce the behavior:
14+
1. Run command '...'
15+
2. With input '...'
16+
3. See error
17+
18+
**Expected Behavior**
19+
A clear and concise description of what you expected to happen.
20+
21+
**Environment (please complete):**
22+
- OS: [e.g. Ubuntu 22.04, macOS 14, Windows 11]
23+
- Python version: [e.g. 3.10, 3.12]
24+
- deadcode version: [e.g. 0.1.1]
25+
26+
**Additional Context**
27+
Add any other context about the problem here.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for this project
4+
title: "[FEATURE] "
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
**Is your feature request related to a problem?**
10+
A clear and concise description of what the problem is.
11+
12+
**Describe the Solution**
13+
A clear and concise description of what you want to happen.
14+
15+
**Describe Alternatives**
16+
A clear and concise description of any alternative solutions or features you've considered.
17+
18+
**Additional Context**
19+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Description
2+
3+
<!-- Briefly describe the changes in this PR -->
4+
5+
## Type of Change
6+
7+
- [ ] Bug fix
8+
- [ ] New feature
9+
- [ ] Documentation update
10+
- [ ] CI/CD improvement
11+
- [ ] Refactoring
12+
- [ ] Dependency update
13+
14+
## How Has This Been Tested?
15+
16+
- [ ] `pytest tests/ -v` passes
17+
- [ ] `ruff check .` passes
18+
19+
## Checklist
20+
21+
- [ ] My code follows the project's style guidelines
22+
- [ ] I have added tests that prove my fix/feature works
23+
- [ ] All existing tests pass
24+
- [ ] I have updated documentation as needed
25+
26+
## Related Issues
27+
28+
<!-- Link to any related issues: Fixes #123, Closes #456 -->

.github/workflows/ci.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: ["3.11", "3.12", "3.13"]
18+
python-version: ["3.10", "3.11", "3.12", "3.13"]
1919

2020
steps:
2121
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
@@ -36,14 +36,15 @@ jobs:
3636
run: ruff check .
3737

3838
- name: Run tests
39-
run: python -m pytest tests/ -x -q
39+
run: python -m pytest tests/ -q --cov=deadcode --cov-report=term-missing
4040

4141
publish:
4242
needs: test
4343
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
4444
runs-on: ubuntu-latest
4545
permissions:
4646
id-token: write
47+
contents: read
4748

4849
steps:
4950
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
@@ -62,4 +63,4 @@ jobs:
6263
run: python -m build
6364

6465
- name: Publish to PyPI
65-
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
66+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b

AGENTS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# deadcode
2+
3+
## Purpose
4+
CLI tool to detect and auto-remove unused exports, dead routes, and orphaned CSS in TypeScript/React/Next.js projects.
5+
6+
## Build & Test Commands
7+
- Install: `pip install -e .` or `pip install git+https://github.com/Coding-Dev-Tools/deadcode.git`
8+
- Test: `pytest tests/` (or `python -m pytest tests/ -v --tb=short`)
9+
- Lint: `ruff check src/ tests/`
10+
- Format: `ruff format src/ tests/`
11+
- Build: `pip install build twine && python -m build && twine check dist/*`
12+
- CLI check: `deadcode --help`
13+
14+
## Architecture
15+
Key directories:
16+
- `src/deadcode/` — Main package (CLI, scanner, config)
17+
- `tests/` — Test suite
18+
- `.github/workflows/` — CI/CD (auto-code-review.yml, ci.yml, publish.yml)
19+
20+
## Conventions
21+
- Language: Python 3.10+
22+
- Test framework: pytest (with coverage)
23+
- CI: GitHub Actions (matrix: Python 3.10, 3.11, 3.12, 3.13)
24+
- Linting/formatting: ruff (line-length 120, target py310)
25+
- Package layout: src/ layout with setuptools
26+
- Type checking: py.typed included
27+
- Dependencies: click, rich, pathspec, pyyaml
28+
- CLI entry point: deadcode.cli:cli
29+
- Default branch: master
30+
- Branch naming: `improve/<repo>-<timestamp>` for structural fixes

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ Thanks for your interest in contributing!
88
2. Create a virtual environment: python -m venv .venv && source .venv/bin/activate
99
3. Install dev dependencies: pip install -e ".[dev]"
1010
4. Run tests: pytest tests/ -v
11-
5. Lint: uff check src/
11+
5. Lint: ruff check src/
12+
6. Run ruff format src/ --check before committing
1213

1314
## Pull Requests
1415

1516
- Fork the repo and create a feature branch
1617
- Add tests for any new functionality
1718
- Ensure all existing tests pass
18-
- Run uff check src/ --fix before committing
19+
- Run ruff check src/ --fix before committing
1920
- Keep PRs focused on a single change
2021

2122
## Reporting Issues
@@ -32,4 +33,4 @@ Thanks for your interest in contributing!
3233

3334
## License
3435

35-
By contributing, you agree your work will be licensed under the same license as this project.
36+
By contributing, you agree your work will be licensed under the same license as this project.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ deadcode stats
7676
- **Unused export detection** — finds functions, types, classes, interfaces, enums, and consts that are exported but never imported within your project
7777
- **Dead route detection** — detects unreachable page components in Next.js App Router projects
7878
- **Orphaned CSS detection** — finds CSS module classes that are defined but never referenced in TSX/JSX files
79-
- **Safe auto-removal**`--dry-run` preview mode shows exactly what will be deleted before making changes
80-
- **Full-project AST analysis** — regex-based scanning covers export/import patterns, route detection, CSS class usage, and component references across your entire codebase
79+
- **Safe auto-removal**`--dry-run` preview shows exactly what will be deleted first; `remove` only blanks self-contained single-line findings and skips (with a warning) anything spanning multiple lines, so it never leaves half-deleted, broken code
80+
- **Full-project scanning**fast regex-based scanning covers export/import patterns, route detection, CSS class usage, and component references across your entire codebase (no AST/tree-sitter — deliberately dependency-free and quick)
8181
- **Monorepo support** — handles large projects efficiently with ignore patterns
8282
- **CI integration** — JSON output for automated pipelines and gating
8383

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""pytest configuration — add project src to Python path."""
2+
23
import site
34
import sys
45
from pathlib import Path

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "deadcode-cli",
33
"version": "0.1.1",
4-
"description": "Find unused/dead code in Python projects. Static analysis tool to identify orphaned functions, classes, and imports.",
4+
"description": "Find unused/dead code in TypeScript, React, and Next.js projects. Scans for orphaned exports, dead routes, unreferenced components, and unused CSS module classes.",
55
"author": "Revenue Holdings <engineering@revenueholdings.dev>",
66
"license": "MIT",
77
"repository": {
@@ -38,6 +38,7 @@
3838
"engines": {
3939
"node": ">=16.0.0"
4040
},
41+
"preferGlobal": true,
4142
"publishConfig": {
4243
"access": "public"
4344
}

0 commit comments

Comments
 (0)