Skip to content

1.1.0

Choose a tag to compare

@AntonProkopyev AntonProkopyev released this 28 Jun 10:17
· 26 commits to master since this release
6655ddc

πŸš€ Major Enhancements

Enhanced Mutable Objects Detection

  • Expanded EO008: Complete rewrite from single checker to comprehensive modular package
  • 12 New Error Codes: Added EO015-EO027 for granular mutability detection
    • EO015: Mutable class attribute violations
    • EO016: Mutable instance attribute violations
    • EO017: Instance attribute mutation violations
    • EO018: Augmented assignment mutation violations
    • EO019: Mutating method call violations
    • EO020: Subscript assignment mutation violations
    • EO021: Chained mutation violations
    • EO022: Missing factory methods violations
    • EO023: Mutable default argument violations
    • EO024: Missing immutability enforcement violations
    • EO025: Copy-on-write violations
    • EO026: Aliasing violations (exposing mutable state)
    • EO027: Defensive copy violations

Modular Architecture

  • 6 Specialized Checkers: Organized mutable objects detection into focused modules
    • core.py: Main orchestrator coordinating all sub-checkers
    • contract_checker.py: Immutability contract enforcement
    • copy_on_write_checker.py: Copy-on-write pattern validation
    • deep_checker.py: Cross-class mutation analysis
    • factory_checker.py: Factory method pattern validation
    • pattern_detectors.py: Aliasing and defensive copy detection
    • shared_state_checker.py: Shared mutable state detection

πŸ”§ Code Quality & Complexity Rules

Ruff Integration

  • McCabe Complexity: Added C90 with max-complexity = 10
  • Nested Blocks: Added PLR1702 with max-nested-blocks = 5
  • Set Literals: Added PLR6201 enforcement (tuple β†’ set membership tests)
  • Preview Mode: Enabled ruff preview for latest pylint rules

Code Refactoring

  • Reduced Complexity: Refactored methods from 6-7 nesting levels to ≀5
  • Extract Methods: Improved maintainability through helper method extraction
  • Static Methods: Added @staticmethod decorators where appropriate
  • Type Safety: Enhanced mypy compliance with proper type narrowing

πŸ“ˆ Testing & Coverage

Coverage Improvements

  • 90% Coverage: Increased from 86% to 90% (+5% improvement)
  • Pattern Detectors: From 0% to 99% coverage
  • New Test Cases: Added 4 comprehensive test cases for EO026/EO027
  • Integration Tests: Enhanced end-to-end testing for new checkers

Test Quality

  • 100 Tests: All tests pass with enhanced coverage
  • False Positive Prevention: Added tests ensuring clean code doesn't trigger violations
  • Real-world Scenarios: Added aliasing and defensive copy test cases

πŸ—οΈ Architecture Improvements

Type Safety

  • MyPy Clean: Fixed all type errors with proper AsyncFunctionDef support
  • Type Assertions: Added strategic type narrowing for complex AST patterns
  • Null Safety: Enhanced null checking for optional attributes

Documentation

  • Updated README: Comprehensive error code documentation with examples
  • Project Structure: Updated to reflect new modular architecture
  • Coverage Badge: Updated to reflect improved test coverage (90%)

πŸ› Bug Fixes

  • Pattern Detector Integration: Fixed unused pattern detectors (0% β†’ 99% coverage)
  • Type Compatibility: Resolved mypy errors with union types
  • Whitespace Handling: Consistent code formatting across all files

⚠️ Breaking Changes

  • Mutable Objects: EO008 now focuses specifically on dataclass violations
  • New Error Codes: Code that was previously missed may now trigger EO015-EO027

πŸ”„ Internal Changes

  • Ruff Configuration: Added comprehensive linting rules with complexity enforcement
  • Parent Tracking: Enhanced AST analysis with parent node mapping
  • Modular Imports: Reorganized imports for better dependency management