Scala coverage report incomplete

From one day to another our code coverage drops from about 78% to 10% because most files were not longer analyzed.

Some more details:

  • Scala version is 2.13
  • Used sbt plugins for sonar coverage
    • addSbtPlugin(“org.scoverage” % “sbt-scoverage” % “1.9.2”)
    • addSbtPlugin(“com.sonar-scala” % “sbt-sonar” % “2.3.0”)
  • Our gitlab pipeline has five stages
    • build (compile)
    • test 1/3
    • test 2/3
    • test 3/3
    • analyze coverage
  • We have to split the pipeline into 3 test stages because each must be ready within 60 minutes.
  • Altogether the pipeline takes between 2 and 2,5 hours
  • The project is 98% scala language code.
  • The project has 15 sub projects. (see “Files” below )
    • 14 are ok (the smaller sub projects, about 10% of overall code (lines and files))
    • 1 is not ok (about 90% code)
  • The one (model/src) is very special. Only one (IndividualContactImplementation.scala of 1732 files has coverage. see coverage report
  • No errors in the log but one major difference

Sensors Log File

The good one

------------- Run sensors on module model
Sensor Scala Sensor [sonarscala]
1729 source files to be analyzed
382/1729 files analyzed, current file: model/src/main/scala/metacompany/resources/inventory/stocktaking/entries/helper/StockTakingResourceEntryHelper.scala
926/1729 files analyzed, current file: model/src/main/scala/metacompany/pricerules/engine/steps2/order/pipeline/FilterContext.scala
1488/1729 files analyzed, current file: model/src/main/scala/eu/numberfour/sites/online_presences/VerifyTokenResponse.scala
1729/1729 source files have been analyzed
Sensor Scala Sensor [sonarscala] (done) | time=34505ms
Sensor Scoverage sensor for Scala coverage [sonarscala]
Importing /builds/jB6LN3n7/0/numberfour/server/infra/build/infra/model/target/scala-2.13/scoverage-report/scoverage.xml
[warn] Fail to resolve 279 file(s). No coverage data will be imported on the following file(s): /builds/jB6LN3n7/0/numberfour/server/infra/build/infra/model/target/scala-2.13/src_managed/main/scala/eu/numberfour/DebugApiDispatcher.scala;...
Sensor Scoverage sensor for Scala coverage [sonarscala] (done) | time=2465ms
------------- Run sensors on module infraconfig

The bad one

------------- Run sensors on module model
Sensor Scala Sensor [sonarscala]
1730 source files to be analyzed
464/1730 files analyzed, current file: model/src/main/scala/metacompany/common/services/ParticipantMailHelper.scala
1070/1730 files analyzed, current file: model/src/main/scala/metacompany/resources/inventory/query/ResourceStockCountCompanionQueries.scala
1724/1730 files analyzed, current file: model/src/main/scala/n4/metacompany/saleschannel/SalesChannelImplementation.scala
1730/1730 source files have been analyzed
Sensor Scala Sensor [sonarscala] (done) | time=30082ms
Sensor Scoverage sensor for Scala coverage [sonarscala]
Importing /builds/jB6LN3n7/0/numberfour/server/infra/build/infra/model/target/scala-2.13/scoverage-report/scoverage.xml
Sensor Scoverage sensor for Scala coverage [sonarscala] (done) | time=33ms
------------- Run sensors on module infraconfig

files 1,962 New Code: Since code_analysis-SNAPSHOT

* coreservice_ws/src 36
* device_management_service_client/src 6
* devicemanagement/src 10
* externals/src 21
* handlebars/src 8
* infraconfig/src 10
* infracontext/src 8
* keyvalue/src 5
* model/src 1,732
* notification/src 4
* payment_gateway_client/src 6
* search/src 84
* thrift/src 5
* tools/src 8
* user/src/main/scala 19

coverage report

infra model/src main/scala metacompany contacts
Coverage 28.9%
                                            Coverage    Uncovered
ContactBaseImplementation.scala              0.0%	    663
ContactDocumentHandlerImplementation.scala   0.0%	      2
ContactEDIHelper.scala                       0.0%	     88
ContactHelper.scala                          0.0%	    184
ContactRewardHelper.scala                    0.0%	     90
ContactSingletonImplementation.scala         0.0%	      6
ContactSingletonInternalAPI.scala            0.0%	      7
CustomerPriceListImplementation.scala        0.0%	      6
IndividualContactImplementation.scala       73.9%	    421
LoyaltyProgramSubscriptionHelper.scala       0.0%	     33
LoyaltyRewardOps.scala                       0.0%	      9
MountpointSubtypeImplementation.scala        0.0%	     68

Thx you for your help.


Welcome to the community!

I’m rather confused by your situation. Are you sure you’ve correctly labeled the two log snippets? Because the one you call “good” looks bad to me & vice versa.

And I find your initial problem statement confusing too:

Are they no longer analyzed (included in the analysis at all) or no longer reported as covered by the coverage reports you feed into analysis?


Thx Ann for your reply.

yes that is curious that log with the warning inside is the good one. It take 4 seconds longer and is successful at the end.

I’m not sure if it not analysed or not reported (but probably it is not reported), because the log says “1730 source files have been analyzed” but the report lists only one file.


Could you set add -Dsonar.log.level=DEBUG to your analysis command? I think that will give us a better idea of what’s going on during the import of your coverage report.