8000 GitHub - clintaire/PyGCA: Python library designed to detect and analyze operator usage in Python codebases. It supports a variety of operators, including arithmetic, bitwise, comparison, identity, logical, and membership operators.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Python library designed to detect and analyze operator usage in Python codebases. It supports a variety of operators, including arithmetic, bitwise, comparison, identity, logical, and membership operators.

License

Notifications You must be signed in to change notification settings

clintaire/PyGCA

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PYGCA

A static analysis tool that detects and analyzes operator usage patterns in Python codebases

Build Status Downloads Coverage License Code Style Python Versions


Motivation

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.

Table of Contents

Key Features

  • 🎯 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

Installation

From PyPI

pip install pygca

From Source

git clone https://github.com/clintaire/PyGCA.git
cd PyGCA
pip install -e .

Quick Start

Basic Usage

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 '=='

Example Analysis

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:

  1. Potential division by zero
  2. Bitwise operator in conditional context
  3. Safe identity check (no issue)

Advanced Usage

Targeted Analysis

Check specific operator categories:

python -m pygca analyze --operators arithmetic,bitwise example.py

Configuration

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}"

Performance Profiling

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%

Testing

Run the test suite:

pytest tests/ --cov=pygca --cov-report=term-missing

Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/your-feature)
  5. Open a Pull Request

See our Contribution Guidelines for details.

Documentation

For full documentation and API reference, visit:

Comparison with Similar Tools

Feature PyGCA Pylint Flake8
Python 3.12+ βœ… βœ… βœ…
Custom Rules High Medium Low
CLI Interface βœ… βœ… βœ…
Plugin System ❌ βœ… βœ…

Troubleshooting

Common Issues

  1. ImportError when running PyGCA

    • Make sure you've installed all dependencies with pip install -r requirements.txt
  2. False positives in operator detection

    • Configure exclusions in your .pygcconfig file

License

This project is licensed under the MIT License - see the LICENSE file for details.

Real-world Use Cases

  • 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

Roadmap

  • Support for Python 3.12 match/case statements
  • IDE integrations (VS Code, PyCharm)
  • Web interface for online analysis

About

Python library designed to detect and analyze operator usage in Python codebases. It supports a variety of operators, including arithmetic, bitwise, comparison, identity, logical, and membership operators.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0