Skip to main content

sonar_generate_report

Generate a comprehensive quality report from SonarQube analysis.

Description

Creates detailed quality reports in multiple formats. Useful for stakeholder communication, sprint reviews, and tracking quality trends over time.

Parameters

ParameterTypeRequiredDefaultDescription
formatstringNosummaryReport format: summary, detailed, json

Format Options

FormatDescriptionBest For
summaryHigh-level overviewQuick status checks
detailedFull breakdown with all issuesDeep analysis
jsonMachine-readable formatCI/CD integration

Usage

Summary Report

Give me a quality report summary

Tool call:

{}

Detailed Report

I need a full quality report with all issues

Tool call:

{
"format": "detailed"
}

JSON Format

Export quality data as JSON for our dashboard

Tool call:

{
"format": "json"
}

Response Format

Summary Format

╔══════════════════════════════════════════════════════════════════╗
║ QUALITY REPORT - SUMMARY ║
╠══════════════════════════════════════════════════════════════════╣
║ Project: my-awesome-app ║
║ Generated: 2024-01-15 14:32:00 ║
║ Analysis: Latest ║
╚══════════════════════════════════════════════════════════════════╝

📊 QUALITY GATE: ✅ PASSED

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📈 RATINGS OVERVIEW:

Reliability: A ████████████████████ (0 bugs)
Security: B ████████████████░░░░ (2 vulnerabilities)
Maintainability: A ████████████████████ (156 code smells)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📋 ISSUES SUMMARY:

│ Type │ Count │ Trend │
├─────────────────┼───────┼────────┤
│ 🐛 Bugs │ 0 │ ↓3 │
│ 🔓 Vulnerabilities│ 2 │ ↓1 │
│ 🔒 Hotspots │ 5 │ = │
│ 💭 Code Smells │ 156 │ ↓12 │

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📊 COVERAGE & DUPLICATION:

Test Coverage: 67.3% ████████████████░░░░░░░░░
Duplication: 4.2% ██░░░░░░░░░░░░░░░░░░░░░░░

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⏱️ TECHNICAL DEBT:

Total: 3d 4h
Ratio: 2.3%

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🎯 RECOMMENDATIONS:

1. Fix 2 security vulnerabilities (estimated: 2h)
2. Review 5 security hotspots
3. Coverage target: increase to 70% (+2.7%)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Detailed Format

╔══════════════════════════════════════════════════════════════════╗
║ QUALITY REPORT - DETAILED ║
╠══════════════════════════════════════════════════════════════════╣
║ Project: my-awesome-app ║
║ Generated: 2024-01-15 14:32:00 ║
╚══════════════════════════════════════════════════════════════════╝

[Summary section as above...]

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔓 VULNERABILITIES (2):

1. [CRITICAL] SQL Injection Risk
File: src/api/userController.ts:45
Rule: typescript:S3649
Message: Sanitize user input before SQL query

2. [MAJOR] Hardcoded Credentials
File: src/config/database.ts:12
Rule: typescript:S2068
Message: Remove hardcoded password

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

🔒 SECURITY HOTSPOTS (5):

[TO_REVIEW] 3 hotspots require manual review
[REVIEWED] 2 hotspots marked as safe

1. [HIGH] Weak cryptography
File: src/utils/crypto.ts:23
Status: TO_REVIEW

2. [MEDIUM] CORS configuration
File: src/server/middleware.ts:15
Status: TO_REVIEW

...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

💭 CODE SMELLS BY SEVERITY:

MAJOR (45):
• Cognitive complexity issues: 23
• Long methods: 12
• Duplicate blocks: 10

MINOR (89):
• Naming conventions: 45
• Magic numbers: 28
• TODO comments: 16

INFO (22):
• Formatting issues: 22

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

📁 TOP FILES BY ISSUES:

1. src/services/PaymentService.ts (23 issues)
2. src/utils/validators.ts (18 issues)
3. src/api/handlers/orderHandler.ts (15 issues)
4. src/components/DataTable.tsx (12 issues)
5. src/hooks/useApi.ts (8 issues)

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

JSON Format

{
"project": {
"key": "my-project-a1b2c3d4",
"name": "my-awesome-app",
"version": "1.2.3"
},
"generated": "2024-01-15T14:32:00Z",
"qualityGate": {
"status": "PASSED",
"conditions": [...]
},
"metrics": {
"bugs": 0,
"vulnerabilities": 2,
"codeSmells": 156,
"coverage": 67.3,
"duplicatedLinesDensity": 4.2,
"technicalDebt": "3d 4h"
},
"ratings": {
"reliability": "A",
"security": "B",
"maintainability": "A"
},
"issues": {
"byType": {...},
"bySeverity": {...},
"byFile": [...]
}
}

Examples

Example 1: Sprint Review

Prompt:

Generate a report for our sprint review meeting

Tool Call:

{
"format": "summary"
}

Example 2: Technical Analysis

Prompt:

I need a detailed breakdown of all quality issues

Tool Call:

{
"format": "detailed"
}

Example 3: Dashboard Integration

Prompt:

Export quality data for our monitoring dashboard

Tool Call:

{
"format": "json"
}

Report Sections

SectionSummaryDetailedJSON
Quality Gate
Ratings
Issue Counts
Issue Details
File Breakdown
Trends
Recommendations

Use Cases

ScenarioFormatReason
Daily standupsummaryQuick overview
Sprint reviewsummaryStakeholder-friendly
Technical debt analysisdetailedFull visibility
CI/CD pipelinejsonAutomated processing
Management reportsummaryHigh-level metrics
Issue triagedetailedPrioritize fixes

Best Practices

  1. Regular reporting - Generate weekly for trend tracking
  2. Match audience - Summary for stakeholders, detailed for developers
  3. Track trends - Compare reports over time
  4. Act on recommendations - Don't just generate, follow up

Common Issues

"No data available"

Cause: Project hasn't been scanned.

Solution: Run sonar_scan_project first.

"Report seems outdated"

Cause: Using cached analysis data.

Solution: Re-scan project for fresh data.