# PyReachX
PyReachX is a static code analysis tool that helps identify unreachable code in Python projects. It analyzes your Python codebase to find functions and methods that are never called or accessed.
[![CI](https://github.com/ad3002/pyreachx/actions/workflows/ci.yml/badge.svg)](https://github.com/ad3002/pyreachx/actions/workflows/ci.yml)
[![PyPI version](https://badge.fury.io/py/pyreachx.svg)](https://badge.fury.io/py/pyreachx)
[![codecov](https://codecov.io/gh/ad3002/pyreachx/branch/main/graph/badge.svg)](https://codecov.io/gh/ad3002/pyreachx)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
## Features
- Identifies unreachable functions and methods
- Generates HTML and JSON reports
- Configurable exclusion patterns
- Support for class method analysis
- Command-line interface
- Confidence scoring for identified unreachable code
## Installation
```bash
pip install pyreachx
```
## Usage
### Command Line
```bash
# Basic usage
pyreachx /path/to/your/project
# Specify entry point
pyreachx /path/to/your/project -e module.main
# Custom configuration file
pyreachx /path/to/your/project -c config.yml
# Custom output file
pyreachx /path/to/your/project -o report.html
```
### Configuration
Create a `pyreachx.yml` file to customize the analysis:
```yaml
exclude_patterns:
- "**/test_*.py"
- "**/__init__.py"
ignore_decorators:
- "@property"
- "@staticmethod"
confidence_threshold: 0.8
```
### Python API
```python
from pyreachx import CodeAnalyzer, AnalyzerConfig
# Create configuration
config = AnalyzerConfig.from_file("pyreachx.yml")
# Initialize analyzer
analyzer = CodeAnalyzer(config)
# Run analysis
result = analyzer.analyze("/path/to/project", entry_point="main")
# Generate report
from pyreachx import Reporter
reporter = Reporter(result)
reporter.generate_report("report.html")
```
## Example Output
HTML Report:
```html
<div class='item'>
<strong>module.py</strong> (lines 10-15)<br>
Type: function<br>
Name: unused_function<br>
Confidence: 95%
</div>
```
JSON Report:
```json
{
"unreachable_items": [
{
"file_path": "module.py",
"line_start": 10,
"line_end": 15,
"code_type": "function",
"name": "unused_function",
"confidence": 0.95
}
],
"statistics": {
"total_unreachable_lines": 6,
"files_affected": ["module.py"],
"type_distribution": {
"function": 1
}
}
}
```
## Development
### Setup Development Environment
```bash
# Clone the repository
git clone https://github.com/ad3002/pyreachx.git
cd pyreachx
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e .[test]
```
### Running Tests
```bash
pytest tests/
```
### Code Style
This project uses:
- Black for code formatting
- isort for import sorting
- flake8 for linting
```bash
# Format code
black pyreachx tests
isort pyreachx tests
# Check linting
flake8 pyreachx tests
```
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
- AST module from Python standard library
- NetworkX for dependency graph analysis
- Click for CLI interface
- Jinja2 for report templating
## Project Status
PyReachX is in alpha stage. While it's functional, there might be false positives and edge cases that aren't handled yet. Use with caution in production environments.
Raw data
{
"_id": null,
"home_page": "https://github.com/ad3002/pyreachx",
"name": "pyreachx",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Aleksey Komissarov",
"author_email": "ad3002@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/02/12/717eafedab2823a011361771e059058c5899ee2dd1948eeabe6aaa19c3a4/pyreachx-0.1.0.tar.gz",
"platform": null,
"description": "# PyReachX\n\nPyReachX is a static code analysis tool that helps identify unreachable code in Python projects. It analyzes your Python codebase to find functions and methods that are never called or accessed.\n\n[![CI](https://github.com/ad3002/pyreachx/actions/workflows/ci.yml/badge.svg)](https://github.com/ad3002/pyreachx/actions/workflows/ci.yml)\n[![PyPI version](https://badge.fury.io/py/pyreachx.svg)](https://badge.fury.io/py/pyreachx)\n[![codecov](https://codecov.io/gh/ad3002/pyreachx/branch/main/graph/badge.svg)](https://codecov.io/gh/ad3002/pyreachx)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)\n\n## Features\n\n- Identifies unreachable functions and methods\n- Generates HTML and JSON reports\n- Configurable exclusion patterns\n- Support for class method analysis\n- Command-line interface\n- Confidence scoring for identified unreachable code\n\n## Installation\n\n```bash\npip install pyreachx\n```\n\n## Usage\n\n### Command Line\n\n```bash\n# Basic usage\npyreachx /path/to/your/project\n\n# Specify entry point\npyreachx /path/to/your/project -e module.main\n\n# Custom configuration file\npyreachx /path/to/your/project -c config.yml\n\n# Custom output file\npyreachx /path/to/your/project -o report.html\n```\n\n### Configuration\n\nCreate a `pyreachx.yml` file to customize the analysis:\n\n```yaml\nexclude_patterns:\n - \"**/test_*.py\"\n - \"**/__init__.py\"\nignore_decorators:\n - \"@property\"\n - \"@staticmethod\"\nconfidence_threshold: 0.8\n```\n\n### Python API\n\n```python\nfrom pyreachx import CodeAnalyzer, AnalyzerConfig\n\n# Create configuration\nconfig = AnalyzerConfig.from_file(\"pyreachx.yml\")\n\n# Initialize analyzer\nanalyzer = CodeAnalyzer(config)\n\n# Run analysis\nresult = analyzer.analyze(\"/path/to/project\", entry_point=\"main\")\n\n# Generate report\nfrom pyreachx import Reporter\nreporter = Reporter(result)\nreporter.generate_report(\"report.html\")\n```\n\n## Example Output\n\nHTML Report:\n```html\n<div class='item'>\n <strong>module.py</strong> (lines 10-15)<br>\n Type: function<br>\n Name: unused_function<br>\n Confidence: 95%\n</div>\n```\n\nJSON Report:\n```json\n{\n \"unreachable_items\": [\n {\n \"file_path\": \"module.py\",\n \"line_start\": 10,\n \"line_end\": 15,\n \"code_type\": \"function\",\n \"name\": \"unused_function\",\n \"confidence\": 0.95\n }\n ],\n \"statistics\": {\n \"total_unreachable_lines\": 6,\n \"files_affected\": [\"module.py\"],\n \"type_distribution\": {\n \"function\": 1\n }\n }\n}\n```\n\n## Development\n\n### Setup Development Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/ad3002/pyreachx.git\ncd pyreachx\n\n# Create virtual environment\npython -m venv venv\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\n\n# Install development dependencies\npip install -e .[test]\n```\n\n### Running Tests\n\n```bash\npytest tests/\n```\n\n### Code Style\n\nThis project uses:\n- Black for code formatting\n- isort for import sorting\n- flake8 for linting\n\n```bash\n# Format code\nblack pyreachx tests\nisort pyreachx tests\n\n# Check linting\nflake8 pyreachx tests\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- AST module from Python standard library\n- NetworkX for dependency graph analysis\n- Click for CLI interface\n- Jinja2 for report templating\n\n## Project Status\n\nPyReachX is in alpha stage. While it's functional, there might be false positives and edge cases that aren't handled yet. Use with caution in production environments.\n",
"bugtrack_url": null,
"license": null,
"summary": "Python Code Reachability Analyzer",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/ad3002/pyreachx"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0eccd85289bacce0ce03926c9d876759e459d34b864f6c91eea9f25816a0ea2b",
"md5": "597f0d30679d6c5fe39ed2ddbea98ca9",
"sha256": "1dbb61263793650177755e7017126a49ff667ef4bdfefe64accd9025d3d3b61d"
},
"downloads": -1,
"filename": "pyreachx-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "597f0d30679d6c5fe39ed2ddbea98ca9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 9097,
"upload_time": "2024-11-18T19:39:22",
"upload_time_iso_8601": "2024-11-18T19:39:22.425798Z",
"url": "https://files.pythonhosted.org/packages/0e/cc/d85289bacce0ce03926c9d876759e459d34b864f6c91eea9f25816a0ea2b/pyreachx-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0212717eafedab2823a011361771e059058c5899ee2dd1948eeabe6aaa19c3a4",
"md5": "f8aa864f73dbe7dd27223db3180abf8f",
"sha256": "cb73d728a51c13c40126f1f84d2abbd166cf2844c1d8ef75591219e5d95362cb"
},
"downloads": -1,
"filename": "pyreachx-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "f8aa864f73dbe7dd27223db3180abf8f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12994,
"upload_time": "2024-11-18T19:39:24",
"upload_time_iso_8601": "2024-11-18T19:39:24.240083Z",
"url": "https://files.pythonhosted.org/packages/02/12/717eafedab2823a011361771e059058c5899ee2dd1948eeabe6aaa19c3a4/pyreachx-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 19:39:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ad3002",
"github_project": "pyreachx",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "pyreachx"
}