Sonar Scanner T-SQL unable to parse file (drop synonym)

  • Hello, i’m using SonarQube Developer edition integrated with azure devops. During parsing (azure devops task “Run Code Analysis” version 5.19.0) my T-SQL code fails with the message that I will detail at the end of the post.
  • how is SonarQube deployed: zip, Docker, Helm
    –zip in Windows Server
  • what are you trying to achieve
    –scan t-sql files for static code analysis (SQL SERVER 2019 syntax)
  • what have you tried so far to achieve this
    –Sonar scanner analyzer with the .sql file using TSQL analyzer feature.

Error message:

INFO: Sensor T-SQL Sensor [tsql]
INFO: Sensor T-SQL Sensor is restricted to changed files only
INFO: 1 source files to be analyzed
WARN: Unable to parse file '/C:/XXX/20240209_test_synonym.sql' : Parse error at line 2 column 6:

1: IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_test]') AND type IN (N'SN'))
2: DROP SYNONYM [dbo].[usp_test]
3: GO
4: CREATE SYNONYM [dbo].[usp_test] FOR [dbo].[usp_test_final]

INFO: 1/1 files, last analyzed (188 ms): XXX/20240209_test_synonym.sql
INFO: Sensor T-SQL Sensor [tsql] (done) | time=891ms

Please confirm, if any other information required.
Thank you! (327 Bytes)

Hello @pabseb,

Thank you for raising this issue.
I was able to reproduce it.

I have created a ticket in our backlog so we can tackle it in the future.

Have a nice day!

1 Like