Scanner ignores Javascript files in C# project

Hi @Vincent-FundApps. We’ve had a discussion internally about the expected behaviour and we’d like to revise our previous answer.

The SonarScanner for MSBuild can analyse non-C#/VB files if those files are referenced in the MSBuild project. More specifically, any files using one of the ItemTypes in this list should be analysed automatically. If the ItemType you are using isn’t in the list, you can add it as described here.

Now, as to why your .js files are not being analysed:

Content is included in the list of ItemTypes that should be analysed. However, Scripts\dist\app.all.js doesn’t include any of the wildcards that are used by MSBuild, so it refers to a single file.
As an example, an expression like Scripts\dist\*.js would include all .js files in the dist folder.
An expression like Scripts\**\*.js would include all .js files in all folders under Scripts.

You can check which files the scanner thinks should be analysed by looking in the file .sonarqube\out\sonar-project.properties after MSBuild has finished.

FYI we’ve created a ticket to update the scanner documentation: Log in with Atlassian account.

Apologies for any inconvenience caused.

1 Like