code-prune 1.5.0__tar.gz → 1.6.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.
- {code_prune-1.5.0 → code_prune-1.6.0}/CHANGELOG.md +7 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/PKG-INFO +4 -3
- {code_prune-1.5.0 → code_prune-1.6.0}/README.md +3 -2
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/__init__.py +1 -1
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/language_tables.py +3 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/suppression.py +19 -3
- {code_prune-1.5.0 → code_prune-1.6.0}/pyproject.toml +1 -1
- {code_prune-1.5.0 → code_prune-1.6.0}/LICENSE +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/.codepruneignore +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/cli.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/config.ini +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/config.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/logging.ini +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/parser.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/reporter.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/scanner.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/searcher.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/store.py +0 -0
- {code_prune-1.5.0 → code_prune-1.6.0}/code_prune/symbol_ignore +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code-prune
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Summary: Find unreachable, unused, and obsolete code before it becomes technical debt.
|
|
5
5
|
License: MIT License
|
|
6
6
|
|
|
@@ -56,7 +56,7 @@ Description-Content-Type: text/markdown
|
|
|
56
56
|
|
|
57
57
|
# code-prune
|
|
58
58
|
|
|
59
|
-
[](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [](https://github.com/rcw3bb/code-prune/blob/main/CHANGELOG.md) [](https://www.python.org/) [](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,
|
|
@@ -172,7 +172,8 @@ Overriding members are also never reported as unused symbols: Java `@Override`,
|
|
|
172
172
|
Gosu `override` / `@Override`, TypeScript `override`, and Python `@override` /
|
|
173
173
|
`@typing.override`. In Java and Gosu, declarations annotated with
|
|
174
174
|
`@SuppressWarnings("unused")` or `@SuppressWarnings("all")` (including a class
|
|
175
|
-
annotated that way, which covers all of its members) are skipped as well
|
|
175
|
+
annotated that way, which covers all of its members) are skipped as well, as are
|
|
176
|
+
Gosu declarations annotated with `@Export`.
|
|
176
177
|
|
|
177
178
|
## Development
|
|
178
179
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# code-prune
|
|
2
2
|
|
|
3
|
-
[](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [](https://github.com/rcw3bb/code-prune/blob/main/LICENSE) [](https://github.com/rcw3bb/code-prune/blob/main/CHANGELOG.md) [](https://www.python.org/) [](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,
|
|
@@ -116,7 +116,8 @@ Overriding members are also never reported as unused symbols: Java `@Override`,
|
|
|
116
116
|
Gosu `override` / `@Override`, TypeScript `override`, and Python `@override` /
|
|
117
117
|
`@typing.override`. In Java and Gosu, declarations annotated with
|
|
118
118
|
`@SuppressWarnings("unused")` or `@SuppressWarnings("all")` (including a class
|
|
119
|
-
annotated that way, which covers all of its members) are skipped as well
|
|
119
|
+
annotated that way, which covers all of its members) are skipped as well, as are
|
|
120
|
+
Gosu declarations annotated with `@Export`.
|
|
120
121
|
|
|
121
122
|
## Development
|
|
122
123
|
|
|
@@ -163,6 +163,9 @@ SUPPRESS_WARNINGS_VALUES = frozenset({"unused", "all"})
|
|
|
163
163
|
#: Annotation names marking a method as an override.
|
|
164
164
|
OVERRIDE_ANNOTATION_NAMES = frozenset({"Override"})
|
|
165
165
|
|
|
166
|
+
#: Annotation names marking a declaration as exported (used externally), per language.
|
|
167
|
+
EXPORT_ANNOTATION_NAMES: dict[str, frozenset[str]] = {"Gosu": frozenset({"Export"})}
|
|
168
|
+
|
|
166
169
|
#: Modifier node types marking a declaration as an override, per language.
|
|
167
170
|
OVERRIDE_MODIFIER_TYPES: dict[str, frozenset[str]] = {
|
|
168
171
|
"TypeScript": frozenset({"override_modifier"}),
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
A declaration is exempt when it overrides an inherited member (it is invoked
|
|
4
4
|
through its base type, so it never has a textual usage) or, for Java and Gosu,
|
|
5
5
|
when it (or an enclosing class) carries ``@SuppressWarnings`` with ``"unused"``
|
|
6
|
-
or ``"all"``.
|
|
6
|
+
or ``"all"``, or when a Gosu declaration is annotated ``@Export``.
|
|
7
7
|
|
|
8
8
|
Author: Ron Webb
|
|
9
9
|
Since: 1.5.0
|
|
@@ -15,6 +15,7 @@ from tree_sitter import Node # type: ignore[import-untyped]
|
|
|
15
15
|
|
|
16
16
|
from .language_tables import (
|
|
17
17
|
ANNOTATION_NODE_TYPES,
|
|
18
|
+
EXPORT_ANNOTATION_NAMES,
|
|
18
19
|
OVERRIDE_ANNOTATION_NAMES,
|
|
19
20
|
OVERRIDE_MODIFIER_TYPES,
|
|
20
21
|
SUPPRESS_WARNINGS_NAME,
|
|
@@ -181,12 +182,27 @@ def _is_override(node: Node, source_bytes: bytes, language: str) -> bool:
|
|
|
181
182
|
)
|
|
182
183
|
|
|
183
184
|
|
|
185
|
+
def _is_exported(node: Node, source_bytes: bytes, language: str) -> bool:
|
|
186
|
+
"""Return whether *node* carries an ``@Export``-style annotation.
|
|
187
|
+
|
|
188
|
+
Author: Ron Webb
|
|
189
|
+
Since: 1.6.0
|
|
190
|
+
"""
|
|
191
|
+
export_names = EXPORT_ANNOTATION_NAMES.get(language, frozenset())
|
|
192
|
+
return any(
|
|
193
|
+
_annotation_name(annotation, source_bytes) in export_names
|
|
194
|
+
for annotation in _annotations(node, language)
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
|
|
184
198
|
def is_exempt_symbol(node: Node, source_bytes: bytes, language: str) -> bool:
|
|
185
199
|
"""Return whether the declaration *node* must not be an unused-symbol finding.
|
|
186
200
|
|
|
187
201
|
Author: Ron Webb
|
|
188
202
|
Since: 1.5.0
|
|
189
203
|
"""
|
|
190
|
-
return
|
|
191
|
-
node, source_bytes, language
|
|
204
|
+
return (
|
|
205
|
+
_is_override(node, source_bytes, language)
|
|
206
|
+
or _is_exported(node, source_bytes, language)
|
|
207
|
+
or _is_suppressed(node, source_bytes, language)
|
|
192
208
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|