I’m trying to run sonarqube scanner on PR and master branch for a web app written in typescript and javascript.
ts and tsx files are getting analysed for PR (branch) analysis but when the analysis is run on master branch the ts and tsx files are shown as un-analysed.
code from master branch analysis
Sample action for master branch analysis:
sonarqube:
runs-on: ubuntu-latest
needs: [lint, test]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: SonarQube Scan
uses: SonarSource/[email protected]
env:
SONAR_TOKEN: XX
SONAR_HOST_URL: XX
with:
args: >
-Dsonar.verbose=true
-Dsonar.sources=./src/
-Dsonar.tests=./test/
-Dsonar.projectKey=my_key
-Dsonar.eslint.reportPaths=./reports/eslint.json
-Dsonar.css.stylelint.reportPaths=/reports/stylelint.json
-Dsonar.javascript.lcov.reportPaths=./reports/lcov.info
We have also ensured that tsconfig.json has the necessary includes
"include": [
"**/*.ts",
"**/*.tsx",
"**/*.css",
],
Don’t know what’s going wrong.
The issue was related to an option useUnknownInCatchVariables
that was being used as compiler option in tsconfig.json.
When the scanner was run in debug mode an error was being thrown due to which tsx files were not getting scanned.
06:09:36.583 INFO: Using /github/workspace/./tsconfig.json from sonar.typescript.tsconfigPath property
06:09:36.744 ERROR: Unknown compiler option 'useUnknownInCatchVariables'.
Based on https://community.sonarsource.com/t/typescript-useunknownincatchvariables-compiler-option-causes-main-branch-to-show-up-empty/49349/4?u=abhijeet_vaikar thread, we have to: