Since a few weeks, sonar lint throws the following errors on code analysis. It looks like there is something doing checks for CSS files on cshtml (Razor Template) files, but is bugged out by the Razor syntax. I’m not sure what to do about it and would like the false errors to disappear. If the css parser can’t handle Razor files, it probably shouldn’t scan such files in the first place. An excerpt from the build output:
##[section]Starting: Run code analysis
==============================================================================
Task : Run Code Analysis
Description : Run scanner and upload the results to the SonarCloud server.
Version : 1.6.3
Author : sonarsource
Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.
[More Information](http://redirect.sonarsource.com/doc/install-configure-scanner-tfs-ts.html)
==============================================================================
[command]C:\VSTS2\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.7.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
12:11:40.749 12:11:40.749 WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\VSTS2\_work\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.7.0\classic-sonar-scanner-msbuild\sonar-scanner-3.3.0.1492\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\VSTS2\_work\36\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.3.0.1492
...
INFO: ------------- Run sensors on module ...
INFO: Sensor SonarCSS Metrics [cssfamily]
INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=72ms
INFO: Sensor SonarCSS Rules [cssfamily]
##[error]ERROR: Failed to parse [...]/site.css, line 106, Unknown word
ERROR: Failed to parse [...]/site.css, line 106, Unknown word
##[error]ERROR: Failed to parse [...].cshtml, line 106, Unclosed bracket
ERROR: Failed to parse [...].cshtml, line 106, Unclosed bracket
##[error]ERROR: Failed to parse [...].cshtml, line 34, At-rule without name
ERROR: Failed to parse [...].cshtml, line 34, At-rule without name
##[error]ERROR: Failed to parse [...].cshtml, line 64, At-rule without name
ERROR: Failed to parse [...].cshtml, line 64, At-rule without name
##[error]ERROR: Failed to parse [...].cshtml, line 147, At-rule without name
ERROR: Failed to parse [...].cshtml, line 147, At-rule without name
##[error]ERROR: Failed to parse [...].cshtml, line 14, At-rule without name
ERROR: Failed to parse [...].cshtml, line 14, At-rule without name
##[error]ERROR: Failed to parse [...].cshtml, line 60, Unclosed bracket
ERROR: Failed to parse [...].cshtml, line 60, Unclosed bracket
##[error]ERROR: Failed to parse [...].cshtml, line 59, Unclosed bracket
ERROR: Failed to parse [...].cshtml, line 59, Unclosed bracket
##[error]ERROR: Failed to parse [...].cshtml, line 17, At-rule without name
ERROR: Failed to parse [...].cshtml, line 17, At-rule without name
##[error]ERROR: Failed to parse [...].cshtml, line 60, Unclosed bracket
ERROR: Failed to parse [...].cshtml, line 60, Unclosed bracket
##[error]ERROR: Failed to parse [...].cshtml, line 38, Unclosed bracket
ERROR: Failed to parse [...].cshtml, line 38, Unclosed bracket
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=6742ms