generator-jhipster
generator-jhipster copied to clipboard
Add sonar report to PRs.
Overview of the feature request
Add sonar reports to PRs to avoid regressions. It's not possible to use sonar cloud due to token restrictions. We need to implement our own solution using sonar at docker.
Motivation for or Use Case
Keep the generated code quality high.
Related issues or PR
- [ ] Checking this box is mandatory (this is just to show you read everything)
Adding bug bounty to this as we seem to always find Sonar issues after the fact.
Would adding eslint-plugin-sonar
help us catch these issues sooner?
Which code do you want to analyze on PRs? Generated code or the generator code itself?
Generated code means a lot of sonar invocations on each CI project.
Which code do you want to analyze on PRs? Generated code or the generator code itself?
Generated code
Generated code means a lot of sonar invocations on each CI project.
The idea is to keep limited to ngx-default for now. It’s the only one we have sonarcloud.
We already generate the previous (main) code every time. The idea is:
- cache junit/maven results at main.
- load junit/maven results at PRs.
- run sonar at loaded results.
- run sonar at new code results.
- should reports at console and fail when new issues is found.
One suggestion would be to have a look at this folder: https://github.com/jhipster/jhipster-lite/tree/main/tests-ci and specially this script sonar.sh
Import the repo into Sonar Cloud and it will work automatically:
-
Analyze default branch firstly (automatically).
-
Every Pull Request will be analyzed automatically, and comment the report: see https://github.com/zhyd1997/generator-jhipster/pull/4#issuecomment-1528768481

Thanks for your suggestion @zhyd1997 But the last time I tried, it doesn't detect the code smells. See my try: https://github.com/jhipster/jhipster-lite/pull/374
So it will always show false positive, that's why in JHipster Lite project, I prefer using a stable sh script to do the job
Hi @pascalgrimaud
It works now!

https://github.com/zhyd1997/generator-jhipster/pull/4#issuecomment-1528773778
Oh, I'll give it a try to JHLite repository Thanks @zhyd1997 :-)))
For your information, just tested it this morning, and it's still broken. See my try here: https://github.com/jhipster/jhipster-lite/pull/6131
Update: https://github.com/jhipster/jhipster-lite/pull/6131#issuecomment-1530996564