code-prune 1.0.0__tar.gz

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.
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2026-11-01
4
+
5
+ ### Added
6
+
7
+ - Core dead-code CLI: `code-prune <path> [options]`, built on Click and Rich,
8
+ mirroring the `litscan` basis project's architecture.
9
+ - Tree-sitter based detection across Python, JavaScript, TypeScript, Java,
10
+ and Gosu for five categories of findings: unreachable code, unused imports
11
+ & local variables, cross-file unused functions/classes/methods, obsolete
12
+ (`@deprecated`/TODO/FIXME) markers, and commented-out code.
13
+ - `config.ini` with an `[override] ignore-file` setting, a bundled
14
+ `.codepruneignore` (gitignore-style path exclusions), and a bundled
15
+ `symbol_ignore` (regex symbol-name exclusions for unused-symbol findings).
16
+ - SQLite-backed `SessionStore` for concurrent per-file scanning and a
17
+ SQL-aggregated cross-file "unused symbol" resolution pass.
18
+ - JSON and HTML report output via `--format`.
19
+
20
+ ### Fixed
21
+
22
+ - Upgraded `tree-sitter-gosu` to `>=0.3.0,<0.4.0`, which decomposes `${...}`
23
+ string interpolation into real `interpolation`/`identifier` nodes. This
24
+ resolves a false-positive `unused-local`/`unused-import`/`unused-symbol`
25
+ finding for Gosu names referenced only inside string interpolation (e.g.
26
+ `"... ${myVar} ..."`).
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ron Webb
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.
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: code-prune
3
+ Version: 1.0.0
4
+ Summary: Find unreachable, unused, and obsolete code before it becomes technical debt.
5
+ License: MIT License
6
+
7
+ Copyright (c) 2026 Ron Webb
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
26
+ License-File: LICENSE
27
+ Keywords: cli,static-analysis,dead-code,unused-code,tree-sitter,code-quality
28
+ Author: Ron Webb
29
+ Requires-Python: >=3.14
30
+ Classifier: Development Status :: 4 - Beta
31
+ Classifier: Environment :: Console
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: Operating System :: OS Independent
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.14
36
+ Classifier: Programming Language :: Python :: 3 :: Only
37
+ Classifier: Topic :: Software Development :: Quality Assurance
38
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
39
+ Classifier: Typing :: Typed
40
+ Requires-Dist: braincraft (>=1.3.1,<2.0.0)
41
+ Requires-Dist: click (>=8.0.0,<9.0.0)
42
+ Requires-Dist: env-dir-bootstrap (>=1.0.0,<2.0.0)
43
+ Requires-Dist: logenrich (>=1.0.1,<2.0.0)
44
+ Requires-Dist: rich (>=15.0.0,<16.0.0)
45
+ Requires-Dist: tree-sitter (>=0.26.0,<0.27.0)
46
+ Requires-Dist: tree-sitter-gosu (>=0.3.0,<0.4.0)
47
+ Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
48
+ Requires-Dist: tree-sitter-javascript (>=0.25.0,<0.26.0)
49
+ Requires-Dist: tree-sitter-python (>=0.25.0,<0.26.0)
50
+ Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
51
+ Project-URL: Changelog, https://github.com/rcw3bb/code-prune/blob/main/CHANGELOG.md
52
+ Project-URL: Homepage, https://github.com/rcw3bb/code-prune
53
+ Project-URL: Issues, https://github.com/rcw3bb/code-prune/issues
54
+ Project-URL: Repository, https://github.com/rcw3bb/code-prune
55
+ Description-Content-Type: text/markdown
56
+
57
+ # code-prune
58
+
59
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [![Version](https://img.shields.io/badge/Version-1.0.0-green.svg)](https://github.com/rcw3bb/code-prune/blob/main/CHANGELOG.md) [![Python](https://img.shields.io/badge/Python-3.14%2B-blue)](https://www.python.org/) [![PyPI](https://img.shields.io/badge/PyPI-code-prune-orange)](https://pypi.org/project/code-prune/)
60
+
61
+
62
+ A CLI tool that scans a codebase for unreachable, unused, and obsolete code,
63
+ helping you find dead code before it becomes technical debt.
64
+
65
+ ## Features
66
+
67
+ `code-prune` parses source files with [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
68
+ and reports five categories of findings across **Python, JavaScript,
69
+ TypeScript, Java, and Gosu**:
70
+
71
+ - **Unreachable code** — statements after `return`/`raise`/`throw`/`break`/
72
+ `continue`, and `if` branches whose condition is a constant falsy literal
73
+ (`False`/`false`/`0`).
74
+ - **Unused imports & local variables** — per-file, syntactic detection of
75
+ bindings that are never referenced again in the same file.
76
+ - **Unused functions/classes/methods** — cross-file detection of definitions
77
+ that are never referenced anywhere in the scanned project.
78
+ - **Obsolete markers** — `@deprecated`/`@Deprecated`-style decorators and
79
+ annotations, plus `TODO`/`FIXME`/`XXX` comment tags.
80
+ - **Commented-out code** — comments whose content heuristically resembles
81
+ source code.
82
+
83
+ > Detection is heuristic and syntactic rather than a full scope- or
84
+ > call-graph-aware analysis — treat findings as a starting point for review,
85
+ > not a guarantee.
86
+
87
+ ## Requirements
88
+
89
+ - Python `>=3.14`
90
+ - Poetry `2.2`
91
+
92
+ ## Installation
93
+
94
+ ```powershell
95
+ poetry install
96
+ ```
97
+
98
+ ## Usage
99
+
100
+ ```powershell
101
+ poetry run code-prune <path> [options]
102
+ ```
103
+
104
+ Common options:
105
+
106
+ | Option | Description |
107
+ |-------------------|------------------------------------------------------------------------------|
108
+ | `--ext` | Comma-separated extensions to include (e.g. `py,js,ts,java,gs,gsx`). |
109
+ | `--categories` | Comma-separated categories to report: `unreachable,unused,obsolete,commented-out` (default: all). |
110
+ | `--format` | Output format: `json`, `html`, or `all` (default: `json`). |
111
+ | `--output` | Base output filename without extension (default: `code-prune-output`). |
112
+ | `--output-dir` | Directory for the report file(s) (default: `reports`). |
113
+ | `--workers` | Number of parallel worker threads used to scan files. |
114
+ | `--db` | Path to the SQLite scratch database used during a scan run. |
115
+ | `--target-list` | Treat `path` as a file listing target paths, one per line. |
116
+
117
+ Example:
118
+
119
+ ```powershell
120
+ poetry run code-prune src --categories unreachable,unused --format all
121
+ ```
122
+
123
+ ## Configuration
124
+
125
+ Logging is bootstrapped via `env-dir-bootstrap`. Set the `CODE_PRUNE_CONFIG_DIR`
126
+ environment variable to override the default configuration directory used to
127
+ resolve `logging.ini`, `config.ini`, `.codepruneignore`, and `symbol_ignore`.
128
+
129
+ ### Ignoring files and directories
130
+
131
+ `.codepruneignore` holds gitignore-style patterns for files/directories to
132
+ exclude from scanning (mirroring `.gitignore` syntax). Override the filename
133
+ via `config.ini`:
134
+
135
+ ```ini
136
+ [override]
137
+ ignore-file = .codepruneignore
138
+ ```
139
+
140
+ ### Ignoring symbol names
141
+
142
+ `symbol_ignore` holds one regex pattern per line, matched against symbol
143
+ names to suppress from "unused function/class/method" findings — useful for
144
+ dunder methods, `main`, test hooks (`test_*`, `setUp`), and similar
145
+ intentionally-unreferenced symbols.
146
+
147
+ ## Development
148
+
149
+ Run tests with coverage and generate an HTML report:
150
+
151
+ ```powershell
152
+ poetry run pytest --cov=code_prune tests --cov-report html
153
+ ```
154
+
155
+ Format and lint the code:
156
+
157
+ ```powershell
158
+ poetry run black code_prune; poetry run pylint code_prune
159
+ ```
160
+
161
+ ## License
162
+
163
+ This project is licensed under the [MIT License](LICENSE).
164
+
@@ -0,0 +1,107 @@
1
+ # code-prune
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [![Version](https://img.shields.io/badge/Version-1.0.0-green.svg)](https://github.com/rcw3bb/code-prune/blob/main/CHANGELOG.md) [![Python](https://img.shields.io/badge/Python-3.14%2B-blue)](https://www.python.org/) [![PyPI](https://img.shields.io/badge/PyPI-code-prune-orange)](https://pypi.org/project/code-prune/)
4
+
5
+
6
+ A CLI tool that scans a codebase for unreachable, unused, and obsolete code,
7
+ helping you find dead code before it becomes technical debt.
8
+
9
+ ## Features
10
+
11
+ `code-prune` parses source files with [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
12
+ and reports five categories of findings across **Python, JavaScript,
13
+ TypeScript, Java, and Gosu**:
14
+
15
+ - **Unreachable code** — statements after `return`/`raise`/`throw`/`break`/
16
+ `continue`, and `if` branches whose condition is a constant falsy literal
17
+ (`False`/`false`/`0`).
18
+ - **Unused imports & local variables** — per-file, syntactic detection of
19
+ bindings that are never referenced again in the same file.
20
+ - **Unused functions/classes/methods** — cross-file detection of definitions
21
+ that are never referenced anywhere in the scanned project.
22
+ - **Obsolete markers** — `@deprecated`/`@Deprecated`-style decorators and
23
+ annotations, plus `TODO`/`FIXME`/`XXX` comment tags.
24
+ - **Commented-out code** — comments whose content heuristically resembles
25
+ source code.
26
+
27
+ > Detection is heuristic and syntactic rather than a full scope- or
28
+ > call-graph-aware analysis — treat findings as a starting point for review,
29
+ > not a guarantee.
30
+
31
+ ## Requirements
32
+
33
+ - Python `>=3.14`
34
+ - Poetry `2.2`
35
+
36
+ ## Installation
37
+
38
+ ```powershell
39
+ poetry install
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ```powershell
45
+ poetry run code-prune <path> [options]
46
+ ```
47
+
48
+ Common options:
49
+
50
+ | Option | Description |
51
+ |-------------------|------------------------------------------------------------------------------|
52
+ | `--ext` | Comma-separated extensions to include (e.g. `py,js,ts,java,gs,gsx`). |
53
+ | `--categories` | Comma-separated categories to report: `unreachable,unused,obsolete,commented-out` (default: all). |
54
+ | `--format` | Output format: `json`, `html`, or `all` (default: `json`). |
55
+ | `--output` | Base output filename without extension (default: `code-prune-output`). |
56
+ | `--output-dir` | Directory for the report file(s) (default: `reports`). |
57
+ | `--workers` | Number of parallel worker threads used to scan files. |
58
+ | `--db` | Path to the SQLite scratch database used during a scan run. |
59
+ | `--target-list` | Treat `path` as a file listing target paths, one per line. |
60
+
61
+ Example:
62
+
63
+ ```powershell
64
+ poetry run code-prune src --categories unreachable,unused --format all
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ Logging is bootstrapped via `env-dir-bootstrap`. Set the `CODE_PRUNE_CONFIG_DIR`
70
+ environment variable to override the default configuration directory used to
71
+ resolve `logging.ini`, `config.ini`, `.codepruneignore`, and `symbol_ignore`.
72
+
73
+ ### Ignoring files and directories
74
+
75
+ `.codepruneignore` holds gitignore-style patterns for files/directories to
76
+ exclude from scanning (mirroring `.gitignore` syntax). Override the filename
77
+ via `config.ini`:
78
+
79
+ ```ini
80
+ [override]
81
+ ignore-file = .codepruneignore
82
+ ```
83
+
84
+ ### Ignoring symbol names
85
+
86
+ `symbol_ignore` holds one regex pattern per line, matched against symbol
87
+ names to suppress from "unused function/class/method" findings — useful for
88
+ dunder methods, `main`, test hooks (`test_*`, `setUp`), and similar
89
+ intentionally-unreferenced symbols.
90
+
91
+ ## Development
92
+
93
+ Run tests with coverage and generate an HTML report:
94
+
95
+ ```powershell
96
+ poetry run pytest --cov=code_prune tests --cov-report html
97
+ ```
98
+
99
+ Format and lint the code:
100
+
101
+ ```powershell
102
+ poetry run black code_prune; poetry run pylint code_prune
103
+ ```
104
+
105
+ ## License
106
+
107
+ This project is licensed under the [MIT License](LICENSE).
@@ -0,0 +1,9 @@
1
+ # Gitignore-style patterns for files/directories to exclude from scanning.
2
+ # One pattern per line. Lines starting with # are comments. Empty lines are ignored.
3
+ .git/
4
+ node_modules/
5
+ dist/
6
+ build/
7
+ __pycache__/
8
+ .venv/
9
+ bin/
@@ -0,0 +1,25 @@
1
+ """
2
+ Package initialization for code_prune.
3
+
4
+ Bootstraps the configuration directory and logging setup.
5
+
6
+ Author: Ron Webb
7
+ Since: 1.0.0
8
+ """
9
+
10
+ from env_dir_bootstrap import EnvDirBootstrap
11
+
12
+ __app_name__ = "code-prune"
13
+ __version__ = "1.0.0"
14
+
15
+ _bootstrapper = EnvDirBootstrap(
16
+ env_var="CODE_PRUNE_CONFIG_DIR",
17
+ resources=["logging.ini", "config.ini", ".codepruneignore", "symbol_ignore"],
18
+ package="code_prune",
19
+ )
20
+
21
+ _bootstrapper.setup()
22
+
23
+ CONF_DIR = str(_bootstrapper.get_dir())
24
+ PATH_IGNORE_PATH = _bootstrapper.resolve(".codepruneignore")
25
+ SYMBOL_IGNORE_PATH = _bootstrapper.resolve("symbol_ignore")