fix(lint): auto-fix ruff violations and tune lint rules
- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,22 +7,22 @@ Supports multiple validator types: architecture, security, performance
|
||||
import json
|
||||
import logging
|
||||
import subprocess
|
||||
from datetime import datetime, UTC
|
||||
from datetime import UTC, datetime
|
||||
|
||||
from sqlalchemy import desc, func
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.modules.monitoring.exceptions import (
|
||||
ScanParseException,
|
||||
ScanTimeoutException,
|
||||
ViolationNotFoundException,
|
||||
)
|
||||
from app.modules.dev_tools.models import (
|
||||
ArchitectureScan,
|
||||
ArchitectureViolation,
|
||||
ViolationAssignment,
|
||||
ViolationComment,
|
||||
)
|
||||
from app.modules.monitoring.exceptions import (
|
||||
ScanParseException,
|
||||
ScanTimeoutException,
|
||||
ViolationNotFoundException,
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -565,7 +565,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.status)
|
||||
.all()
|
||||
)
|
||||
status_dict = {status: count for status, count in status_counts}
|
||||
status_dict = dict(status_counts)
|
||||
|
||||
# Get violations by severity
|
||||
severity_counts = (
|
||||
@@ -576,7 +576,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.severity)
|
||||
.all()
|
||||
)
|
||||
by_severity = {sev: count for sev, count in severity_counts}
|
||||
by_severity = dict(severity_counts)
|
||||
|
||||
# Get violations by rule
|
||||
rule_counts = (
|
||||
@@ -587,10 +587,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.rule_id)
|
||||
.all()
|
||||
)
|
||||
by_rule = {
|
||||
rule: count
|
||||
for rule, count in sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10]
|
||||
}
|
||||
by_rule = dict(sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
# Get top violating files
|
||||
file_counts = (
|
||||
@@ -667,7 +664,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.status)
|
||||
.all()
|
||||
)
|
||||
status_dict = {status: count for status, count in status_counts}
|
||||
status_dict = dict(status_counts)
|
||||
|
||||
# Get violations by severity
|
||||
severity_counts = (
|
||||
@@ -678,7 +675,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.severity)
|
||||
.all()
|
||||
)
|
||||
by_severity = {sev: count for sev, count in severity_counts}
|
||||
by_severity = dict(severity_counts)
|
||||
|
||||
# Get violations by rule (across all validators)
|
||||
rule_counts = (
|
||||
@@ -689,10 +686,7 @@ class CodeQualityService:
|
||||
.group_by(ArchitectureViolation.rule_id)
|
||||
.all()
|
||||
)
|
||||
by_rule = {
|
||||
rule: count
|
||||
for rule, count in sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10]
|
||||
}
|
||||
by_rule = dict(sorted(rule_counts, key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
# Get top violating files
|
||||
file_counts = (
|
||||
@@ -761,10 +755,7 @@ class CodeQualityService:
|
||||
|
||||
for v in violations:
|
||||
path_parts = v.file_path.split("/")
|
||||
if len(path_parts) >= 2:
|
||||
module = "/".join(path_parts[:2])
|
||||
else:
|
||||
module = path_parts[0]
|
||||
module = "/".join(path_parts[:2]) if len(path_parts) >= 2 else path_parts[0]
|
||||
by_module[module] = by_module.get(module, 0) + 1
|
||||
|
||||
return dict(sorted(by_module.items(), key=lambda x: x[1], reverse=True)[:10])
|
||||
|
||||
Reference in New Issue
Block a user