Parse error in sonar scanner for TSQL files


(Swati Jasuja) #1


I am using SonarQube version 6.5. I am getting an error while running the sonar-scanner on my tsql files on command line as " Unable to parse file : Parse error at line no column no:

I am getting this error for many files (all files are TSQL files) and I guess these files are skipped from the scanning process. When I checked few of the files I did not find any issue at the given line number.

Can anyone please help me understand the meaning of this error and how to avoid it or how to remove it?


(Nicolas Bontoux) #2

Hi Swati,

The parse-error means that the TSQL code analyzer (built in SonarQube) was able to completely process the code file, potentially preventing accurate detection of issues.

It’s normal that you don’t necessarily see an issue in SonarQube at that line, that would depend on whether you do track parsing failures or not. For example:

A parse-error on valid code is an anomaly, and the SonarSource staff will be happy to improve the analyzer if you provide detailed steps to reproduce the parse-error. A good practice is to share a minimal source file that causes the same error when analyzer with SonarQube.

Last but not least: make sure to use the last version of the TSQL analyzer, .

(Swati Jasuja) #3

Hi Nicolas,

I am scanning TSQL files which have default encoding as “Western European (Windows) - Codepage 1252” and the encoding I am using in file is UTF-8. Could that be the reason for this error? If so, what encoding should I use here?

Also, what I understand from your reply is that these files which have a parse error will be scanned but static code issues will not be detected and pointed out correctly. Is that correct?

(Nicolas Bontoux) #4

Hi Swati,

A parse error means the file was not successfully analyzed in its entirety, so yes it does mean that issue detection may not be exhaustive.

Good catch ! Yes using the wrong encoding can definitely cause problems. Check-out sonar.sourceEncoding analysis parameter , can definitely help out (windows-1252 might be worth trying).

(Swati Jasuja) #5


I was able to rule out the “Invalid character encountered in file at line no for encoding UTF-8” error by changing the encoding to “windows-1252”, but still getting same parse errors for the same files as I was getting when using UTF-8. I suppose the parse errors are not because of encoding and mean something else.

Below is the snapshot of the parse error. As seen, on command line the error is pointed out but in the code there is no invalid character. Any inputs would be really helpful. Thanks.

(Swati Jasuja) #6

Image of the code:


(Nicolas Bontoux) #7


Before anything: are you using the latest version of TSQL analyzer ? (note: might have to upgrade SonarQube too as the 6.5 you mentioned is fairly old)

(Pierre-Yves Nicolas) #8


Our TSQL parser does not support service broker statements like RECEIVE.
We will handle that: SONARTSQL-136

Thanks for the feedback.