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