feat(scorecard): Add SonarQube metric providers#2576
feat(scorecard): Add SonarQube metric providers#2576christoph-jerolimov wants to merge 10 commits intoredhat-developer:mainfrom
Conversation
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
…ues, and security Add four metric providers to the scorecard-backend-module-sonarqube plugin: - Quality gate status (boolean) - Open issues count (number) - Security rating (number, A=1 to E=5) - Security issues/vulnerabilities count (number) Includes SonarQubeClient, config, factory, example catalog entity, and unit tests. SonarQube baseUrl defaults to https://sonarcloud.io; token is optional for public projects. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
|
Important This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior. Changed Packages
|
…config schema - Add config.d.ts with typed config schema supporting default + named instances - Refactor SonarQubeClient to resolve instance by name from sonarqube.instances[] - Parse sonarqube.org/project-key annotation for optional instance prefix (instance/project-key) - Use apiKey + authType (Basic/Bearer) from config.d.ts instead of token - Falls back to default instance when no instance prefix in annotation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
SonarQube expects Basic auth as base64(apiKey:) with an appended colon. Bearer auth passes the apiKey directly without encoding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
Review Summary by QodoAdd SonarQube metric providers for scorecard with multi-instance support
WalkthroughsDescription• Add SonarQube backend module with four metric providers - Quality gate status (boolean) - Open issues count (number) - Security rating (number, A=1 to E=5) - Security issues/vulnerabilities count (number) • Support multiple SonarQube instances with named configuration • Implement SonarQubeClient with Basic/Bearer auth and base64 encoding • Include comprehensive unit tests and configuration schema • Add README documentation and example catalog entity Diagramflowchart LR
Config["Config Schema<br/>config.d.ts"]
Client["SonarQubeClient<br/>API Integration"]
BoolProvider["BooleanMetricProvider<br/>Quality Gate"]
NumProvider["NumberMetricProvider<br/>Issues/Rating"]
Factory["MetricProviderFactory<br/>Provider Creation"]
Module["Backend Module<br/>Registration"]
Config -->|"Instance Config"| Client
Client -->|"API Calls"| BoolProvider
Client -->|"API Calls"| NumProvider
Factory -->|"Creates"| BoolProvider
Factory -->|"Creates"| NumProvider
Module -->|"Registers"| Factory
File Changes1. workspaces/scorecard/plugins/scorecard-backend-module-sonarqube/config.d.ts
|
Code Review by Qodo
1. Instance apiKey wrongly required
|
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
workspaces/scorecard/plugins/scorecard-backend-module-sonarqube/package.json
Outdated
Show resolved
Hide resolved
workspaces/scorecard/plugins/scorecard-backend-module-sonarqube/config.d.ts
Show resolved
Hide resolved
workspaces/scorecard/plugins/scorecard-backend-module-sonarqube/src/clients/SonarQubeClient.ts
Show resolved
Hide resolved
...gins/scorecard-backend-module-sonarqube/src/metricProviders/SonarQubeNumberMetricProvider.ts
Outdated
Show resolved
Hide resolved
…blic Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
Add metrics for code coverage, code duplications, security review rating, security hotspots, reliability rating/issues, and maintainability rating/issues. Refactors calculateMetric to use a data-driven API key mapping table instead of a switch statement, and deduplicates rating thresholds into a shared constant. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
…Utils Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
HusneShabbir
left a comment
There was a problem hiding this comment.
@christoph-jerolimov this will unblock your CI
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
|



Hey, I just made a Pull Request!
New module with new metrics from sonarqube/sonarcloud; agentic-eng. by @imykhno, myself and Claude. 😀
TODOs✔️ Checklist