code-prune 1.0.0__tar.gz → 1.2.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,69 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0 - 2026-11-15
4
+
5
+ ### Added
6
+
7
+ - `--search-path`: files and/or directories (separated by `;`) searched
8
+ textually for each `unused-symbol` candidate. Symbols found there are no
9
+ longer reported. Classes and functions/methods are both matched with a
10
+ whole-word regex; a method additionally requires its enclosing class's name
11
+ to be found in the same file. The symbol's own file is ignored and
12
+ `.codepruneignore` rules apply.
13
+ - `--search-ext`: extensions of the files searched in `--search-path`
14
+ (default: every text file). Requires `--search-path`.
15
+
16
+ ## 1.1.0 - 2026-11-05
17
+
18
+ ### Added
19
+
20
+ - `todo-marker` category: `TODO`/`FIXME`/`XXX` comments are reported separately
21
+ from `obsolete` since they are not necessarily obsolete.
22
+ - `--categories` now accepts `unused-import`, `unused-local` and `unused-symbol`
23
+ explicitly; `unused` remains as shorthand for all three.
24
+ - `category-counts` in the JSON report, and per-category counts in the HTML
25
+ report category filter dropdown.
26
+ - A `.codepruneignore` in the target path extends the configured ignore
27
+ patterns; it is not affected by `config.ini`.
28
+
29
+ ### Changed
30
+
31
+ - The HTML report's category filter is now a dropdown of the categories present
32
+ in the report (with counts).
33
+ - Only supported source files are read; all other files are skipped.
34
+ - `obsolete` now covers `@deprecated`-style markers and `deprecated` comments
35
+ only (TODO/FIXME/XXX moved to `todo-marker`).
36
+ - README: installation uses `pip install code-prune`; Poetry instructions moved
37
+ to a Development section.
38
+
39
+ ### Fixed
40
+
41
+ - Comments following a terminating statement are no longer reported as
42
+ unreachable code.
43
+ - Documentation comments (Javadoc/JSDoc `/** ... */`) are no longer reported as
44
+ commented-out code.
45
+
46
+ ## 1.0.0 - 2026-11-01
47
+
48
+ ### Added
49
+
50
+ - Core dead-code CLI: `code-prune <path> [options]`, built on Click and Rich,
51
+ mirroring the `litscan` basis project's architecture.
52
+ - Tree-sitter based detection across Python, JavaScript, TypeScript, Java,
53
+ and Gosu for five categories of findings: unreachable code, unused imports
54
+ & local variables, cross-file unused functions/classes/methods, obsolete
55
+ (`@deprecated`/TODO/FIXME) markers, and commented-out code.
56
+ - `config.ini` with an `[override] ignore-file` setting, a bundled
57
+ `.codepruneignore` (gitignore-style path exclusions), and a bundled
58
+ `symbol_ignore` (regex symbol-name exclusions for unused-symbol findings).
59
+ - SQLite-backed `SessionStore` for concurrent per-file scanning and a
60
+ SQL-aggregated cross-file "unused symbol" resolution pass.
61
+ - JSON and HTML report output via `--format`.
62
+
63
+ ### Fixed
64
+
65
+ - Upgraded `tree-sitter-gosu` to `>=0.3.0,<0.4.0`, which decomposes `${...}`
66
+ string interpolation into real `interpolation`/`identifier` nodes. This
67
+ resolves a false-positive `unused-local`/`unused-import`/`unused-symbol`
68
+ finding for Gosu names referenced only inside string interpolation (e.g.
69
+ `"... ${myVar} ..."`).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code-prune
3
- Version: 1.0.0
3
+ Version: 1.2.0
4
4
  Summary: Find unreachable, unused, and obsolete code before it becomes technical debt.
5
5
  License: MIT License
6
6
 
@@ -27,7 +27,7 @@ License-File: LICENSE
27
27
  Keywords: cli,static-analysis,dead-code,unused-code,tree-sitter,code-quality
28
28
  Author: Ron Webb
29
29
  Requires-Python: >=3.14
30
- Classifier: Development Status :: 4 - Beta
30
+ Classifier: Development Status :: 5 - Production/Stable
31
31
  Classifier: Environment :: Console
32
32
  Classifier: Intended Audience :: Developers
33
33
  Classifier: Operating System :: OS Independent
@@ -56,7 +56,7 @@ Description-Content-Type: text/markdown
56
56
 
57
57
  # code-prune
58
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/)
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.2.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
60
 
61
61
 
62
62
  A CLI tool that scans a codebase for unreachable, unused, and obsolete code,
@@ -65,20 +65,26 @@ helping you find dead code before it becomes technical debt.
65
65
  ## Features
66
66
 
67
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,
68
+ and reports six categories of findings across **Python, JavaScript,
69
69
  TypeScript, Java, and Gosu**:
70
70
 
71
71
  - **Unreachable code** — statements after `return`/`raise`/`throw`/`break`/
72
72
  `continue`, and `if` branches whose condition is a constant falsy literal
73
- (`False`/`false`/`0`).
73
+ (`False`/`false`/`0`). Comments are never reported as unreachable.
74
74
  - **Unused imports & local variables** — per-file, syntactic detection of
75
75
  bindings that are never referenced again in the same file.
76
76
  - **Unused functions/classes/methods** — cross-file detection of definitions
77
77
  that are never referenced anywhere in the scanned project.
78
78
  - **Obsolete markers** — `@deprecated`/`@Deprecated`-style decorators and
79
- annotations, plus `TODO`/`FIXME`/`XXX` comment tags.
79
+ annotations, plus comments mentioning `deprecated`.
80
+ - **TODO markers** — `TODO`/`FIXME`/`XXX` comment tags (not necessarily
81
+ obsolete, so reported separately).
80
82
  - **Commented-out code** — comments whose content heuristically resembles
81
- source code.
83
+ source code. Documentation comments (Javadoc/JSDoc `/** ... */`) and Python
84
+ docstrings are not treated as commented-out code.
85
+
86
+ Only supported files (`.py`, `.pyi`, `.js`, `.mjs`, `.cjs`, `.ts`, `.tsx`,
87
+ `.java`, `.gs`, `.gsx`) are read; every other file is skipped.
82
88
 
83
89
  > Detection is heuristic and syntactic rather than a full scope- or
84
90
  > call-graph-aware analysis — treat findings as a starting point for review,
@@ -87,39 +93,50 @@ TypeScript, Java, and Gosu**:
87
93
  ## Requirements
88
94
 
89
95
  - Python `>=3.14`
90
- - Poetry `2.2`
91
96
 
92
97
  ## Installation
93
98
 
94
99
  ```powershell
95
- poetry install
100
+ pip install code-prune
96
101
  ```
97
102
 
98
103
  ## Usage
99
104
 
100
105
  ```powershell
101
- poetry run code-prune <path> [options]
106
+ code-prune <path> [options]
102
107
  ```
103
108
 
109
+ `<path>` may be a file, a directory, or several of them separated by `;`.
110
+
104
111
  Common options:
105
112
 
106
113
  | Option | Description |
107
114
  |-------------------|------------------------------------------------------------------------------|
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). |
115
+ | `--ext` | Comma-separated extensions to include (e.g. `py,js,ts,java,gs,gsx`). Omit to scan every supported file. |
116
+ | `--categories` | Comma-separated categories to report: `unreachable`, `unused-import`, `unused-local`, `unused-symbol`, `obsolete`, `todo-marker`, `commented-out`. `unused` is shorthand for all three `unused-*` categories (default: all). |
110
117
  | `--format` | Output format: `json`, `html`, or `all` (default: `json`). |
111
118
  | `--output` | Base output filename without extension (default: `code-prune-output`). |
112
119
  | `--output-dir` | Directory for the report file(s) (default: `reports`). |
113
120
  | `--workers` | Number of parallel worker threads used to scan files. |
114
121
  | `--db` | Path to the SQLite scratch database used during a scan run. |
115
122
  | `--target-list` | Treat `path` as a file listing target paths, one per line. |
123
+ | `--search-path` | Files and/or directories (separated by `;`) searched textually for each `unused-symbol` candidate; a symbol found there is not reported. Classes and functions/methods are both matched by a whole-word regex; a method additionally requires its enclosing class's name to appear in the same file. The symbol's own file is skipped and `.codepruneignore` rules apply. |
124
+ | `--search-ext` | Comma-separated extensions of the files searched in `--search-path` (e.g. `xml,json`). Omit to search every text file. Requires `--search-path`. |
116
125
 
117
126
  Example:
118
127
 
119
128
  ```powershell
120
- poetry run code-prune src --categories unreachable,unused --format all
129
+ code-prune src --categories unreachable,unused-import,todo-marker --format all
130
+ code-prune src --categories unused-symbol --search-path "templates;../other-repo" --search-ext xml,json,py
121
131
  ```
122
132
 
133
+ ### Reports
134
+
135
+ Both report formats include the number of findings per category: the JSON
136
+ report has a `category-counts` object, and the HTML report shows the counts in
137
+ a category dropdown filter listing the categories present in the report. The
138
+ HTML summary line shows only the total number of findings.
139
+
123
140
  ## Configuration
124
141
 
125
142
  Logging is bootstrapped via `env-dir-bootstrap`. Set the `CODE_PRUNE_CONFIG_DIR`
@@ -130,13 +147,17 @@ resolve `logging.ini`, `config.ini`, `.codepruneignore`, and `symbol_ignore`.
130
147
 
131
148
  `.codepruneignore` holds gitignore-style patterns for files/directories to
132
149
  exclude from scanning (mirroring `.gitignore` syntax). Override the filename
133
- via `config.ini`:
150
+ used in the configuration directory via `config.ini`:
134
151
 
135
152
  ```ini
136
153
  [override]
137
154
  ignore-file = .codepruneignore
138
155
  ```
139
156
 
157
+ In addition, a `.codepruneignore` placed in the target path (the scanned
158
+ directory, or the directory containing a scanned file) extends those patterns.
159
+ It always uses that fixed name and is not affected by `config.ini`.
160
+
140
161
  ### Ignoring symbol names
141
162
 
142
163
  `symbol_ignore` holds one regex pattern per line, matched against symbol
@@ -146,6 +167,20 @@ intentionally-unreferenced symbols.
146
167
 
147
168
  ## Development
148
169
 
170
+ Development uses [Poetry](https://python-poetry.org/) `2.2`.
171
+
172
+ Install the project and its dev dependencies:
173
+
174
+ ```powershell
175
+ poetry install
176
+ ```
177
+
178
+ Run the CLI from the working tree:
179
+
180
+ ```powershell
181
+ poetry run code-prune <path> [options]
182
+ ```
183
+
149
184
  Run tests with coverage and generate an HTML report:
150
185
 
151
186
  ```powershell
@@ -1,6 +1,6 @@
1
1
  # code-prune
2
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/)
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.2.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
4
 
5
5
 
6
6
  A CLI tool that scans a codebase for unreachable, unused, and obsolete code,
@@ -9,20 +9,26 @@ helping you find dead code before it becomes technical debt.
9
9
  ## Features
10
10
 
11
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,
12
+ and reports six categories of findings across **Python, JavaScript,
13
13
  TypeScript, Java, and Gosu**:
14
14
 
15
15
  - **Unreachable code** — statements after `return`/`raise`/`throw`/`break`/
16
16
  `continue`, and `if` branches whose condition is a constant falsy literal
17
- (`False`/`false`/`0`).
17
+ (`False`/`false`/`0`). Comments are never reported as unreachable.
18
18
  - **Unused imports & local variables** — per-file, syntactic detection of
19
19
  bindings that are never referenced again in the same file.
20
20
  - **Unused functions/classes/methods** — cross-file detection of definitions
21
21
  that are never referenced anywhere in the scanned project.
22
22
  - **Obsolete markers** — `@deprecated`/`@Deprecated`-style decorators and
23
- annotations, plus `TODO`/`FIXME`/`XXX` comment tags.
23
+ annotations, plus comments mentioning `deprecated`.
24
+ - **TODO markers** — `TODO`/`FIXME`/`XXX` comment tags (not necessarily
25
+ obsolete, so reported separately).
24
26
  - **Commented-out code** — comments whose content heuristically resembles
25
- source code.
27
+ source code. Documentation comments (Javadoc/JSDoc `/** ... */`) and Python
28
+ docstrings are not treated as commented-out code.
29
+
30
+ Only supported files (`.py`, `.pyi`, `.js`, `.mjs`, `.cjs`, `.ts`, `.tsx`,
31
+ `.java`, `.gs`, `.gsx`) are read; every other file is skipped.
26
32
 
27
33
  > Detection is heuristic and syntactic rather than a full scope- or
28
34
  > call-graph-aware analysis — treat findings as a starting point for review,
@@ -31,39 +37,50 @@ TypeScript, Java, and Gosu**:
31
37
  ## Requirements
32
38
 
33
39
  - Python `>=3.14`
34
- - Poetry `2.2`
35
40
 
36
41
  ## Installation
37
42
 
38
43
  ```powershell
39
- poetry install
44
+ pip install code-prune
40
45
  ```
41
46
 
42
47
  ## Usage
43
48
 
44
49
  ```powershell
45
- poetry run code-prune <path> [options]
50
+ code-prune <path> [options]
46
51
  ```
47
52
 
53
+ `<path>` may be a file, a directory, or several of them separated by `;`.
54
+
48
55
  Common options:
49
56
 
50
57
  | Option | Description |
51
58
  |-------------------|------------------------------------------------------------------------------|
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). |
59
+ | `--ext` | Comma-separated extensions to include (e.g. `py,js,ts,java,gs,gsx`). Omit to scan every supported file. |
60
+ | `--categories` | Comma-separated categories to report: `unreachable`, `unused-import`, `unused-local`, `unused-symbol`, `obsolete`, `todo-marker`, `commented-out`. `unused` is shorthand for all three `unused-*` categories (default: all). |
54
61
  | `--format` | Output format: `json`, `html`, or `all` (default: `json`). |
55
62
  | `--output` | Base output filename without extension (default: `code-prune-output`). |
56
63
  | `--output-dir` | Directory for the report file(s) (default: `reports`). |
57
64
  | `--workers` | Number of parallel worker threads used to scan files. |
58
65
  | `--db` | Path to the SQLite scratch database used during a scan run. |
59
66
  | `--target-list` | Treat `path` as a file listing target paths, one per line. |
67
+ | `--search-path` | Files and/or directories (separated by `;`) searched textually for each `unused-symbol` candidate; a symbol found there is not reported. Classes and functions/methods are both matched by a whole-word regex; a method additionally requires its enclosing class's name to appear in the same file. The symbol's own file is skipped and `.codepruneignore` rules apply. |
68
+ | `--search-ext` | Comma-separated extensions of the files searched in `--search-path` (e.g. `xml,json`). Omit to search every text file. Requires `--search-path`. |
60
69
 
61
70
  Example:
62
71
 
63
72
  ```powershell
64
- poetry run code-prune src --categories unreachable,unused --format all
73
+ code-prune src --categories unreachable,unused-import,todo-marker --format all
74
+ code-prune src --categories unused-symbol --search-path "templates;../other-repo" --search-ext xml,json,py
65
75
  ```
66
76
 
77
+ ### Reports
78
+
79
+ Both report formats include the number of findings per category: the JSON
80
+ report has a `category-counts` object, and the HTML report shows the counts in
81
+ a category dropdown filter listing the categories present in the report. The
82
+ HTML summary line shows only the total number of findings.
83
+
67
84
  ## Configuration
68
85
 
69
86
  Logging is bootstrapped via `env-dir-bootstrap`. Set the `CODE_PRUNE_CONFIG_DIR`
@@ -74,13 +91,17 @@ resolve `logging.ini`, `config.ini`, `.codepruneignore`, and `symbol_ignore`.
74
91
 
75
92
  `.codepruneignore` holds gitignore-style patterns for files/directories to
76
93
  exclude from scanning (mirroring `.gitignore` syntax). Override the filename
77
- via `config.ini`:
94
+ used in the configuration directory via `config.ini`:
78
95
 
79
96
  ```ini
80
97
  [override]
81
98
  ignore-file = .codepruneignore
82
99
  ```
83
100
 
101
+ In addition, a `.codepruneignore` placed in the target path (the scanned
102
+ directory, or the directory containing a scanned file) extends those patterns.
103
+ It always uses that fixed name and is not affected by `config.ini`.
104
+
84
105
  ### Ignoring symbol names
85
106
 
86
107
  `symbol_ignore` holds one regex pattern per line, matched against symbol
@@ -90,6 +111,20 @@ intentionally-unreferenced symbols.
90
111
 
91
112
  ## Development
92
113
 
114
+ Development uses [Poetry](https://python-poetry.org/) `2.2`.
115
+
116
+ Install the project and its dev dependencies:
117
+
118
+ ```powershell
119
+ poetry install
120
+ ```
121
+
122
+ Run the CLI from the working tree:
123
+
124
+ ```powershell
125
+ poetry run code-prune <path> [options]
126
+ ```
127
+
93
128
  Run tests with coverage and generate an HTML report:
94
129
 
95
130
  ```powershell
@@ -10,7 +10,7 @@ Since: 1.0.0
10
10
  from env_dir_bootstrap import EnvDirBootstrap
11
11
 
12
12
  __app_name__ = "code-prune"
13
- __version__ = "1.0.0"
13
+ __version__ = "1.2.0"
14
14
 
15
15
  _bootstrapper = EnvDirBootstrap(
16
16
  env_var="CODE_PRUNE_CONFIG_DIR",