cytoscnpy 1.2.2__cp39-cp39-win_amd64.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.
cytoscnpy/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from .cytoscnpy import run
2
+
3
+ __all__ = ["run"]
cytoscnpy/__main__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+ if __name__ == "__main__":
4
+ main()
cytoscnpy/cli.py ADDED
@@ -0,0 +1,15 @@
1
+ import sys
2
+ from cytoscnpy import run
3
+
4
+
5
+ def main():
6
+ args = sys.argv[1:]
7
+ try:
8
+ rc = run(args)
9
+ raise SystemExit(int(rc))
10
+ except Exception as e:
11
+ print(f"cytoscnpy error: {e}", file=sys.stderr)
12
+ raise SystemExit(1)
13
+
14
+ if __name__ == "__main__":
15
+ main()
Binary file
@@ -0,0 +1,337 @@
1
+ Metadata-Version: 2.4
2
+ Name: cytoscnpy
3
+ Version: 1.2.2
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: 3
6
+ Classifier: Programming Language :: Python :: 3.8
7
+ Classifier: Programming Language :: Python :: 3.9
8
+ Classifier: Programming Language :: Python :: 3.10
9
+ Classifier: Programming Language :: Python :: 3.11
10
+ Classifier: Programming Language :: Python :: 3.12
11
+ Classifier: Programming Language :: Python :: 3.13
12
+ Classifier: Programming Language :: Python :: Implementation :: CPython
13
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
14
+ Classifier: Topic :: Software Development :: Quality Assurance
15
+ Classifier: Topic :: Software Development :: Testing
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: Apache Software License
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Dist: pytest>=7.0 ; extra == 'dev'
20
+ Requires-Dist: pytest-cov>=4.0 ; extra == 'dev'
21
+ Requires-Dist: ruff ; extra == 'dev'
22
+ Requires-Dist: tomli ; python_full_version < '3.11' and extra == 'dev'
23
+ Requires-Dist: trove-classifiers ; extra == 'dev'
24
+ Requires-Dist: mkdocs-material>=9.5.0 ; extra == 'docs'
25
+ Requires-Dist: mkdocs-minify-plugin>=0.8.0 ; extra == 'docs'
26
+ Provides-Extra: dev
27
+ Provides-Extra: docs
28
+ Summary: High-performance dead code elimination analysis tool for Python.
29
+ Requires-Python: >=3.8
30
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
31
+
32
+ # CytoScnPy - High-Performance Python Static Analysis
33
+
34
+ [![CI](https://github.com/djinn09/CytoScnPy/actions/workflows/test-ci.yml/badge.svg)](https://github.com/djinn09/CytoScnPy/actions/workflows/test-ci.yml)
35
+ [![Coverage](https://github.com/djinn09/CytoScnPy/actions/workflows/coverage.yml/badge.svg)](https://github.com/djinn09/CytoScnPy/actions/workflows/coverage.yml)
36
+ [![codecov](https://codecov.io/gh/djinn09/CytoScnPy/branch/main/graph/badge.svg)](https://codecov.io/gh/djinn09/CytoScnPy)
37
+ [![Security Audit](https://github.com/djinn09/CytoScnPy/actions/workflows/security.yml/badge.svg)](https://github.com/djinn09/CytoScnPy/actions/workflows/security.yml)
38
+ [![Docs](https://github.com/djinn09/CytoScnPy/actions/workflows/docs.yml/badge.svg)](https://github.com/djinn09/CytoScnPy/actions/workflows/docs.yml)
39
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
40
+ [![Version](https://img.shields.io/badge/version-1.2.2-green.svg)](https://github.com/djinn09/CytoScnPy)
41
+
42
+ A fast static analysis tool for Python codebases, powered by Rust with hybrid Python integration. Detects dead code, security vulnerabilities (including taint analysis), and code quality issues with extreme speed. Code quality metrics are also provided.
43
+
44
+ ## Why CytoScnPy?
45
+
46
+ - **Blazing Fast**: Faster in dead code detection.
47
+ - **Memory Efficient**: Uses less memory.
48
+ - **Comprehensive**: Dead code, secrets, security, taint analysis, quality metrics
49
+ - **Framework Aware**: Flask, Django, FastAPI, Pydantic, Azure Functions
50
+ - **Benchmarked**: Continuous benchmarking with 135-item ground truth suite
51
+
52
+ ## Installation
53
+
54
+ **Linux / macOS:**
55
+
56
+ ```bash
57
+ # Install
58
+ curl -fsSL https://raw.githubusercontent.com/djinn09/CytoScnPy/main/install.sh | bash
59
+ ```
60
+
61
+ **Windows (PowerShell):**
62
+
63
+ ```powershell
64
+ # Install
65
+ irm https://raw.githubusercontent.com/djinn09/CytoScnPy/main/install.ps1 | iex
66
+ ```
67
+
68
+ **Via Pip:**
69
+
70
+ ```bash
71
+ pip install cytoscnpy
72
+ ```
73
+
74
+ **From Source:**
75
+
76
+ ```bash
77
+ git clone https://github.com/djinn09/CytoScnPy.git
78
+ cd CytoScnPy
79
+ pip install maturin
80
+ maturin develop -m cytoscnpy/Cargo.toml
81
+ ```
82
+
83
+ ### MCP Server (for AI Assistants)
84
+
85
+ CytoScnPy includes an MCP server for AI assistant integration:
86
+
87
+ ```bash
88
+ # Start MCP server (after pip install)
89
+ cytoscnpy mcp-server
90
+ ```
91
+
92
+ For Claude Desktop, Cursor, or GitHub Copilot configuration, see the **[MCP Server Documentation](cytoscnpy-mcp/README.md)**.
93
+
94
+ ## Features
95
+
96
+ - **Dead Code Detection**: Unused functions, classes, imports, and variables with cross-module tracking.
97
+ - **Cascading Detection**: Methods inside unused classes are automatically flagged as unused.
98
+ - **Auto-Fix**: Remove dead code automatically with `--fix` (preview by default, use `--apply` to execute).
99
+ - **Clone Detection**: Find duplicate code with `--clones`.
100
+ - **Security Analysis**: Taint analysis (SQLi, XSS), secret scanning (API keys, suspicious variables), and dangerous code patterns (`eval`, `exec`).
101
+ - **Code Quality Metrics**: Cyclomatic complexity, Halstead metrics, Maintainability Index, and raw metrics (LOC, SLOC).
102
+ - **Framework Support**: Native understanding of Flask, Django, FastAPI, Pydantic, and Azure Functions v2 patterns.
103
+ - **Smart Heuristics**: Handles dataclasses, `__all__` exports, visitor patterns, and dynamic attributes intelligently.
104
+ - **Cross-File Detection**: Tracks symbol usage across the entire codebase, including nested packages and complex import chains, to ensure code used in other modules is never incorrectly flagged.
105
+
106
+ ## Usage
107
+
108
+ > [!IMPORTANT] **Behavioral Change**: Starting from version 1.2.2, tests are **excluded by default** across both the CLI and the library API to reduce noise in production analysis. Use the `--include-tests` flag or set `include_tests = true` in your configuration to scan test files.
109
+
110
+ ### Command Line
111
+
112
+ ```bash
113
+ cytoscnpy [PATHS]... [OPTIONS]
114
+ ```
115
+
116
+ **Examples:**
117
+
118
+ ```bash
119
+ # Dead code analysis
120
+ cytoscnpy . # Analyze current directory
121
+ cytoscnpy /path/to/project --json # JSON output for CI/CD
122
+
123
+ # Security checks (short flags: -s, -d, -q)
124
+ cytoscnpy . --secrets --danger --quality
125
+ cytoscnpy . -s -d -q # Same with short flags
126
+
127
+ # Confidence threshold (0-100)
128
+ cytoscnpy . --confidence 80
129
+
130
+ # Path filtering
131
+ cytoscnpy . --exclude-folder venv --exclude-folder build
132
+ cytoscnpy . --include-folder specific_venv # Override defaults
133
+ cytoscnpy . --include-tests
134
+
135
+ # Jupyter notebooks
136
+ cytoscnpy . --include-ipynb --ipynb-cells
137
+
138
+ # Clone detection (find duplicate code)
139
+ cytoscnpy . --clones --clone-similarity 0.8
140
+
141
+ # Auto-fix dead code (preview first, then apply)
142
+ cytoscnpy . --fix # Preview changes (dry-run by default)
143
+ cytoscnpy . --fix --apply # Apply changes
144
+ cytoscnpy . --fix -a # Apply changes (short flag)
145
+
146
+ # Generate HTML report (quality auto-enabled; add --secrets --danger for security)
147
+ cytoscnpy . --html --secrets --danger
148
+ ```
149
+
150
+ **Options:**
151
+
152
+ | Flag | Description |
153
+ | ------------------------ | ------------------------------------------------ |
154
+ | `-c, --confidence <N>` | Set confidence threshold (0-100) |
155
+ | `--root <PATH>` | Project root for analysis (CI/CD mode) |
156
+ | `-s, --secrets` | Scan for API keys, tokens, credentials |
157
+ | `-d, --danger` | Scan for dangerous code + taint analysis |
158
+ | `-q, --quality` | Scan for code quality issues |
159
+ | `-n, --no-dead` | Skip dead code detection (security/quality only) |
160
+ | `--html` | Generate HTML report (auto-enables quality) |
161
+ | `--json` | Output results as JSON |
162
+ | `-v, --verbose` | Enable verbose output for debugging |
163
+ | `--quiet` | Quiet mode: summary only, no tables |
164
+ | `--include-tests` | Include test files in analysis |
165
+ | `--exclude-folder <DIR>` | Exclude specific folders |
166
+ | `--include-folder <DIR>` | Force include folders |
167
+ | `--include-ipynb` | Include Jupyter notebooks |
168
+ | `--ipynb-cells` | Report findings per notebook cell |
169
+ | `--clones` | Detect duplicate code |
170
+ | `--clone-similarity <N>` | Clone similarity threshold (0.0-1.0) |
171
+ | `--fix` | Preview dead code removal (dry-run by default) |
172
+ | `-a, --apply` | Apply --fix changes to files |
173
+
174
+ **CI/CD Gate Options:**
175
+
176
+ | Flag | Description |
177
+ | ---------------------- | ------------------------------------------ |
178
+ | `--fail-threshold <N>` | Exit code 1 if unused code % > N |
179
+ | `--max-complexity <N>` | Exit code 1 if any function complexity > N |
180
+ | `--min-mi <N>` | Exit code 1 if maintainability index < N |
181
+ | `--fail-on-quality` | Exit code 1 if any quality issues found |
182
+ | `--max-nesting <N>` | Exit code 1 if any block nesting > N |
183
+ | `--max-args <N>` | Exit code 1 if any function has > N args |
184
+ | `--max-lines <N>` | Exit code 1 if any function has > N lines |
185
+
186
+ > **Full CLI Reference:** See [docs/CLI.md](docs/CLI.md) for complete command documentation.
187
+
188
+ ### Metric Subcommands
189
+
190
+ ```bash
191
+ cytoscnpy raw . # Raw Metrics (LOC, SLOC, Comments)
192
+ cytoscnpy cc . # Cyclomatic Complexity
193
+ cytoscnpy hal . # Halstead Metrics
194
+ cytoscnpy mi . # Maintainability Index
195
+ cytoscnpy stats . --all # Full project report (secrets, danger, quality)
196
+ cytoscnpy stats . --all -o report.md # Save report to file
197
+ cytoscnpy files . # Per-file metrics table
198
+ ```
199
+
200
+ > **Tip**: Add `--json` for machine-readable output, `--exclude-folder <DIR>` to skip directories globally, or `--ignore <PATTERN>` for subcommand-specific glob filtering.
201
+
202
+ ### Feature Flags
203
+
204
+ The crate supports experimental features that can be enabled at compile time:
205
+
206
+ | Feature | Description |
207
+ | ------- | ------------------------------------------------------------------------------------------- |
208
+ | `cfg` | Enables Control Flow Graph (CFG) construction and behavioral validation for clone detection |
209
+
210
+ To build with a feature enabled:
211
+
212
+ ```bash
213
+ cargo build --features cfg
214
+ ```
215
+
216
+ ## ⚙️ Configuration
217
+
218
+ Create `.cytoscnpy.toml` (uses `[cytoscnpy]`) or add to `pyproject.toml` (uses `[tool.cytoscnpy]`):
219
+
220
+ **`.cytoscnpy.toml` example:**
221
+
222
+ ```toml
223
+ [cytoscnpy]
224
+ # General Settings
225
+ confidence = 60 # Minimum confidence threshold (0-100)
226
+ exclude_folders = ["venv", ".tox", "build", "node_modules", ".git"]
227
+ include_folders = ["src", "tests"] # Optional: whitelist folders
228
+ include_tests = false # Note: include_ipynb and ipynb_cells are CLI-only (use flags)
229
+
230
+ # Analysis Features
231
+ secrets = true
232
+ danger = true
233
+ quality = true
234
+
235
+ # Fail Threshold (exit code 1 if exceeded)
236
+ fail_threshold = 10.0 # Fail if >10% of code is unused
237
+ # fail_threshold = 0.0 # Zero tolerance: fail on any unused code
238
+
239
+ # Code Quality Thresholds
240
+ max_lines = 100 # Max lines per function
241
+ max_args = 5 # Max arguments per function
242
+ max_complexity = 10 # Max cyclomatic complexity
243
+ max_nesting = 4 # Max indentation depth
244
+ min_mi = 65.0 # Minimum Maintainability Index
245
+ ignore = ["R001"] # Ignore specific rule IDs
246
+
247
+ # Advanced Secret Scanning
248
+ [cytoscnpy.secrets_config]
249
+ entropy_enabled = true
250
+ entropy_threshold = 4.5 # Higher = more random (API keys usually >4.0)
251
+ min_length = 16 # Min length to check for entropy
252
+ scan_comments = true # Scan comments for secrets
253
+ skip_docstrings = false # Skip docstrings in entropy scanning
254
+ min_score = 50 # Minimum confidence score (0-100)
255
+ suspicious_names = ["db_config", "oauth_token"] # Add custom suspicious variable names
256
+
257
+ # Custom Secret Patterns
258
+ [[cytoscnpy.secrets_config.patterns]]
259
+ name = "Slack Token"
260
+ regex = "xox[baprs]-([0-9a-zA-Z]{10,48})"
261
+ severity = "HIGH"
262
+ ```
263
+
264
+ > **Note**: Notebook options (`include_ipynb`, `ipynb_cells`) are currently CLI-only but will be added to the configuration file in a future release.
265
+
266
+ ### CI/CD Quality Gates
267
+
268
+ Configure quality gates for CI/CD pipelines. Set thresholds and the CLI exits with code `1` if exceeded.
269
+
270
+ **CLI Flags:**
271
+
272
+ ```bash
273
+ # Unused code percentage gate
274
+ cytoscnpy . --fail-threshold 5 # Fail if >5% unused
275
+
276
+ # Complexity gate
277
+ cytoscnpy . --max-complexity 10 # Fail if any function >10
278
+
279
+ # Maintainability Index gate
280
+ cytoscnpy . --min-mi 40 # Fail if MI <40
281
+
282
+ # Quiet mode for clean CI output
283
+ cytoscnpy . --fail-threshold 5 --quiet
284
+ ```
285
+
286
+ **Priority:** CLI flag > config file > environment variable > default
287
+
288
+ **Environment Variable:** `CYTOSCNPY_FAIL_THRESHOLD=5.0`
289
+
290
+ ## Performance
291
+
292
+ ### Accuracy (Benchmark Suite: 135 items)
293
+
294
+ | Detection Type | Precision | Recall | F1 Score |
295
+ | -------------- | --------- | -------- | -------- |
296
+ | Classes | 0.73 | 0.79 | **0.76** |
297
+ | Functions | 0.71 | 0.74 | **0.73** |
298
+ | Methods | **0.86** | **0.93** | **0.89** |
299
+ | Imports | 0.67 | 0.40 | 0.50 |
300
+ | Variables | 0.30 | 0.15 | 0.20 |
301
+ | **Overall** | **0.71** | **0.64** | **0.68** |
302
+
303
+ > See [benchmark/README.md](benchmark/README.md) for detailed comparison against Vulture, Flake8, Pylint, Ruff, and others.
304
+
305
+ ## Architecture
306
+
307
+ See [cytoscnpy/README.md](cytoscnpy/README.md#architecture) for detailed architecture and technology stack information.
308
+
309
+ ## Testing
310
+
311
+ See [CONTRIBUTING.md](CONTRIBUTING.md#testing) for testing instructions.
312
+
313
+ ## Contributing
314
+
315
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
316
+
317
+ ## License
318
+
319
+ Apache-2.0 License - see [License](License) file for details.
320
+
321
+ ## Links
322
+
323
+ - **Documentation**: [CytoScnPy](https://djinn09.github.io/CytoScnPy/)
324
+ - **PyPI**: [PyPi](https://pypi.org/project/cytoscnpy/)
325
+ - **VS Code Extension**: [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=djinn09.cytoscnpy)
326
+ - **Rust Core Documentation**: [cytoscnpy/README.md](cytoscnpy/README.md)
327
+ - **Benchmarks & Accuracy**: [benchmark/README.md](benchmark/README.md)
328
+ - **Roadmap**: [docs/roadmap.md](docs/roadmap.md)
329
+ - **Contributing**: [CONTRIBUTING.md](CONTRIBUTING.md)
330
+
331
+ ## References
332
+
333
+ CytoScnPy's design and implementation are inspired by:
334
+
335
+ - [**Skylos**](https://github.com/duriantaco/skylos)
336
+ - [**Radon**](https://github.com/rubik/radon)
337
+
@@ -0,0 +1,8 @@
1
+ cytoscnpy-1.2.2.dist-info/METADATA,sha256=0rbO3ulDbGuyyuPODBpKYBiyItk78rF40nLPbt4j7as,14384
2
+ cytoscnpy-1.2.2.dist-info/WHEEL,sha256=cJkMTYTklyOQ5jua9KOOIaaSma7Th-zqFU6TpVB6bCU,95
3
+ cytoscnpy-1.2.2.dist-info/entry_points.txt,sha256=PXlUPRKLQimXRY6EUfxByP0J0c-zrGLMvlbMhDjsbWM,47
4
+ cytoscnpy/__init__.py,sha256=aXF6AHrXeMpWTNpvml_fQYrva-zKz79Z9YvTjN3NBrE,47
5
+ cytoscnpy/__main__.py,sha256=EClCwCzb6h6YBpt0hrnG4h0mlNhNePyg_xBNNSVm1os,65
6
+ cytoscnpy/cli.py,sha256=lQf5F1uaDserI1ITwmo7-ERoHC1VhhrVJgAp0yCGaIc,306
7
+ cytoscnpy/cytoscnpy.cp39-win_amd64.pyd,sha256=6GZsF-Icf4PlK7FmyQB0wYpcALKSEPePx5iTFR1abtI,4705792
8
+ cytoscnpy-1.2.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.10.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-cp39-win_amd64
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cytoscnpy=cytoscnpy.cli:main