generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Add sonar report to PRs.

Open mshima opened this issue 2 years ago • 4 comments

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)

mshima avatar Aug 18 '22 17:08 mshima

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?

mraible avatar Aug 28 '22 17:08 mraible

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.

gmarziou avatar Aug 28 '22 19:08 gmarziou

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.

mshima avatar Aug 28 '22 19:08 mshima

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

pascalgrimaud avatar Aug 29 '22 11:08 pascalgrimaud

Import the repo into Sonar Cloud and it will work automatically:

  1. Analyze default branch firstly (automatically). Screenshot 2023-04-29 at 19 44 15

  2. Every Pull Request will be analyzed automatically, and comment the report: see https://github.com/zhyd1997/generator-jhipster/pull/4#issuecomment-1528768481

Screenshot 2023-04-29 at 19 45 31

zhyd1997 avatar Apr 29 '23 11:04 zhyd1997

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

pascalgrimaud avatar Apr 29 '23 12:04 pascalgrimaud

Hi @pascalgrimaud

It works now!

Screenshot 2023-04-29 at 20 10 06

https://github.com/zhyd1997/generator-jhipster/pull/4#issuecomment-1528773778

zhyd1997 avatar Apr 29 '23 12:04 zhyd1997

Oh, I'll give it a try to JHLite repository Thanks @zhyd1997 :-)))

pascalgrimaud avatar Apr 29 '23 12:04 pascalgrimaud

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

pascalgrimaud avatar May 02 '23 07:05 pascalgrimaud

Update: https://github.com/jhipster/jhipster-lite/pull/6131#issuecomment-1530996564

zhyd1997 avatar May 02 '23 07:05 zhyd1997