T-SQL in Sonar - valid expression makes scan fail on sql file

Hi,

We have a Developer Edition of SonarQube 10.3 and use it for .NET projects, but I don’t think that matters for the question…

We have some key logic in stored procedures on MS SQL Server. Lots of them (dozens) use perfectly correct T-SQL code:
trim('%' from @percentNumberWithPercentSign)
But it is not supported for scanning by Sonar.

As a result T-SQL Sensor fail to scan the T-SQL file. So entire file - dozens, hunderds of T-SQL lines - are not scanned. That affects every T-SQL file that use that expression. It’s a warning in the build log:

build	06-Feb-2024 09:26:59	WARN: Unable to parse file 'Something.sql' : Parse error at line 269 column 111:
build	06-Feb-2024 09:26:59	269:         declare @someVar decimal(5,2) =  CONVERT(decimal(5,2), trim('%' from @percentNumberWithPercentSign))/100
build	06-Feb-2024 09:26:59	                                                                             ^

Is improvement of T-SQL support on your todo list for foreseeable future?

Kind regards,
Michal Gruda

Hey there.

I don’t anticipate we’ll tackle it soon, but we have a ticket open: https://sonarsource.atlassian.net/browse/SONARTSQL-190

And I"ve linked this thread to it!

Hey Colin,

Thanks for letting me know, happy to hear it’s already in the backlog,

Bests,
Michal

The newest version of the TSQL analyzer fixes the parsing of TRIM. It will soon be available on SonarQube.