ghostbuster-cli 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ghostbuster/__init__.py +3 -0
- ghostbuster/__main__.py +5 -0
- ghostbuster/cli/__init__.py +1 -0
- ghostbuster/cli/app.py +76 -0
- ghostbuster/cli/bust.py +116 -0
- ghostbuster/cli/display.py +276 -0
- ghostbuster/cli/scan.py +141 -0
- ghostbuster/config.py +116 -0
- ghostbuster/core/__init__.py +1 -0
- ghostbuster/core/dead_imports.py +273 -0
- ghostbuster/core/models.py +140 -0
- ghostbuster/core/orphan_files.py +298 -0
- ghostbuster/core/phantom_env.py +196 -0
- ghostbuster/core/scanner.py +112 -0
- ghostbuster/core/scoring.py +83 -0
- ghostbuster/core/zombie_code.py +345 -0
- ghostbuster/fixers/__init__.py +1 -0
- ghostbuster/fixers/import_fixer.py +133 -0
- ghostbuster_cli-0.1.0.dist-info/METADATA +239 -0
- ghostbuster_cli-0.1.0.dist-info/RECORD +23 -0
- ghostbuster_cli-0.1.0.dist-info/WHEEL +4 -0
- ghostbuster_cli-0.1.0.dist-info/entry_points.txt +2 -0
- ghostbuster_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ghostbuster-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Find and bust the ghosts haunting your codebase - unused deps, dead code, orphan files, and phantom env vars.
|
|
5
|
+
Project-URL: Homepage, https://github.com/adewanggar/ghostbuster-cli
|
|
6
|
+
Project-URL: Documentation, https://github.com/adewanggar/ghostbuster-cli#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/adewanggar/ghostbuster-cli
|
|
8
|
+
Project-URL: Issues, https://github.com/adewanggar/ghostbuster-cli/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/adewanggar/ghostbuster-cli/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Ghostbuster Contributors
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: cli,code-quality,dead-code,developer-tools,devtools,linter,unused-dependencies
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
25
|
+
Classifier: Topic :: Software Development :: Testing
|
|
26
|
+
Classifier: Typing :: Typed
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
30
|
+
Requires-Dist: typer>=0.9.0
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
|
|
35
|
+
<img src="assets/readme_header.png" alt="Ghostbuster Header" width="100%" />
|
|
36
|
+
|
|
37
|
+
# Ghostbuster
|
|
38
|
+
|
|
39
|
+
**Find and bust the ghosts haunting your codebase.**
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/ghostbuster-cli/)
|
|
42
|
+
[](https://pypi.org/project/ghostbuster-cli/)
|
|
43
|
+
[](https://github.com/adewanggar/ghostbuster-cli/actions)
|
|
44
|
+
[](https://opensource.org/licenses/MIT)
|
|
45
|
+
[](https://pypi.org/project/ghostbuster-cli/)
|
|
46
|
+
|
|
47
|
+
Unused dependencies, dead functions, orphan files, and phantom environment variables lurk in codebases - slowing down repos, confusing new contributors, and wasting CI minutes.
|
|
48
|
+
|
|
49
|
+
**Ghostbuster finds them all in one command.**
|
|
50
|
+
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## <img src="assets/terminal_icon.png" width="24" height="24" valign="middle" /> Quick Start
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# Install
|
|
59
|
+
pip install ghostbuster-cli
|
|
60
|
+
|
|
61
|
+
# Scan your project
|
|
62
|
+
ghostbuster scan
|
|
63
|
+
|
|
64
|
+
# No config needed.
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## What It Finds
|
|
68
|
+
|
|
69
|
+
Ghostbuster detects **4 categories** in your codebase:
|
|
70
|
+
|
|
71
|
+
| Category | Identifier | What It Detects |
|
|
72
|
+
|:---------|:-----------|:----------------|
|
|
73
|
+
| **Dead Import** | `dead-import` | Dependencies in `requirements.txt` / `pyproject.toml` that are never imported |
|
|
74
|
+
| **Orphan File** | `orphan-file` | `node_modules/`, `venv/`, `.pyc`, large files that should be in `.gitignore` |
|
|
75
|
+
| **Zombie Code** | `zombie-code` | Functions and classes that are defined but never called from anywhere |
|
|
76
|
+
| **Phantom Env** | `phantom-env` | `os.environ["KEY"]` / `os.getenv("KEY")` where KEY is never set |
|
|
77
|
+
|
|
78
|
+
## Ghost Score
|
|
79
|
+
|
|
80
|
+
Every scan produces a **Ghost Score** (0-100) - the higher the score, the more technical debt in your codebase:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
+----------------------- Ghost Score ------------------------+
|
|
84
|
+
| |
|
|
85
|
+
| 47 / 100 |
|
|
86
|
+
| |
|
|
87
|
+
| #########################-------------------------- |
|
|
88
|
+
| |
|
|
89
|
+
| Noticeable technical debt detected. |
|
|
90
|
+
| |
|
|
91
|
+
+------------------------------------------------------------+
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Auto-Fix
|
|
95
|
+
|
|
96
|
+
Ghostbuster can also fix detected issues:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Preview what would be fixed (safe, default)
|
|
100
|
+
ghostbuster bust
|
|
101
|
+
|
|
102
|
+
# Actually apply fixes
|
|
103
|
+
ghostbuster bust --confirm
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Currently auto-fixes:
|
|
107
|
+
- Removes unused import statements
|
|
108
|
+
- Suggests `.gitignore` additions for orphan files
|
|
109
|
+
- Suggests `.env` additions for phantom env vars
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### Basic Scan
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Scan current directory
|
|
117
|
+
ghostbuster scan
|
|
118
|
+
|
|
119
|
+
# Scan a specific path
|
|
120
|
+
ghostbuster scan ./my-project
|
|
121
|
+
|
|
122
|
+
# Verbose mode (show locations and fix suggestions)
|
|
123
|
+
ghostbuster scan -v
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Filtered Scan
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Only check for dead imports
|
|
130
|
+
ghostbuster scan --category dead-import
|
|
131
|
+
|
|
132
|
+
# Only check for zombie code
|
|
133
|
+
ghostbuster scan -c zombie-code
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Output Formats
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
# Default: formatted terminal output
|
|
140
|
+
ghostbuster scan
|
|
141
|
+
|
|
142
|
+
# JSON (for CI pipelines and scripting)
|
|
143
|
+
ghostbuster scan --format json
|
|
144
|
+
|
|
145
|
+
# Markdown (for pasting into issues/PRs)
|
|
146
|
+
ghostbuster scan --format markdown
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### CI Integration
|
|
150
|
+
|
|
151
|
+
```yaml
|
|
152
|
+
# .github/workflows/ghostbuster.yml
|
|
153
|
+
name: Ghost Check
|
|
154
|
+
on: [push, pull_request]
|
|
155
|
+
jobs:
|
|
156
|
+
scan:
|
|
157
|
+
runs-on: ubuntu-latest
|
|
158
|
+
steps:
|
|
159
|
+
- uses: actions/checkout@v4
|
|
160
|
+
- uses: actions/setup-python@v5
|
|
161
|
+
with:
|
|
162
|
+
python-version: "3.12"
|
|
163
|
+
- run: pip install ghostbuster-cli
|
|
164
|
+
- run: ghostbuster scan --format json
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
> Note: `ghostbuster scan` exits with code 1 if issues are found - ideal for CI gates.
|
|
168
|
+
|
|
169
|
+
## Configuration
|
|
170
|
+
|
|
171
|
+
Ghostbuster works with **zero config**, but you can customize it:
|
|
172
|
+
|
|
173
|
+
### `pyproject.toml`
|
|
174
|
+
|
|
175
|
+
```toml
|
|
176
|
+
[tool.ghostbuster]
|
|
177
|
+
exclude_dirs = ["migrations", "generated"]
|
|
178
|
+
ignore_packages = ["my-internal-lib"]
|
|
179
|
+
ignore_env_vars = ["CI", "GITHUB_ACTIONS"]
|
|
180
|
+
ignore_names = ["deprecated_helper"]
|
|
181
|
+
large_file_threshold = 5242880 # 5MB
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `.ghostbuster.toml`
|
|
185
|
+
|
|
186
|
+
```toml
|
|
187
|
+
exclude_dirs = ["vendor", "third_party"]
|
|
188
|
+
categories = ["dead-import", "phantom-env"] # Only run these scanners
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## How It Works
|
|
192
|
+
|
|
193
|
+
Ghostbuster uses **pure AST analysis** - no runtime imports, no code execution, no external services:
|
|
194
|
+
|
|
195
|
+
1. **Dead Imports**: Parses `requirements.txt`/`pyproject.toml` for declared dependencies, walks AST for imports, cross-references with a package-to-import mapping table.
|
|
196
|
+
2. **Orphan Files**: Walks the file tree checking for known ignorable patterns (`node_modules/`, `venv/`, `__pycache__/`, large binary files) and verifies they are covered by `.gitignore`.
|
|
197
|
+
3. **Zombie Code**: Collects all function/class definitions and references across the codebase, identifying definitions with zero references (skipping `__init__`, `test_*`, and decorated functions).
|
|
198
|
+
4. **Phantom Env**: Detects `os.environ["KEY"]`, `os.environ.get("KEY")`, `os.getenv("KEY")` patterns via AST and checks against `.env` files and system environment.
|
|
199
|
+
|
|
200
|
+
## Alternatives
|
|
201
|
+
|
|
202
|
+
| Tool | Scope | Ghostbuster Advantage |
|
|
203
|
+
|:-----|:------|:----------------------|
|
|
204
|
+
| [Vulture](https://github.com/jendrikseipp/vulture) | Dead code only | Ghostbuster also covers dependencies, files, and env vars |
|
|
205
|
+
| [deptry](https://deptry.com/) | Unused deps only | Ghostbuster is a superset with unified output |
|
|
206
|
+
| [deadcode](https://github.com/albertas/deadcode) | Dead code only | Ghostbuster adds auto-fix and unified scoring |
|
|
207
|
+
| [git-sizer](https://github.com/github/git-sizer) | Repo size | Ghostbuster checks .gitignore coverage |
|
|
208
|
+
|
|
209
|
+
## Roadmap
|
|
210
|
+
|
|
211
|
+
- <img src="assets/npm_package_icon.png" width="18" height="18" valign="middle" /> Node.js / TypeScript support (scan `package.json`, dead exports)
|
|
212
|
+
- Pre-commit hook integration
|
|
213
|
+
- GitHub Actions reporter (comment Ghost Score on PRs)
|
|
214
|
+
- Config inheritance for monorepos
|
|
215
|
+
- Ghost Score history tracking & trend chart
|
|
216
|
+
|
|
217
|
+
## Contributing
|
|
218
|
+
|
|
219
|
+
Contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
git clone https://github.com/adewanggar/ghostbuster-cli.git
|
|
223
|
+
cd ghostbuster-cli
|
|
224
|
+
pip install -e .
|
|
225
|
+
pip install pytest ruff mypy
|
|
226
|
+
pytest tests/ -v
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT (c) Ghostbuster Contributors
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
<div align="center">
|
|
236
|
+
|
|
237
|
+
[Report Bug](https://github.com/adewanggar/ghostbuster-cli/issues) | [Request Feature](https://github.com/adewanggar/ghostbuster-cli/issues) | [Changelog](CHANGELOG.md)
|
|
238
|
+
|
|
239
|
+
</div>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
ghostbuster/__init__.py,sha256=DjoP35psoqdgS63xrsEHDnTZH86WuMfkESRWdSm5VJI,94
|
|
2
|
+
ghostbuster/__main__.py,sha256=lNt1TC6uQmJeWfsEjeVSdtWp3zXGPgvepc6GCdm_NPk,112
|
|
3
|
+
ghostbuster/config.py,sha256=eTp21FTGQa4UdDEe7rgj3P9y1EbJWQtoZKk9U2NDVZM,3516
|
|
4
|
+
ghostbuster/cli/__init__.py,sha256=Q4QzQCH5WEZ8gs4WSAwPLLChXkW6srvGr2DNM-sw8kE,58
|
|
5
|
+
ghostbuster/cli/app.py,sha256=nWUVYXBfmRiDhb4k7y9KA1H5qgAYWwyd6PGluT_jG2E,2018
|
|
6
|
+
ghostbuster/cli/bust.py,sha256=sc7aBE0uMEvhrKHWIcDQVr-QRzoS4guIK4gcw-jZhO8,3484
|
|
7
|
+
ghostbuster/cli/display.py,sha256=9P8CRKFhcgGtzjU-Gr-kQc8VxiEtlLNIzYwgs0WIJD8,8459
|
|
8
|
+
ghostbuster/cli/scan.py,sha256=f06buxk6Z_c3CBIq35Z4fXsANwVxD_ecxCnCNpXwUvM,3885
|
|
9
|
+
ghostbuster/core/__init__.py,sha256=mCcFCQAs6q5Qch1yffLAK38YcFn0NmpRdc-e8F6_vcw,68
|
|
10
|
+
ghostbuster/core/dead_imports.py,sha256=KqL5e2VZYpG8tXKf0p-9Rgznsmh3H3al9iQOSicfYww,10024
|
|
11
|
+
ghostbuster/core/models.py,sha256=lVsFcJo6hpK1Nlf7VGCrkhvGU4f-GXWoIBhK4Jj-0ps,4191
|
|
12
|
+
ghostbuster/core/orphan_files.py,sha256=Pwl5Dh8W86F9HK3NuHDljUosVk8Up80rT0QZc4jAxhs,10691
|
|
13
|
+
ghostbuster/core/phantom_env.py,sha256=8avf6nGRU6YoasgAq1Eew4SSSW91nB6eOVF6K-3Hpe0,6690
|
|
14
|
+
ghostbuster/core/scanner.py,sha256=kXEPUPPXnlOMBtCAhwzWU6-Dd7xgRxMKd-4H4OqNVNY,3640
|
|
15
|
+
ghostbuster/core/scoring.py,sha256=80XJC2OBWMrRQNsgwGkvJncGjNLdCkKMXvaoVNvFIMU,2836
|
|
16
|
+
ghostbuster/core/zombie_code.py,sha256=b8mkq5e7VbWb-iPgqfP3NoaVGykt2KvuZCm4sh2cI7Y,10080
|
|
17
|
+
ghostbuster/fixers/__init__.py,sha256=NM1-7IPmSGoBlp7Qo-XFufOA3jF0QbzQxjvrUFDvvZY,53
|
|
18
|
+
ghostbuster/fixers/import_fixer.py,sha256=BpY1skPxIVhpEKgBcol5K3tY90YsvKx7o7DJcOckZmc,5386
|
|
19
|
+
ghostbuster_cli-0.1.0.dist-info/METADATA,sha256=pQiSi1plgRspjDPM3bV8FJMJ5XyoYlc4Ihn6VRZc-r8,8173
|
|
20
|
+
ghostbuster_cli-0.1.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
21
|
+
ghostbuster_cli-0.1.0.dist-info/entry_points.txt,sha256=WbdyzM-b1ECGON6TXnuVe5LgF4EmL_fN5Pkq95L4oOw,56
|
|
22
|
+
ghostbuster_cli-0.1.0.dist-info/licenses/LICENSE,sha256=lGYPL1xowMCD0T-_FgH3xW-_6F6tfpUfVpPXqxFIU3Y,1081
|
|
23
|
+
ghostbuster_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ghostbuster Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|