scoverage / scalac-scoverage-plugin

Scoverage Scala Code Coverage Core Libs
https://github.com/scoverage
Apache License 2.0
423 stars 126 forks source link

Allow to handle "no source root found" in a custom way #525

Open TheElectronWill opened 1 year ago

TheElectronWill commented 1 year ago

This introduce a "PathRecoverer" that can take action when a path is not in any source root. In particular, it can replace the path and allow to continue, or skip the element, or fail (and of course emit a warning, or whatever - but I didn't want to make the reporter itself handle logging, they will look better if handled from sbt, mill, etc.)

The next step is to use this in the sbt plugin, and then we can say goodbye to the "no source root found for $x" error!

TheElectronWill commented 1 year ago

Secondly, on the reporting side, we really need to make sure that we complain loudly when we do come across this

How can the reporter emit a proper warning without having access to a logger? :c (or maybe it has access to something I've missed). I would like to avoid a basic println (which wouldn't be colored not formatted properly, and thus would be less likely to be seen IMO).

edit: wait, you mean the "reporting side" is actually "the sbt scoverage plugin" (and mill, gradle, etc.)? I planned to open a PR in it once this one is merged. By making the default throw an exception, and the plugins warn appropriately, it should be ok.