git-repo-analyzer-test 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/.github/copilot-instructions.md +108 -0
  2. package/.idea/aianalyzer.iml +9 -0
  3. package/.idea/misc.xml +6 -0
  4. package/.idea/modules.xml +8 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/API_REFERENCE.md +244 -0
  7. package/ENHANCEMENTS.md +282 -0
  8. package/README.md +179 -0
  9. package/USAGE.md +189 -0
  10. package/analysis.txt +0 -0
  11. package/bin/cli.js +135 -0
  12. package/docs/SONARCLOUD_ANALYSIS_COVERED.md +144 -0
  13. package/docs/SonarCloud_Presentation_Points.md +81 -0
  14. package/docs/UI_IMPROVEMENTS.md +117 -0
  15. package/package-lock_cmd.json +542 -0
  16. package/package.json +44 -0
  17. package/package_command.json +16 -0
  18. package/public/analysis-options.json +31 -0
  19. package/public/images/README.txt +2 -0
  20. package/public/images/rws-logo.png +0 -0
  21. package/public/index.html +2433 -0
  22. package/repositories.example.txt +17 -0
  23. package/sample-repos.txt +20 -0
  24. package/src/analyzers/accessibility.js +47 -0
  25. package/src/analyzers/cicd-enhanced.js +113 -0
  26. package/src/analyzers/codeReview-enhanced.js +599 -0
  27. package/src/analyzers/codeReview-enhanced.js:Zone.Identifier +3 -0
  28. package/src/analyzers/codeReview.js +171 -0
  29. package/src/analyzers/codeReview.js:Zone.Identifier +3 -0
  30. package/src/analyzers/documentation-enhanced.js +137 -0
  31. package/src/analyzers/performance-enhanced.js +747 -0
  32. package/src/analyzers/performance-enhanced.js:Zone.Identifier +3 -0
  33. package/src/analyzers/performance.js +211 -0
  34. package/src/analyzers/performance.js:Zone.Identifier +3 -0
  35. package/src/analyzers/performance_cmd.js +216 -0
  36. package/src/analyzers/quality-enhanced.js +386 -0
  37. package/src/analyzers/quality-enhanced.js:Zone.Identifier +3 -0
  38. package/src/analyzers/quality.js +92 -0
  39. package/src/analyzers/quality.js:Zone.Identifier +3 -0
  40. package/src/analyzers/security-enhanced.js +512 -0
  41. package/src/analyzers/security-enhanced.js:Zone.Identifier +3 -0
  42. package/src/analyzers/snyk-ai.js:Zone.Identifier +3 -0
  43. package/src/analyzers/sonarcloud.js +928 -0
  44. package/src/analyzers/vulnerability.js +185 -0
  45. package/src/analyzers/vulnerability.js:Zone.Identifier +3 -0
  46. package/src/cli.js:Zone.Identifier +3 -0
  47. package/src/config.js +43 -0
  48. package/src/core/analyzerEngine.js +68 -0
  49. package/src/core/reportGenerator.js +21 -0
  50. package/src/gemini.js +321 -0
  51. package/src/github/client.js +124 -0
  52. package/src/github/client.js:Zone.Identifier +3 -0
  53. package/src/index.js +93 -0
  54. package/src/index_cmd.js +130 -0
  55. package/src/openai.js +297 -0
  56. package/src/report/generator.js +459 -0
  57. package/src/report/generator_cmd.js +459 -0
  58. package/src/report/pdf-generator.js +387 -0
  59. package/src/report/pdf-generator.js:Zone.Identifier +3 -0
  60. package/src/server.js +431 -0
  61. package/src/server.js:Zone.Identifier +3 -0
  62. package/src/server_cmd.js +434 -0
  63. package/src/sonarcloud/client.js +365 -0
  64. package/src/sonarcloud/scanner.js +171 -0
  65. package/src.zip +0 -0
package/README.md ADDED
@@ -0,0 +1,179 @@
1
+ # Git Repository Analyzer
2
+
3
+ A comprehensive Node.js tool for analyzing GitHub repositories across four critical dimensions: **Code Quality**, **Vulnerabilities**, **Code Review Practices**, and **Performance**.
4
+
5
+ ## Features
6
+
7
+ - **📈 Code Quality Analysis**: Evaluate repository health through stars, forks, issues, documentation, and activity metrics
8
+ - **🔒 Security & Vulnerability Assessment**: Identify potential security risks and recommend safeguards
9
+ - **👥 Code Review & Collaboration Metrics**: Analyze pull request patterns, review velocity, and team collaboration
10
+ - **⚡ Performance & Release Analysis**: Track release frequency, development velocity, and code frequency patterns
11
+ - **📊 Comprehensive Reports**: Generate detailed reports with actionable recommendations
12
+ - **🔄 Batch Analysis**: Analyze multiple repositories in one operation
13
+
14
+ ## Installation
15
+
16
+ 1. Clone or download the repository
17
+ 2. Install dependencies:
18
+ ```bash
19
+ npm install
20
+ ```
21
+
22
+ 3. (Optional) Configure GitHub token for authenticated requests:
23
+ ```bash
24
+ npm run analyze -- config
25
+ ```
26
+
27
+ Create a `.env` file in the root directory:
28
+ ```
29
+ GITHUB_TOKEN=your_github_personal_access_token
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### Analyze a Single Repository
35
+
36
+ ```bash
37
+ npm run analyze -- analyze owner/repo-name
38
+ ```
39
+
40
+ **Example:**
41
+ ```bash
42
+ npm run analyze -- analyze facebook/react
43
+ ```
44
+
45
+ ### Save Report to File
46
+
47
+ ```bash
48
+ npm run analyze -- analyze owner/repo-name --output ./reports/report.json
49
+ ```
50
+
51
+ ### Analyze Multiple Repositories
52
+
53
+ Create a file `repos.txt` with one repository per line:
54
+ ```
55
+ facebook/react
56
+ torvalds/linux
57
+ kubernetes/kubernetes
58
+ nodejs/node
59
+ ```
60
+
61
+ Then run:
62
+ ```bash
63
+ npm run analyze -- batch repos.txt --output-dir ./reports
64
+ ```
65
+
66
+ ### View Configuration
67
+
68
+ ```bash
69
+ npm run analyze -- config
70
+ ```
71
+
72
+ ## Report Sections
73
+
74
+ ### 1. Code Quality
75
+ - Stars, forks, watchers
76
+ - Open issues count
77
+ - Primary language and languages used
78
+ - Days since last update
79
+ - Documentation presence
80
+ - Topics and tags
81
+
82
+ ### 2. Security & Vulnerability
83
+ - Risk level assessment (Critical, High, Medium, Low)
84
+ - Risk factors identification
85
+ - Security feature status
86
+ - Maintenance status
87
+ - Actionable recommendations
88
+
89
+ ### 3. Code Review & Collaboration
90
+ - Pull request metrics (total, open, merged, closure rate)
91
+ - Average review time
92
+ - Contributor count
93
+ - Commit patterns and unique authors
94
+ - Review velocity analysis
95
+
96
+ ### 4. Performance & Release
97
+ - Release frequency and patterns
98
+ - Development velocity trends
99
+ - Code activity analysis
100
+ - Weekly additions and deletions
101
+ - Release cadence recommendations
102
+
103
+ ## Environment Variables
104
+
105
+ - `GITHUB_TOKEN`: Personal access token for authenticated API requests (increases rate limit from 60 to 5000 requests/hour)
106
+
107
+ ## API Rate Limits
108
+
109
+ - **Without token**: 60 requests per hour (IP-based)
110
+ - **With token**: 5000 requests per hour (user-based)
111
+
112
+ ## Project Structure
113
+
114
+ ```
115
+ src/
116
+ ├── index.js # Main entry point
117
+ ├── cli.js # Command-line interface
118
+ ├── github/
119
+ │ └── client.js # GitHub API client
120
+ ├── analyzers/
121
+ │ ├── quality.js # Code quality analyzer
122
+ │ ├── vulnerability.js # Security analyzer
123
+ │ ├── codeReview.js # Code review analyzer
124
+ │ └── performance.js # Performance analyzer
125
+ └── report/
126
+ └── generator.js # Report generation
127
+ ```
128
+
129
+ ## Example Output
130
+
131
+ ```
132
+ 📊 GitHub Repository Analysis Report
133
+ Repository: facebook/react
134
+ Generated: 2/10/2026, 10:30:45 AM
135
+
136
+ 🎯 Overall Score: 92/100
137
+ [████████████████████░░░░░░]
138
+
139
+ 📈 Code Quality Analysis
140
+ Quality Score: 95/100
141
+ ┌────────────────────┬─────────┐
142
+ │ Metric │ Value │
143
+ ├────────────────────┼─────────┤
144
+ │ Stars │ 215000 │
145
+ │ Forks │ 44000 │
146
+ │ Open Issues │ 1200 │
147
+ └────────────────────┴─────────┘
148
+
149
+ [Additional sections for security, code review, and performance...]
150
+ ```
151
+
152
+ ## Technologies Used
153
+
154
+ - **axios**: HTTP client for API requests
155
+ - **commander**: CLI framework
156
+ - **chalk**: Terminal colors
157
+ - **table**: Formatted table output
158
+ - **dotenv**: Environment variable management
159
+
160
+ ## Error Handling
161
+
162
+ The analyzer handles various error scenarios:
163
+ - Invalid repository format
164
+ - Network errors
165
+ - API rate limit exceeded
166
+ - Repository not found
167
+ - Insufficient permissions
168
+
169
+ ## Contributing
170
+
171
+ Feel free to submit issues and enhancement requests!
172
+
173
+ ## License
174
+
175
+ MIT License - See LICENSE file for details
176
+
177
+ ## Support
178
+
179
+ For issues, questions, or suggestions, please open an issue in the repository.
package/USAGE.md ADDED
@@ -0,0 +1,189 @@
1
+ # Usage Guide
2
+
3
+ ## Quick Start
4
+
5
+ ### 1. Install Dependencies
6
+ ```bash
7
+ npm install
8
+ ```
9
+
10
+ ### 2. Configure GitHub Token (Optional but Recommended)
11
+ Edit `.env` file and add your GitHub personal access token:
12
+ ```
13
+ GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxx
14
+ ```
15
+
16
+ Get a token from: https://github.com/settings/tokens
17
+
18
+ ### 3. Analyze a Repository
19
+
20
+ **Single Repository:**
21
+ ```bash
22
+ npm run analyze -- analyze facebook/react
23
+ ```
24
+
25
+ **Save Report as JSON:**
26
+ ```bash
27
+ npm run analyze -- analyze nodejs/node --output ./reports/node-report.json
28
+ ```
29
+
30
+ ## Command Reference
31
+
32
+ ### Analyze Command
33
+ ```
34
+ npm run analyze -- analyze <owner/repo> [options]
35
+
36
+ Options:
37
+ -o, --output <path> Save report to JSON file
38
+ ```
39
+
40
+ ### Batch Command
41
+ ```
42
+ npm run analyze -- batch <file> [options]
43
+
44
+ Options:
45
+ -o, --output-dir <path> Save reports to directory
46
+
47
+ File format: One repository per line
48
+ facebook/react
49
+ nodejs/node
50
+ kubernetes/kubernetes
51
+ ```
52
+
53
+ ### Config Command
54
+ ```
55
+ npm run analyze -- config
56
+ ```
57
+ Shows GitHub token configuration instructions.
58
+
59
+ ## Report Components
60
+
61
+ ### Code Quality Score (0-100)
62
+ Evaluates:
63
+ - Repository popularity (stars, forks, watchers)
64
+ - Issue management
65
+ - Documentation availability
66
+ - Activity level
67
+ - Language diversity
68
+
69
+ ### Vulnerability Risk Level
70
+ - **Low**: Repository appears secure
71
+ - **Medium**: Some security concerns
72
+ - **High**: Significant security risks
73
+ - **Critical**: Severe vulnerabilities
74
+
75
+ Risk factors include:
76
+ - Maintenance status
77
+ - Security features enabled
78
+ - Open issues count
79
+ - Documentation coverage
80
+ - Repository archival status
81
+
82
+ ### Code Review Collaboration Score (0-100)
83
+ Metrics:
84
+ - Pull request volume and closure rate
85
+ - Average review time
86
+ - Team collaboration level
87
+ - Commit patterns
88
+ - Contributor count
89
+
90
+ ### Performance Score (0-100)
91
+ Evaluates:
92
+ - Release frequency and patterns
93
+ - Development velocity trends
94
+ - Code activity over time
95
+ - Repository maturity
96
+ - Network metrics
97
+
98
+ ## API Rate Limits
99
+
100
+ - **Without Token**: 60 requests/hour (IP-based)
101
+ - **With Token**: 5000 requests/hour (user-based)
102
+
103
+ ## Typical Analysis Time
104
+
105
+ - Single repository: 3-5 seconds
106
+ - Batch of 10 repositories: 30-50 seconds
107
+
108
+ ## Example Reports
109
+
110
+ ### Report Structure (JSON)
111
+ ```json
112
+ {
113
+ "timestamp": "2026-02-10T18:34:25.000Z",
114
+ "repository": "vuejs/vue",
115
+ "summary": {
116
+ "overallScore": 86,
117
+ "qualityScore": 94,
118
+ "securityScore": 50,
119
+ "collaborationScore": 100,
120
+ "performanceScore": 100,
121
+ "healthStatus": "Excellent"
122
+ },
123
+ "detailed": {
124
+ "quality": { ... },
125
+ "vulnerability": { ... },
126
+ "codeReview": { ... },
127
+ "performance": { ... }
128
+ }
129
+ }
130
+ ```
131
+
132
+ ## Troubleshooting
133
+
134
+ ### "Cannot find module" errors
135
+ - Ensure all dependencies are installed: `npm install`
136
+ - Check file paths are correct (imports should use `../`)
137
+
138
+ ### API rate limit exceeded
139
+ - Add GitHub token to `.env` file
140
+ - Reduces rate limit from 60 to 5000 requests/hour
141
+
142
+ ### "Repository not found" error
143
+ - Verify the repository exists and is public
144
+ - Check the format is correct: `owner/repo-name`
145
+
146
+ ### No data for code frequency
147
+ - Some statistics may not be available for certain repositories
148
+ - This is normal and won't affect the analysis
149
+
150
+ ## Advanced Usage
151
+
152
+ ### Programmatic Use
153
+ ```javascript
154
+ import { analyzeRepository } from './src/index.js';
155
+
156
+ const { report, analysis } = await analyzeRepository('owner', 'repo');
157
+ console.log(report.summary);
158
+ ```
159
+
160
+ ### Custom Report Export
161
+ Extend `ReportGenerator` to add custom formats:
162
+ ```javascript
163
+ static generateCSVReport(analysis) {
164
+ // Custom CSV export logic
165
+ }
166
+ ```
167
+
168
+ ## Best Practices
169
+
170
+ 1. **Use GitHub Token**: Enables 80x higher API rate limits
171
+ 2. **Batch Analysis**: Analyze multiple repos at once to save time
172
+ 3. **Export Reports**: Save JSON reports for archival or comparison
173
+ 4. **Regular Audits**: Periodically re-analyze repositories to track changes
174
+ 5. **Review Recommendations**: Pay attention to generated recommendations for improvements
175
+
176
+ ## Support
177
+
178
+ For issues or questions:
179
+ 1. Check this guide first
180
+ 2. Review the README.md for detailed documentation
181
+ 3. Check GitHub issues in your repository
182
+ 4. Verify your GitHub token has necessary permissions
183
+
184
+ ## Next Steps
185
+
186
+ - Analyze your own repositories
187
+ - Set up batch analysis for multiple projects
188
+ - Export reports for team review
189
+ - Compare reports over time to track improvements
package/analysis.txt ADDED
Binary file
package/bin/cli.js ADDED
@@ -0,0 +1,135 @@
1
+ #!/usr/bin/env node
2
+
3
+ import dotenv from 'dotenv';
4
+ import chalk from 'chalk';
5
+ import path from 'path';
6
+ import fs from 'fs';
7
+ import axios from 'axios';
8
+ import { AnalyzerEngine } from '../src/core/analyzerEngine.js';
9
+ import generator from "../src/report/generator.js";
10
+
11
+ // Load env
12
+ dotenv.config();
13
+
14
+ // ⚠️ DO NOT log full key
15
+ console.log("KEY:", process.env.OPENAI_API_KEY?.slice(0, 8));
16
+
17
+ // ⚠️ DEV ONLY (remove in prod)
18
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
19
+
20
+ // -----------------------------
21
+ // Parse arguments
22
+ // -----------------------------
23
+ const args = process.argv.slice(2);
24
+
25
+ if (args.length === 0) {
26
+ console.log(chalk.yellow('Usage: analyze <owner/repo> [--output report.json]'));
27
+ process.exit(1);
28
+ }
29
+
30
+ const repoInput = args[0];
31
+ const outputIndex = args.indexOf('--output');
32
+ const outputPath = outputIndex !== -1 ? args[outputIndex + 1] : null;
33
+
34
+ // -----------------------------
35
+ // Parse repo
36
+ // -----------------------------
37
+ function parseRepo(repo) {
38
+ if (repo.startsWith('http')) {
39
+ const parts = repo
40
+ .replace('https://github.com/', '')
41
+ .replace('.git', '')
42
+ .split('/');
43
+ return { owner: parts[0], repo: parts[1] };
44
+ }
45
+ const [owner, repoName] = repo.split('/');
46
+ return { owner, repo: repoName };
47
+ }
48
+
49
+ const { owner, repo } = parseRepo(repoInput);
50
+
51
+ if (!owner || !repo) {
52
+ console.error(chalk.red('❌ Invalid repository format. Use owner/repo'));
53
+ process.exit(1);
54
+ }
55
+
56
+ // -----------------------------
57
+ // Run Analysis
58
+ // -----------------------------
59
+ (async () => {
60
+ try {
61
+ console.log(chalk.cyan(`\n🔍 Analyzing: ${owner}/${repo}\n`));
62
+
63
+ const analyzer = new AnalyzerEngine();
64
+ const analysis = await analyzer.runFullAnalysis(owner, repo);
65
+
66
+ // Pretty JSON output (no [Object])
67
+ console.log(chalk.gray("\n📊 Analysis Result:\n"));
68
+ console.log(JSON.stringify(analysis, null, 2));
69
+
70
+ // -----------------------------
71
+ // Generate TEXT report
72
+ // -----------------------------
73
+ const textReport = generator.generateReport(`${owner}/${repo}`, analysis);
74
+
75
+ console.log(chalk.green("\n📝 Text Report:\n"));
76
+ console.log(textReport);
77
+
78
+ // -----------------------------
79
+ // Generate PDF via API
80
+ // -----------------------------
81
+ const serverUrl = "http://localhost:9000";
82
+
83
+ console.log(chalk.cyan("\n📄 Generating PDF report...\n"));
84
+
85
+ const response = await axios.post(
86
+ `${serverUrl}/api/export-pdf`,
87
+ {
88
+ repository: `${owner}/${repo}`,
89
+ analysis: analysis,
90
+ report: {
91
+ summary: analysis.summary || {}
92
+ }
93
+ },
94
+ {
95
+ responseType: "stream",
96
+ }
97
+ );
98
+
99
+ // Ensure reports folder exists
100
+ const reportsDir = path.join(process.cwd(), "reports");
101
+ if (!fs.existsSync(reportsDir)) {
102
+ fs.mkdirSync(reportsDir);
103
+ }
104
+
105
+ const fileName = `${owner}-${repo}-${Date.now()}.pdf`;
106
+ const filePath = path.join(reportsDir, fileName);
107
+
108
+ const writer = fs.createWriteStream(filePath);
109
+
110
+ response.data.pipe(writer);
111
+
112
+ await new Promise((resolve, reject) => {
113
+ writer.on("finish", resolve);
114
+ writer.on("error", reject);
115
+ });
116
+
117
+ console.log(chalk.green("\n✅ PDF Report Generated!\n"));
118
+ console.log(chalk.blue(`📁 Local Path: ${filePath}`));
119
+ console.log(chalk.blue(`🌐 Download URL: http://localhost:9000/reports/${fileName}\n`));
120
+
121
+ // -----------------------------
122
+ // Save JSON if --output used
123
+ // -----------------------------
124
+ if (outputPath) {
125
+ const fullPath = path.resolve(outputPath);
126
+ fs.writeFileSync(fullPath, JSON.stringify(analysis, null, 2), 'utf-8');
127
+
128
+ console.log(chalk.green(`\n✅ JSON Report saved to: ${fullPath}\n`));
129
+ }
130
+
131
+ } catch (error) {
132
+ console.error(chalk.red(`❌ Error: ${error.message}`));
133
+ process.exit(1);
134
+ }
135
+ })();
@@ -0,0 +1,144 @@
1
+ # Points Covered in SonarCloud Analysis
2
+
3
+ This document lists what the Repository Analyzer includes when it runs a SonarCloud-based code quality analysis.
4
+
5
+ ---
6
+
7
+ ## Short summary (at a glance)
8
+
9
+ | Area | What’s covered |
10
+ |------|----------------|
11
+ | **Quality gate** | Status (OK / ERROR / NONE) + conditions list |
12
+ | **Metrics** | LOC, bugs, vulnerabilities, code smells, coverage, duplication, complexity, security hotspots, ratings |
13
+ | **Issues** | List with severity, file, line, message; breakdown by type and severity |
14
+ | **Score** | 0–10 score + A+ to F rating from bugs, vulns, smells, gate, coverage |
15
+ | **Recommendations** | Auto-generated from metrics (gate, bugs, vulns, smells, coverage, duplication) |
16
+ | **UI** | KPI cards, 3 charts, metric tiles, conditions, issues table, recommendations, SonarCloud link |
17
+
18
+ **APIs used (free plan):** Quality gate status, measures/component, issues/search.
19
+ **Optional:** Clone + SonarScanner for first-time or always-fresh scan.
20
+
21
+ ---
22
+
23
+ ## 1. Quality Gate
24
+
25
+ - **Status:** OK, ERROR, or NONE (from SonarCloud `api/qualitygates/project_status`).
26
+ - **Conditions:** Each condition shows:
27
+ - Metric key
28
+ - Status (OK / ERROR)
29
+ - Operator and value
30
+ - Error threshold (when applicable)
31
+ - **UI:** Quality Gate KPI card (green = OK, red = ERROR, grey = NONE/unknown) and a conditions list when available.
32
+
33
+ ---
34
+
35
+ ## 2. Core Metrics (Free-Tier)
36
+
37
+ | Metric | Description |
38
+ |--------|-------------|
39
+ | **ncloc** | Non-comment lines of code |
40
+ | **bugs** | Number of bugs |
41
+ | **vulnerabilities** | Number of vulnerabilities |
42
+ | **code_smells** | Number of code smells |
43
+ | **coverage** | Test coverage (%) |
44
+ | **duplicated_lines_density** | Duplicated lines (%) |
45
+
46
+ ---
47
+
48
+ ## 3. Extended Metrics (When Available)
49
+
50
+ | Metric | Description |
51
+ |--------|-------------|
52
+ | **security_hotspots** | Security hotspots count |
53
+ | **security_hotspots_reviewed** | Hotspots reviewed (%) |
54
+ | **sqale_rating** | Maintainability rating (A–E) |
55
+ | **reliability_rating** | Reliability rating (A–E) |
56
+ | **security_rating** | Security rating (A–E) |
57
+ | **quality_gate_status** | Quality gate status from measures |
58
+ | **complexity** | Cyclomatic complexity |
59
+ | **cognitive_complexity** | Cognitive complexity |
60
+ | **duplicated_blocks** | Duplicated blocks |
61
+ | **lines** | Total lines |
62
+
63
+ ---
64
+
65
+ ## 4. Issues
66
+
67
+ - **Source:** SonarCloud `api/issues/search`.
68
+ - **Per issue:** Key, type, severity, message, component (file), line, rule, effort.
69
+ - **Severities:** BLOCKER, CRITICAL, MAJOR, MINOR, INFO.
70
+ - **UI:** Issues table (e.g. top 50–100), and “Issues by severity” pie chart; total issue count in KPI and in “Issues breakdown” chart (bugs, vulnerabilities, code smells, hotspots).
71
+
72
+ ---
73
+
74
+ ## 5. Quality Score & Rating
75
+
76
+ - **Score:** 0–10, computed from:
77
+ - Bugs (deduction)
78
+ - Vulnerabilities (deduction)
79
+ - Code smells (capped deduction)
80
+ - Quality gate ERROR (deduction)
81
+ - Reliability and security ratings (A=best, E=worst)
82
+ - Coverage ≥ 80% (small bonus)
83
+ - **Rating:** A+, A, B+, B, C+, C, F (from score).
84
+ - **UI:** “Quality Score” KPI card (e.g. X/10 and rating).
85
+
86
+ ---
87
+
88
+ ## 6. Overall Summary
89
+
90
+ - **Status:** Passed / Failed / Unknown (from quality gate).
91
+ - **Metrics summary:** Bugs, vulnerabilities, code smells, coverage, duplication, ncloc (for display in the report/UI).
92
+
93
+ ---
94
+
95
+ ## 7. Recommendations
96
+
97
+ Generated from the analysis (not from SonarCloud API):
98
+
99
+ - **Quality gate failed** → Fix failing quality gate conditions.
100
+ - **Bugs > 0** → Address reported bugs.
101
+ - **Vulnerabilities > 0** → Remediate vulnerabilities.
102
+ - **Code smells > 50** → Reduce code smells for maintainability.
103
+ - **Coverage < 80%** → Increase test coverage toward 80%+.
104
+ - **Duplication > 5%** → Reduce duplicated lines.
105
+
106
+ Each recommendation has priority (HIGH / MEDIUM / LOW), category, and action text.
107
+
108
+ ---
109
+
110
+ ## 8. Dashboard / UI Elements
111
+
112
+ - **KPI cards:** Quality Score, Quality Gate, Lines of Code, Total Issues.
113
+ - **Charts:**
114
+ - Issues breakdown (bugs, vulnerabilities, code smells, security hotspots).
115
+ - Coverage & duplication (%).
116
+ - Issues by severity (BLOCKER, CRITICAL, MAJOR, MINOR, INFO).
117
+ - **Metric tiles:** Lines of code, bugs, vulnerabilities, code smells, security hotspots, duplication, coverage, complexity.
118
+ - **Quality gate conditions** list.
119
+ - **Issues table** (key, rule, severity, file, line, message).
120
+ - **Recommendations** list.
121
+ - **Link** to view project on SonarCloud.
122
+
123
+ ---
124
+
125
+ ## 9. APIs Used (SonarCloud Free Plan)
126
+
127
+ - `GET api/qualitygates/project_status` — Quality gate status and conditions.
128
+ - `GET api/measures/component` — Metric values (free-tier and extended keys).
129
+ - `GET api/issues/search` — Issues list (optional, page size e.g. 100).
130
+
131
+ Project key is derived from `SONAR_ORGANIZATION` and the repo (e.g. `org_repo`). Branches tried: `master`, `main`, then no branch.
132
+
133
+ ---
134
+
135
+ ## 10. Optional: First-Time Scan
136
+
137
+ - If the project is not on SonarCloud (or no metrics yet), the app can:
138
+ - Clone the repo and run SonarScanner (when `SONAR_RUN_SCANNER_IF_MISSING=true`).
139
+ - Or run a fresh scan on each analysis (when `SONAR_ALWAYS_RUN_SCAN=true`).
140
+ - After a scan, the analyzer waits for metrics (configurable wait and polling) and then shows the same points above.
141
+
142
+ ---
143
+
144
+ *This list reflects what is implemented in the Repository Analyzer’s SonarCloud integration (analyzer, client, and UI).*