A static analysis tool that detects and analyzes operator usage patterns in Python codebases
PyGCA was created to help developers contribute to open-source projects more efficiently by identifying minor code issues (like typos and naming convention inconsistencies) without having to manually review millions of lines of code. Read more about our motivation and philosophy.
- Motivation
- Table of Contents
- Key Features
- Installation
- Quick Start
- Advanced Usage
- Testing
- Contributing
- Documentation
- Comparison with Similar Tools
- Troubleshooting
- License
- Real-world Use Cases
- Roadmap
- π― Multi-operator detection with specialized checkers
- π Actionable suggestions with line-number references
- βοΈ Customizable rules via
.pygcconfig
files - π Performance profiling for large codebases
- π Detailed reports in multiple formats
pip install pygca
git clone https://github.com/clintaire/PyGCA.git
cd PyGCA
pip install -e .
Analyze a Python file:
python -m pygca analyze path/to/your_script.py
Sample output:
Found 3 potential issues in path/to/your_script.py:
1. [Line 5] Division by zero risk in 'a / 0'
2. [Line 8] Bitwise AND in conditional context
3. [Line 12] None comparison using '=='
Consider this sample code:
def example(a, b):
# Arithmetic operation
result = a / 0
# Bitwise in conditional
if a & b:
return True
# Identity check
return result is None
PyGCA would detect:
- Potential division by zero
- Bitwise operator in conditional context
- Safe identity check (no issue)
Check specific operator categories:
python -m pygca analyze --operators arithmetic,bitwise example.py
Create .pygcconfig
in your project root:
[operators]
exclude_files = tests/, legacy/
exclude_categories = identity
[messages]
division_by_zero = "Custom warning: Possible division by zero at {line}"
Analyze large codebases with resource monitoring:
python -m pygca analyze --profile large_project/
Sample profile output:
Processed 152 files (2.1MB) in 4.8s
Memory usage: 48.2MB peak
CPU utilization: 32%
Run the test suite:
pytest tests/ --cov=pygca --cov-report=term-missing
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/your-feature
) - Open a Pull Request
See our Contribution Guidelines for details.
For full documentation and API reference, visit:
Feature | PyGCA | Pylint | Flake8 |
---|---|---|---|
Python 3.12+ | β | β | β |
Custom Rules | High | Medium | Low |
CLI Interface | β | β | β |
Plugin System | β | β | β |
-
ImportError when running PyGCA
- Make sure you've installed all dependencies with
pip install -r requirements.txt
- Make sure you've installed all dependencies with
-
False positives in operator detection
- Configure exclusions in your
.pygcconfig
file
- Configure exclusions in your
This project is licensed under the MIT License - see the LICENSE file for details.
- CI/CD Integration: Automatically check PRs for operator issues
- Large Codebase Migration: Identify potential bugs when upgrading Python versions
- Teaching Tool: Help new developers understand operator nuances
- Support for Python 3.12 match/case statements
- IDE integrations (VS Code, PyCharm)
- Web interface for online analysis