Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: exclude test and mock files from sonar code analyses #967

Merged
merged 1 commit into from
Aug 15, 2023

Conversation

dmijatovic
Copy link
Contributor

Exclude folders and files from Sonar analyses

Changes proposed in this pull request:

  • Do not analyse test, mocks and assets folders
  • Define all test files 

How to test:

  • De sonar analyses should now exclude large number of irrelevant files from it's analyses.

PR Checklist:

  • Increase version numbers in docker-compose.yml
  • Link to a GitHub issue
  • Update documentation
  • Tests

@sonarqubecloud
Copy link

[rsd-frontend] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Collaborator

@ewan-escience ewan-escience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use sonar.coverage.exclusions instead of sonar.exclusions, see the section Refined scope settings on https://docs.sonarcloud.io/advanced-setup/analysis-scope/.

@dmijatovic
Copy link
Contributor Author

dmijatovic commented Aug 15, 2023

You need to use sonar.coverage.exclusions instead of sonar.exclusions, see the section Refined scope settings on https://docs.sonarcloud.io/advanced-setup/analysis-scope/.

@ewan-escience Yes, I saw that. The exclusion I defined is not only for coverage but for all sonar analyses. Defined folders should be excluded from Sonar analyses completely not only for the coverage.

For the coverage to be identical to local Jest report we would need to use inclusion option but that option does not exists in Sonar for the coverage. I am accepting that there will be some difference :-(. I expect if the test files are defined properly the stats will improve. From there we can decide on next steps.

Copy link
Collaborator

@ewan-escience ewan-escience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the same page, it says

The test scope parameters (source.tests , sonar.test.exclusion, and sonar.test.inclusion) do not have anything to do with setting up test coverage reporting (see Test Coverage).

So you will not get the desired result this way. It will be worse, because the test code should be analysed but not be in the test coverage.

Copy link
Collaborator

@ewan-escience ewan-escience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see if it works...

@dmijatovic dmijatovic merged commit c0402c3 into main Aug 15, 2023
@dmijatovic dmijatovic deleted the sonar-frontend branch September 4, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants