Warnings in analysis

Hi,

New to SonarQube and trying it out for the first time. I have recently analysed my project and it seems to run fine, but I have a Last analysis has warnings error, alongside errors in the run logs.

Pre-requisite knowledge

  • ALM used = Gitlab
  • CI system used = gitlab-ci
  • Scanner command used when applicable (private details masked) = sonar-scanner -Dsonar.clearCache=true -X
  • Languages of the repository = Typscript, Javascript, Vue

Steps to reporoduce

Running sonar-scanner through our default pipeline where we the below is our SonarQube job:

sonarcloud-check:
  stage: SonarQube
  image:
    name: sonarsource/sonar-scanner-cli:latest
    entrypoint: [""]
  script:
    - sonar-scanner -Dsonar.clearCache=true -X
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
      when: on_success
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
      when: on_success
  needs: []

Error observed:

Analysis seems to run perfectly well apart from the following errors.

On my analysis page it suggest that the last analysis has warnings, with a bunch of errors each displaying

Failed to create TypeScript program with TSConfig file /builds/*****/tsconfig.json. Highest TypeScript supported version is 5.7.2.

where all the errors have a tsconfig.json in a differen place. Here is an example of the tsconfig.json

{
  "compilerOptions": {
    // "verbatimModuleSyntax": false,
    "module": "NodeNext",
    "target": "ES2022",
    "declaration": true,
    "outDir": "./dist",
    "resolveJsonModule": true,
    "baseUrl": "./src",
    "paths": {
      "@/*": [
        "*"
      ]
    },
    "esModuleInterop": true,
    "strictNullChecks": true,
    "strict": true,
    "strictPropertyInitialization": false,
    "moduleResolution": "NodeNext"
  },
}

and here are the debug logs of the error

14:07:13.999 ERROR Error: Cannot read file '/<path>/apps/mcr-client/.nuxt/tsconfig.json'.
14:07:14.000 ERROR     at _Je (/<path>/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:2115:47046)
14:07:14.000 ERROR     at rPf (/<path>/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:2115:47226)
14:07:14.000 ERROR     at _Bt (/<path>/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:2115:47739)
14:07:14.000 ERROR     at Kqt (/<path>/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:2115:74094)
14:07:14.001 ERROR     at MessagePort.<anonymous> (/<path>/.scannerwork/.sonartmp/bridge-bundle/package/bin/server.cjs:2115:78271)
14:07:14.001 ERROR     at [nodejs.internal.kHybridDispatch] (node:internal/event_target:816:20)
14:07:14.001 ERROR     at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)
14:07:14.001 ERROR Failed to create program: Cannot read file '/<path>/apps/mcr-client/.nuxt/tsconfig.json'.

Any help would be much appreciated, thanks!

1 Like

Hello @sukhrajsg,

sorry for the late response.

Are the dependencies installed during analysis? ie did you run npm ci?

The tsconfig.json file that you provided does not seem to point to any other tsconfig.json via references or extends, so I would expect that such tsconfig would not fail during analysis. As the error comes from the analyzer failing to find a tsconfig:

14:07:14.001 ERROR Failed to create program: Cannot read file '/<path>/apps/mcr-client/.nuxt/tsconfig.json'.

Does that file actually exist in the filesystem during analysis?

Cheers,
Victor