feat: implement code quality dashboard with architecture violation tracking
Implement comprehensive code quality dashboard (Phase 2-4) to track and manage
architecture violations found by the validation script.
Backend Implementation:
- Add JSON output support to validate_architecture.py script
- Create CodeQualityService with scan management, violation tracking, and statistics
- Implement REST API endpoints for code quality management:
* POST /admin/code-quality/scan - trigger new architecture scan
* GET /admin/code-quality/scans - list scan history
* GET /admin/code-quality/violations - list violations with filtering/pagination
* GET /admin/code-quality/violations/{id} - get violation details
* POST /admin/code-quality/violations/{id}/assign - assign to developer
* POST /admin/code-quality/violations/{id}/resolve - mark as resolved
* POST /admin/code-quality/violations/{id}/ignore - mark as ignored
* POST /admin/code-quality/violations/{id}/comments - add comments
* GET /admin/code-quality/stats - dashboard statistics
- Fix architecture_scan model imports to use app.core.database
Frontend Implementation:
- Create code quality dashboard page (code-quality-dashboard.html)
* Summary cards for total violations, errors, warnings, health score
* Status breakdown (open, assigned, resolved, ignored)
* Trend visualization for last 7 scans
* Top violating files list
* Violations by rule and module
* Quick action links
- Create violations list page (code-quality-violations.html)
* Filterable table by severity, status, rule ID, file path
* Pagination support
* Violation detail view links
- Add Alpine.js components (code-quality-dashboard.js, code-quality-violations.js)
* Dashboard state management and scan triggering
* Violations list with filtering and pagination
* API integration with authentication
- Add "Code Quality" navigation link in admin sidebar (Developer Tools section)
Routes:
- GET /admin/code-quality - dashboard page
- GET /admin/code-quality/violations - violations list
- GET /admin/code-quality/violations/{id} - violation details
Features:
- Real-time scan execution from UI
- Technical debt score calculation (0-100 scale)
- Violation workflow: open → assigned → resolved/ignored
- Trend tracking across multiple scans
- File and module-level insights
- Assignment system with priorities and due dates
- Collaborative comments on violations
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -584,6 +584,36 @@ class ArchitectureValidator:
|
||||
print("=" * 80)
|
||||
return 0
|
||||
|
||||
def print_json(self) -> int:
|
||||
"""Print validation results as JSON"""
|
||||
import json
|
||||
|
||||
violations_json = []
|
||||
for v in self.result.violations:
|
||||
rel_path = str(v.file_path.relative_to(self.project_root)) if self.project_root in v.file_path.parents else str(v.file_path)
|
||||
violations_json.append({
|
||||
'rule_id': v.rule_id,
|
||||
'rule_name': v.rule_name,
|
||||
'severity': v.severity.value,
|
||||
'file_path': rel_path,
|
||||
'line_number': v.line_number,
|
||||
'message': v.message,
|
||||
'context': v.context or '',
|
||||
'suggestion': v.suggestion or ''
|
||||
})
|
||||
|
||||
output = {
|
||||
'files_checked': self.result.files_checked,
|
||||
'total_violations': len(self.result.violations),
|
||||
'errors': len([v for v in self.result.violations if v.severity == Severity.ERROR]),
|
||||
'warnings': len([v for v in self.result.violations if v.severity == Severity.WARNING]),
|
||||
'violations': violations_json
|
||||
}
|
||||
|
||||
print(json.dumps(output, indent=2))
|
||||
|
||||
return 1 if self.result.has_errors() else 0
|
||||
|
||||
def _print_violation(self, v: Violation):
|
||||
"""Print a single violation"""
|
||||
rel_path = v.file_path.relative_to(self.project_root) if self.project_root in v.file_path.parents else v.file_path
|
||||
@@ -634,6 +664,12 @@ def main():
|
||||
help="Only show errors, suppress warnings"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--json',
|
||||
action='store_true',
|
||||
help="Output results as JSON (for programmatic use)"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Create validator
|
||||
@@ -642,8 +678,11 @@ def main():
|
||||
# Run validation
|
||||
result = validator.validate_all(args.path)
|
||||
|
||||
# Print report
|
||||
exit_code = validator.print_report()
|
||||
# Output results
|
||||
if args.json:
|
||||
exit_code = validator.print_json()
|
||||
else:
|
||||
exit_code = validator.print_report()
|
||||
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user