Language of file 'filename.dev.js' can not be decided as the file matches patterns of both sonar.lang.patterns.cs : **/*.cs,**/*.js and sonar.lang.patterns.js : **/*.js,**/*.jsx,**/*.mjs,**/*.vue
When I inspect the Languages in the project settings (screenshot below), I can see that in the C# patterns there is only .cs files. But I do see as well that the keys don’t match : the key in the project settings is sonar.cs.file.suffixes and the key in the error is sonar.lang.patterns.cs. Any idea what might be the issue?
If I explicitly set the key identified in the error to use only .cs files, with the below property, it works. But I would like to avoid this
We don’t set
.js as a C# pattern, so this is probably coming from analysis parameters. The first thing I’d do is:
- remove your
sonar.scanner.dumpToFile=[path to file]
To see exactly what analysis is getting. You’ll see in here a conflation of things explicitly set at the four levels described at the top of this page. (Yes, those are the SonarQube docs, and you’ve tagged this SonarCloud. It should be the same for both, but I’m not sure where that hierarchy ended up in the reorganized SC docs.) That will accomplish confirming (or not!) that somewhere else that file suffix is being set.
And then the question becomes tracking down where.
Hi and thank you for your reply!
I tried to add the below property in the sonar cloud scanner analysis parameters, but the file is not being created. The path in the property is the exact path in the Azure DevOps agent, but the file is not being created there. Is there an example on how to properly use this property in Azure DevOps?
I don’t think there is.
I guess you’ll need to just manually check the places that property could be being set:
- analysis command line (or some sort of ‘extra properties’ input)
- project configuration files (e.g. your
- in the scanner installation (see the part about
- in the project file
- in the UI at the project level
- in the UI at the Org level
There was indeed a C# misconfigured rule in the UI at the project level, matching .js files. But in another project! I couldn’t find it at first, because I was using the same key for the two projects. It is fixed now
Thanks for your help!