sonar-scanner-npm icon indicating copy to clipboard operation
sonar-scanner-npm copied to clipboard

package.json name is being prioritiesed over sonar-project.properties file.

Open basickarl opened this issue 5 years ago • 1 comments

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.

basickarl avatar Apr 17 '20 13:04 basickarl

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.

rmlira avatar Jul 07 '20 20:07 rmlira

Hey folks, this looks like something worth doing. Do you want to try a PR?

gabssnake avatar Sep 26 '22 19:09 gabssnake

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.

gabssnake avatar Dec 04 '22 16:12 gabssnake