soprasteria / sonar-report

Generates an html report from SonarQube
GNU General Public License v3.0
89 stars 43 forks source link

Report fails with arg --quality-gate-status when there is just one analysis #266

Open danielFesenmeyer opened 8 months ago

danielFesenmeyer commented 8 months ago

For a new project (when there is just one analysis), report generation fails when the arg --quality-gate-status is specified. When a second analysis has been done, the same report succeeds.

Observed with sonar-report version 3.1.3 and sonarqube docker installation based on sonarqube image sonarqube:10.4.1-community.

The following error occurs:

Error while getting quality gate status :  - Cannot read properties of undefined (reading 'date') -  -  - 
file:///mydir/node_modules/.pnpm/sonar-report@3.1.3/node_modules/sonar-report/index.js:405
        json.projectStatus.period.date
                                  ^

TypeError: Cannot read properties of undefined (reading 'date')
    at generateReport (file:mydir/node_modules/.pnpm/sonar-report@3.1.3/node_modules/sonar-report/index.js:405:35)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The reason is that the API result does not contain the period entry, in case there is just one analysis.

I know this is a corner case, but I think it is possible to provide meaningful quality gate information (at least in case of overall quality gate definitions), even when no period information is available. WDYT?

stealthrabbi commented 2 months ago

I am also seeing this issue.