sonar-scanner-npm
sonar-scanner-npm copied to clipboard
package.json name is being prioritiesed over sonar-project.properties file.
In our package.json we have all lower-case: my-project We use however the project key: My-Project
This has now lead to two projects being created in our server.
The sonar-project.properties file should override the package.json values.
I'm passing one param to sonar-scanner as follows:
sonar-scanner -Dsonar.projectBaseDir=./projects/PATH_TO_BASE_DIR
At my base dir (an subdirectory of my project) I have configured the sonar-project.properties file containing the sonar.projectKey property. Instead of reading this property the sonar-scanner keeps guessing the 'projectKey' reading the project.json file.
As a workaround I create a sonar-project.properties empty file at root directory of my project, so now the sonar-scanner is reading the right file because it skips the injection of 'package.json guessed properties'... it checks only at root directory for a sonar-project.properties if it can't find the file it reads the package.json to guess the sonar properties, but in case we have passed a Dsonar.projectBaseDir property it should check there for the file not at root.
I suggest to create at cli an argument that allows users to control the behavior of inject defaultOptions (based on project.json) or not, it he passes '--defaultOptions=false' the sonar-scanner skips the injection of guessed properties.
Hey folks, this looks like something worth doing. Do you want to try a PR?
Hello @basickarl, you brought up many good issues!
Hello also @rmlira, as mentioned in other issues, we are tracking potential improvements here:
- #165
I'll close this issue for now but feel free to reopen it if you have any feedback.