We hadn’t sonar in use for one month, so recently we updated sonarqube to version 8.1.
With that update we migrated our database to another server (before it was on the same server).
On the old configuration a scan took about 2 minutes.
Now with the new setup scanning takes a half an hour for the typescript files. In 10 seconds he scans 13-16 files.
I also tested it locally on my computer which doesn’t change anything. The server CPU isn’t even used with its full capacity.
The command for running the scanner is:
sonar-scanner.bat -Dsonar.test.inclusions=**/*.test.*,**/*.spec.*,**.int.* -Dsonar.projectKey=frontend -Dsonar.projectName=Frontend -Dsonar.host.url=https://our.domain.com/ -Dsonar.login=******** -Dsonar.language=ts,html,css
Could you post debug logs (with
We recently migrated TypeScript analysis to a new frontend and it seems to be slow on huge projects. How many TS files and tsconfigs do you have?
Try to set
Not yet, but I hope to investigate your problem this week. I will update this thread.
One thing I noticed is that you use windows-1252 encoding. Could you experiment with using utf-8?
How can i change the encoding in the sonarscanner? Our files should be utf-8.
To set the encoding, you need to add this in your sonar-project.properties or on the sonar-scanner command line:
I suggest to disable the Duplication engine that is consuming by definition a lot of time and is not your priority:
sonar.language is having no effect. The parameter was dropped with SonarQube 7.7.
So finally, I would:
- use SonarQube 8.2 (the latest and greatest)
- execute that command at the root of your TypeScript project:
thank you @Alexandre_Gigleux for your help. Sadly i have still the same issues even after i applied your suggestions.
I updated SonarQube to 8.2, i updated the sonar-scanner-cli to the latest version and i set sonar.cps.exclusions=** which the scanner is caring.
But i have still problems that the scanner is too slow (28 files in 10 seconds).
I hope to hear from you.
could you share logs of analysis with encoding fixed to UTF-8?
I have a similar problem. We are using
- SonarQube Enterprise 7.9.1
- SonarJS 6.1.0
- Sonarqube-scanner 2.6.0 with the newest sonar-scanner-cli
The project contains more than 4900 typescript source files and over 20 tsconfig.json files.
Looking at the log, most of the steps (e.g. indexing files, matching files to tsconfig.json, etc) only take few seconds to finish. But when it comes to the analysis of the >4900 typescript files, it takes ~2 hours.
Do you have an idea where this long duration comes from?
My guess would be that it has to do with sending AnalysisRequest and/or getting AnalysisResponse in TypeScriptSensor.java but I might be wrong.
Thanks in advance for your help!
First, are your files in UTF-8?
Our current guess is that there is a lot of memory used, so a lot of time is takes by allocating. But so far we didn’t get any reproducer in our hands so we can’t debug and improve that.
You would help us a lot if you could provide us sources of your project, privately of course.
i would like to provide you our project. But unforntunately our project (enterprise) is not to give it to someone… my boss forbid it explicitly.
Maybe i can reproduce it with another small project. But that needs a lot of time.
Maybe @To1 can hand over something?
I just tried scanning the angular project which results in 100 files/10 seconds. Our project has 25-30 files/10 seconds which is a lot less.
@Lena yes, they are in UTF-8 and we also set -Dsonar.sourceEncoding=UTF-8.
I’m really sorry, I’m in the same situation as Daniel. I cannot / must not provide the sources either.
@danieldaeschle which version of SonarQube did you use before updating to 8.1? Did it still use SonarTS or already SonarJS then?
We used 7.9 LTS Version before. If i can remember corrently, it was SonarTS.
Here is a Repository with our Project structure in obfuscated.
The typescript files doesn’t contain real code.
In this state SonarScanner is slow (6 files per second). To speed it up: Remove the
typings directory either through removing it in the
tsconfig, removing the directory itself or copy all files from
typings and remove the
After that SonarScanner scans 30 files per second which is 5 times faster than before!
With out original project the scanner scans 2-3 files per second.
I hope it helps you to fix that bug.
I didn’t have so far any time to investigate your reproducer, but that’s certainly on my todo.
I will ping you as soon as I have any info.
Thanks for the help anyway!
Hey @danieldaeschle ,
As I wrote you in private, I’m not able to reproduce slow analysis with your example project
Your 2000 files take ~35sec for me, removing
typings makes it just couple of seconds faster.