0
votes

I'm trying to analyse a SQL server SSDT database project with SonarCloud but running into some issues.

We are using VSTS with the SonarCloud tasks set up around the build to listen, build, analyse and publish to our SonarCloud account.

Build Process

It runs successfully but doesn't scan all the project, it scans and analyses a few stand-alone .SQL files recognising them as t-sql files but none of the actual stored procedures.

Please can anyone help on how to include the stored procedures in the code analysis?

Many Thanks

1
See this SO question. Why do you think the plugin needed is installed in SonarCloud? - Jeroen Heier
What's the result like? (Code tab) What's the result you want? A simple result: sonarcloud.io/… - starian chen-MSFT
@JeroenHeier Thanks for the reply. I think the plugin is installed already because its analysing some of the .sql scripts (stand-alone one time run scripts), but not any of the stored procedures, which I dont understand why. - DataNovice
@starianchen-MSFT thanks for the reply. The result in the Code tab looks to pick up the database folder, and a couple of additional folders underneath. However the main schema "dbo" folder is not being picked up, which contains the bulk of the stored procedures. We removed the .sql extension type from the PL/SQL language selection and added it to the TSQL language selection, and can confirm the code which is being picked up is being analysed as TSQL. - DataNovice
@starianchen-MSFT - from the example you linked to a similar situation would be where the Script.PostDeployment1.sql has been picked up but prorcedure1.sql is not. - DataNovice

1 Answers

1
votes

I found the answer to this. The MSBuild SonarCloud integration doesn't work for database projects, you have to use the Sonar Scanner option when configuring the listener task.

Edit: after getting in touch with SonarCloud they have raised the issue and provided a workaround which you can find via the link below

https://github.com/SonarSource/sonar-scanner-msbuild/issues/463