- Sonarcloud task in Azure Devops
- error observed
ERROR: Failed to analyze file [name_of_file.ts]: Cannot read property 'parent' of null
Could you share tracktrace of this error? (at least I expect there should be one)
Also example of such code with
• will help us.
there’s no stacktrace of the error in the prompt, the analysis only prints the error in this case.
Actually I check and one of the files that is failing doesnt contain the
• inside a string, but my guess is that it has to be with a weird character because previously I was having problems with files in UTF-8-BOM encoding instead of UTF-8, seems like a regression in the static analysis tool, because the same code was able to be analyzed before with success.
Could you provide a file reproducing this problem? (that’s possible privately)
Otherwise without stacktrace (superweird there is no one) it will be hard to investigate
Ok, I will send one example
Unfortunately we didn’t manage to reproduce the problem. Let’s see if somebody else will face the same issue.
We had the same error with the character ≠ in the comments. Once that character was changed into != the error was gone.
I still can’t reproduce
Can you provide versions of Node and TypeScript you are using?
And also could you provide the code that reproducing the problem? Just putting
≠ in the comment didn’t produce the error for me.
and ts file ?
required-documents.component.ts.txt (19.2 KB)
I tried to reproduce the issue, and I it doesn’t fail for me. Could you post full log of analysis (privately if needed). I am mostly interested in following line
17:30:18.330 DEBUG: 'src/required-documents.component.ts' generated metadata with charset 'UTF-8'
i.e. what is the detected encoding for the file.
Also, you can try to set the encoding by using
The warnings in my pipeline are fixed now after adding sonar.sourceEncoding to the settings, So it seems that this is needed with the new SonarJS static scanner since the previous version of the scanner was not giving me those warnings, perhaps UTF-8 was default before
Setting the encoding by using
sonar.sourceEncoding=UTF-8 did the trick, thanks!