feat(validators): add noqa suppression support to security and performance validators
All checks were successful
CI / dependency-scanning (push) Successful in 27s
CI / docs (push) Successful in 35s
CI / ruff (push) Successful in 8s
CI / pytest (push) Successful in 34m22s
CI / validate (push) Successful in 19s
CI / deploy (push) Successful in 2m25s

- Add centralized _is_noqa_suppressed() to BaseValidator with normalization
  (accepts both SEC001 and SEC-001 formats for ruff compatibility)
- Wire noqa support into all 21 security and 18 performance check functions
- Add ruff external config for SEC/PERF/MOD/EXC codes in pyproject.toml
- Convert all 280 Python noqa comments to dashless format (ruff-compatible)
- Add site/ to IGNORE_PATTERNS (excludes mkdocs build output)
- Suppress 152 false positive findings (test passwords, seed data, validator
  self-references, Apple Wallet SHA1, etc.)
- Security: 79 errors → 0, 60 warnings → 0
- Performance: 80 warnings → 77 (3 test script suppressions)
- Add proposal doc with noqa inventory and remaining findings recommendations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-14 22:56:56 +01:00
parent f84c5d903e
commit 1b8a40f1ff
75 changed files with 404 additions and 310 deletions

View File

@@ -54,7 +54,7 @@ class WebhookVerificationException(BusinessLogicException):
# =============================================================================
class PaymentException(BusinessLogicException): # noqa: MOD-025
class PaymentException(BusinessLogicException): # noqa: MOD025
"""Base exception for payment-related errors."""
def __init__(
@@ -66,7 +66,7 @@ class PaymentException(BusinessLogicException): # noqa: MOD-025
super().__init__(message=message, error_code=error_code, details=details)
class PaymentNotFoundException(ResourceNotFoundException): # noqa: MOD-025
class PaymentNotFoundException(ResourceNotFoundException): # noqa: MOD025
"""Raised when a payment is not found."""
def __init__(self, payment_id: str):
@@ -78,7 +78,7 @@ class PaymentNotFoundException(ResourceNotFoundException): # noqa: MOD-025
self.payment_id = payment_id
class PaymentFailedException(PaymentException): # noqa: MOD-025
class PaymentFailedException(PaymentException): # noqa: MOD025
"""Raised when payment processing fails."""
def __init__(self, message: str, stripe_error: str | None = None):
@@ -90,7 +90,7 @@ class PaymentFailedException(PaymentException): # noqa: MOD-025
self.stripe_error = stripe_error
class PaymentRefundException(PaymentException): # noqa: MOD-025
class PaymentRefundException(PaymentException): # noqa: MOD025
"""Raised when a refund fails."""
def __init__(self, message: str, payment_id: str | None = None):
@@ -102,7 +102,7 @@ class PaymentRefundException(PaymentException): # noqa: MOD-025
self.payment_id = payment_id
class InsufficientFundsException(PaymentException): # noqa: MOD-025
class InsufficientFundsException(PaymentException): # noqa: MOD025
"""Raised when there are insufficient funds for payment."""
def __init__(self, required_amount: float, available_amount: float | None = None):
@@ -121,7 +121,7 @@ class InsufficientFundsException(PaymentException): # noqa: MOD-025
self.available_amount = available_amount
class PaymentGatewayException(ExternalServiceException): # noqa: MOD-025
class PaymentGatewayException(ExternalServiceException): # noqa: MOD025
"""Raised when payment gateway fails."""
def __init__(self, gateway: str, message: str):
@@ -132,7 +132,7 @@ class PaymentGatewayException(ExternalServiceException): # noqa: MOD-025
self.gateway = gateway
class InvalidPaymentMethodException(ValidationException): # noqa: MOD-025
class InvalidPaymentMethodException(ValidationException): # noqa: MOD025
"""Raised when an invalid payment method is provided."""
def __init__(self, method: str):

View File

@@ -314,7 +314,7 @@ class GatewayService:
"status": "healthy" if is_healthy else "unhealthy",
"gateway": code,
}
except Exception as e: # noqa: EXC-003
except Exception as e: # noqa: EXC003
logger.exception(f"Gateway health check failed: {code}")
return {
"status": "error",