Sonarscanner failed to scan a tsql file with parse error

tsql

(Hari) #1

Hi I just installed sonarqube developer edition yesterday and installed latest sonar scanner to scan my sql server code using sonarTSQL code analyzer.
I simply tried to scan sample code but getting below error and stopped scanning further. Below is the error from sonar scanner. Appreciate any help.

WARN: Unable to parse file 'C:/ 001-1-DDL_app_test_lnr.tsql' : Parse error at line 2 column 30:
 
1:
2:  CREATE FUNCTION my_function RETURN PLS_INTEGER AS
                                                                 ^
3: BEGIN
4:   RETURN 42;

(Alban Auzeill) #2

Hi Hari,

If I add “()” after function name, “S” at RETURN and “END” at the end, the code is parsed by SonarTSQL without error.

CREATE FUNCTION my_function() RETURNS PLS_INTEGER AS
BEGIN
RETURN 42;
END

And it matches specification: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-2017

Could you execute your tsql file on your SQL Server to check if there is a syntax error?
Which is your SQL Server version?

Regards,
Alban