Fix isChild check in CoberturaMultiSourceReader #266
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
591ff35 changed
isChild
to compare absolute paths rather than relative ones. However, it did something else - changed the variables being compared from instances ofPath
toString
s. WhilestartsWith
is defined in both types, their behavior is not the same.Path#startsWith
correctly determines if a path is a parent of another because it takes file path elements in consideration, whileString#startsWith
does prefix checks at a character level.In real scenarios, this fails when using Scala version specific source folders like
src/main/scala
andsrc/main/scala-2.12
, natively supported by SBT. They are sibling directories, but the current implementation incorrectly assumes them to be parent and children, respectively. On this PR we're fixing it by keeping usage of absolute paths while still usingPath
.Added a unit test that correctly catches this error so that hopefully we don't get any regressions.