chore: add SonarCloud integration#70
Merged
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds SonarCloud static analysis by introducing a SonarCloud scan step to the CI test workflow and configuring project-level Sonar settings via a new sonar-project.properties file. Sequence diagram for CI test workflow with SonarCloud scansequenceDiagram
actor Developer
participant GitHub
participant GitHubActions
participant TestJob
participant SonarCloudAction
participant SonarCloud
Developer->>GitHub: Push or open PR
GitHub->>GitHubActions: Trigger test workflow
GitHubActions->>TestJob: Start job (uses test.yml)
TestJob->>TestJob: Install dependencies
TestJob->>TestJob: Run tests and generate coverage lcov.info
TestJob->>SonarCloudAction: Execute SonarSource_sonarcloud_github_action_v5
SonarCloudAction->>GitHubActions: Read SONAR_TOKEN secret
SonarCloudAction->>SonarCloud: Send analysis using sonar-project.properties
SonarCloud-->>SonarCloudAction: Analysis results stored and quality reports
SonarCloudAction-->>GitHubActions: Job status
GitHubActions-->>GitHub: Report workflow status on commit/PR
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Hardcoding
sonar.projectVersion=2.0.0insonar-project.propertiesmay quickly drift from the actual app version; consider sourcing this from your build (e.g., package.json or a CI variable) or omitting it to avoid version mismatches. - Instead of excluding
**/*.spec.tsand**/*.test.tsviasonar.exclusions, consider configuring them as test sources withsonar.testsso you still get static analysis on test code while keeping the coverage and metrics separation clear.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Hardcoding `sonar.projectVersion=2.0.0` in `sonar-project.properties` may quickly drift from the actual app version; consider sourcing this from your build (e.g., package.json or a CI variable) or omitting it to avoid version mismatches.
- Instead of excluding `**/*.spec.ts` and `**/*.test.ts` via `sonar.exclusions`, consider configuring them as test sources with `sonar.tests` so you still get static analysis on test code while keeping the coverage and metrics separation clear.
## Individual Comments
### Comment 1
<location path="sonar-project.properties" line_range="7-10" />
<code_context>
+sonar.projectVersion=2.0.0
+
+sonar.sources=src
+sonar.exclusions=**/node_modules/**,**/dist/**,**/*.spec.ts,**/*.test.ts
+
+sonar.javascript.lcov.reportPaths=coverage/lcov.info
</code_context>
<issue_to_address>
**suggestion (testing):** Revisit exclusions to avoid unintentionally hiding test code from Sonar or missing other generated directories.
Excluding `*.spec.ts` and `*.test.ts` means Sonar won’t see tests at all, which also limits test-level metrics and can skew coverage. Consider using `sonar.test.inclusions` for test patterns, keeping `sonar.sources` for production code, and reserving `sonar.exclusions` for generated/third‑party directories (e.g. `**/coverage/**`, `**/build/**`).
```suggestion
sonar.sources=src
sonar.tests=src
sonar.exclusions=**/node_modules/**,**/dist/**,**/coverage/**,**/build/**
sonar.test.inclusions=**/*.spec.ts,**/*.test.ts
sonar.javascript.lcov.reportPaths=coverage/lcov.info
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Adds SonarCloud static analysis to the project.
Changes
sonar-project.propertieswith project keyHealth-RI_FAIRDataPoint-clientand organizationhealth-ri.github/workflows/test.yml) usingSonarSource/sonarcloud-github-action@v5Setup required
Add a
SONAR_TOKENsecret to the repository (Settings → Secrets → Actions). Generate the token in your SonarCloud account under Security settings.Summary by Sourcery
Integrate SonarCloud static analysis into the project and CI pipeline.
Build:
CI:
Chores: