Cannot scan typescript files in angular monorepo

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this
"sonarqube-scanner": "^2.7.0"
"typescript": "^3.5.3"

I am trying to run sonarqube on an angular monorepo where the structure is as follows:

Project structure:

...
/projects
- /a
  - ...
  - /src
  - tsconfig.app.json
  - tsconfig.spec.json
- /b
  - ...
  - /src
  - tsconfig.lib.json
  - tsconfig.spec.json
tsconfig.json
angular.json
...

Root level tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2018", "dom"],
    "paths": {
      "@project-x/a": ["projects/a/src/public-api"],
      "@project-x/b": ["projects/b/src/public-api"],
      "@project-x/c": ["projects/c/src/public-api"]
    }
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

sonar-project.properties

...
# source directories to include 
sonar.sources=projects/a, projects/b, projects/c
sonar.typescript.tsconfigPath=tsconfig.json

# test directories to exclude
sonar.exclusions=projects/**/*.config.js, projects/**/*.spec.js, projects/**/*.conf.js, projects/**/e2e/**
sonar.test.inclusions=projects/**/*.spec.ts

When I run sonar-scanner I get that it is retrying to to analyze a file until memory blows up:

INFO: Sensor SonarJS Coverage [javascript] (done) | time=227ms
INFO: Sensor TypeScript analysis [javascript]
INFO: Using TypeScript at: '/Users/xxx/Projects/xxx/node_modules/@compodoc/ngd-core/node_modules'
INFO: Using /Users/xxx/Projects/xxx/tsconfig.json from sonar.typescript.tsconfigPath property
INFO: 420 source files to be analyzed
INFO: Analyzing 420 files using tsconfig: /Users/xxx/Projects/xxx/tsconfig.json
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
...

It seems to be solved if I add "includes": ["projects/(a | b | c)/**/*.ts] to the root level tsconfig.json, but then I get that it skips all the files to analyze:

...
INFO: 420 source files to be analyzed
INFO: Skipping 420 files with no tsconfig.json
INFO: 420/420 source files have been analyzed

Hi Kevin, welcome to the SonarSource Community!

You say “until memory blows up” but it seemed as though this analysis was on track to give you the results you were hoping for. Can you simply try to increase heap memory used by the scanner and see how you fare?

I added this property to the sonar-project.properties:

sonar.javascript.node.maxspace=4096

and still got

INFO: 420 source files to be analyzed
INFO: Analyzing 420 files using tsconfig: /Users/xxx/Projects/xxx/tsconfig.json
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
INFO: 0/420 files analyzed, current file: projects/xxx/src/lib/_shared/index.ts
ERROR: eslint-bridge Node.js process is unresponsive. This is most likely caused by process running out of memory. Consider setting sonar.javascript.node.maxspace to higher value (e.g. 4096).
ERROR: Failure during analysis, Node.js command to start eslint-bridge was: {NODE_PATH=/Users/xxx/Projects/xxx/node_modules/@compodoc/ngd-core/node_modules} /Users/xxx/Projects/xxx/.scannerwork/.sonartmp/eslint-bridge-bundle/package/node_modules/run-node/run-node --max-old-space-size=4096 /Users/xxx/Projects/xxx/.scannerwork/.sonartmp/eslint-bridge-bundle/package/bin/server 60664
java.lang.IllegalStateException: eslint-bridge is unresponsive