Cannot compute 'New Code' for SVN branches (Failed to detect fork date)

Using SonarQube Enterprise Edition Version 8.9.6 (build 50800), and scans are done using SonarScanner for .NET v5.4.1 (.NET Framework 4.6+ version)

We are configuring our build process to allow running code analysis on our SVN feature branches, however I cannot get the ‘New Code’ to be recognized.

When running the SonarScanner for .NET, the analysis is successful but it is unable to compute new code: “WARN: Failed to detect fork date. No New Code will be computed.”

We are using the in-built Subversion integration and the blame information is visible within the SonarQube code viewer, so authentication etc. does not seem to be at issue here

New Code settings:

  • trunk branch (the main branch) - set to use a specific analysis date

  • Project level setting - Reference branch set to trunk

So the desired functionality is that any differences between the branch and the reference branch be considered New Code, which I believe is what these settings should achieve

Here is the most relevant section of the scanner log (with sonar.verbose param set to true)


  15:56:57.690 INFO: CPD Executor CPD calculation finished (done) | time=1389ms

  15:56:57.697 DEBUG: Getting revision id is not supported by svn provider

  15:56:57.698 INFO: Load New Code definition

  15:56:58.012 DEBUG: GET 200 <url_omitted> | time=314ms

  15:56:58.012 INFO: Load New Code definition (done) | time=314ms

  15:56:58.013 INFO: Computing New Code since fork with 'trunk'

  15:56:58.312 DEBUG: latest revision is 77817

WARNING : warning : An illegal reflective access operation has occurred [C:\workdir\Desktop\Branch_Alpha\build.proj]

WARNING : warning : Illegal reflective access by org.tmatesoft.svn.core.internal.util.SVNSocketFactory (file:/C:/Users/awxs7h/.sonar/cache/9b4903ef5ecd0c34a6fe4b62db0b7bfe/scanner-enterprise-8.9.6.50800-all.jar) to method sun.security.ssl.SSLSocketImpl.setHost(java.lang.String) [C:\wo

rkdir\Desktop\Branch_Alpha\build.proj]

WARNING : warning : Please consider reporting this to the maintainers of org.tmatesoft.svn.core.internal.util.SVNSocketFactory [C:\workdir\Desktop\Branch_Alpha\build.proj]

WARNING : warning : Use --illegal-access=warn to enable warnings of further illegal reflective access operations [C:\workdir\Desktop\Branch_Alpha\build.proj]

WARNING : warning : All illegal access operations will be denied in a future release [C:\workdir\Desktop\Branch_Alpha\build.proj]

  15:57:08.235 WARN: Failed to detect fork date. No New Code will be computed.

  15:57:08.244 DEBUG: Getting relative path from SCM root is not supported by svn provider

  15:57:12.237 INFO: Analysis report generated in 13574ms, dir size=20 MB

  15:57:19.118 INFO: Analysis report compressed in 6881ms, zip size=7 MB

  15:57:19.118 INFO: Analysis report generated in C:\workdir\Desktop\Branch_Alpha\.sonarqube\out\.sonar\scanner-report

  15:57:19.118 DEBUG: Upload report

Other things to note:

  • We have run an analysis against our trunk branch with the SVN integration enabled - blame info etc is there so this seems to be working.

    • (We do get a ‘Missing blame information for 3 files’ message too, but this seems unlikely to be related and has not yet been investigated - all other files do have blame info.)
  • The feature branch was created after the trunk had alrady been analyzed with SVN integration

  • In case it is somehow relevant to how the fork point is calculated, our Subversion is organized in this hierarchy:

    • trunk
      • Tools
      • Source
    • branches
      • stories
        • ExampleStory
      • defects
  • And the feature branches such as ‘ExampleStory’ are copies of only the ‘trunk/Source’ folder. So the first log entry when each feature branch is created is always one showing the contents being copied from ‘trunk/Source’ for example

Currently at a bit of a loss as to the problem - does anyone have any idea what may be the issue?

I’ve managed to track down the cause and have solved the problem - leaving the solution here in case anyone else has a similar problem in future,

The problem ultimately is due to the fact that when we create a branch we copy ‘/trunk/Source’ and create a feature branch at URL ‘/branches/stories/ExampleStory’ for example, however our main branch in SonarQube was called ‘trunk’ and not ‘trunk/Source’.

Renaming our main branch to be ‘trunk/Source’ fixes the problem, you can see why if you look at the source code here, as SonarQube is expecting e.getCopyPath() to exactly equal the reference branch name - but in our case e.getCopyPath() presumably was trunk/Source while our reference branch name in SonarQube was just trunk, and therefore the fork point was not found.

Summary: ensure that the path you copy from in Subversion to create a branch exactly matches the reference branch name in SonarQube