SonarTsPlugin icon indicating copy to clipboard operation
SonarTsPlugin copied to clipboard

Sonar analysis shows 0 bugs but reports bugs when output file is used

Open bobsru opened this issue 7 years ago • 5 comments

I installed v1.1.0 SonarTsPlugin plugin in Sonarqube 5.6.6 and my project had the following configuration Typescript: 2.2.0 Sonar-Scanner: 2.8 Tslint: 2.4.5

When I run Sonar-scanner -X, I am able to see that it is executing node command with ts files and outputting to a tmp file. While I cat it, it is always an empty file and then it gets deleted. And no bugs are reported to sonarqube. I copied the node command and ran without --out parameter and I can see the output.

When I run with sonar.ts.tslint.outputPath=opfile.json, then I can see bugs in sonarqube. I am running with administrator permissions. Am I missing something?

bobsru avatar May 12 '17 22:05 bobsru

The only time I've seen that happening has been when the user account running the analysis doesn't have write access to the folder being analysed - i.e. a build agent in a CI environment running as a limited user account. But if you're running as administrator that's that out the window!

If you do use the --out parameter (pointing it to some random folder), presumably you're getting output in that situation? Is that how you generated opfile.json which subsequently went on to work, or did you just pipe the output of the manual command run into a file?

Pablissimo avatar May 15 '17 09:05 Pablissimo

Yes, you are right. I gave --out opfile.json to the node command and I used that in sonar.ts.tslint.outputPath parameter.

bobsru avatar May 15 '17 12:05 bobsru

The only time I've seen that happening has been when the user account running the analysis doesn't have write access to the folder being analysed - i.e. a build agent in a CI environment running as a limited user account. But if you're running as administrator that's that out the window!

This is exactly my config and I'm getting the same behavior. I'm happy to get my bugs now :D I don't really need it, but I'm not able to see the opfile.json, so my config looks pretty weird... Is there a way to make things cleaner?

ZoeThivet avatar Jun 17 '17 08:06 ZoeThivet

Not sure what you mean - you can simulate what the plugin is doing by:

  • Run the scanner with the -X flag (to get diagnostic info)
  • Copy the command line the plugin reports will be used to run the tslint analysis (you will need to change the target of the --out parameter since it'll refer to a folder that, by the time the analysis has finished, won't exist0
  • Run that - the output you get could then be passed via the sonar.ts.tslint.outputPath parameter if desired

Pablissimo avatar Jun 18 '17 11:06 Pablissimo

Alright, I did this. I was able to access the opfile.json running this command. So does it mean than, when we use the sonar.ts.tslint.outputPath parameter un Jenkins, the opfile.json is just a temporary file? Is it normal that it's deleted in the end of the build?

ZoeThivet avatar Jun 18 '17 22:06 ZoeThivet