This is on SonarQube 7.4 Developer Edition
Create a new job by doing an initial analysis
Here is my sonar-project.properties
Run sbt clean compile coverage test coverageReport
Run sonar-scanner -X -Dsonar.projectVersion=BASELINE -Dsonar.host.url=xxx -Dsonar.login=xxx
Go to the newly created project and set the New Code period to BASELINE.
Make some change in your code to cause a code smell. Run the exact same build and sonar-scanner commands. View the project in SonarQube. Go to Overview and it will show the New Code period as previous_version instead of BASELINE.
Run the sonar scanner command again. Go back to the UI and you will see that the New Code period is still previous_version. The problem is that the New Code analysis shows 1 code smell even though no changes have been made since the previous BASELINE.
Go to the Activity tab and mark the first analysis as version “1”.
Run sonar scanner again. Go back to the UI and now it shows the New Code period as BASELINE with 0 code smell.
This is definitely causing a lot of problems for us because we do our quality gates on the pull request branches. So, if pull request 1 has 85% code coverage, pull request 2 has 85% code coverage, etc., eventually all that “new code” dips below 80% and then our quality gate fails since SonarQube is ignoring the New Code period setting. And so “new code” means our first analysis with SonarQube.
I have seen this on both Scala and Java projects. It also seems to be new since we upgraded to SonarQube 7.4.