Reports calls that add or remove a java.nio.file.Path to/from a Kotlin collection or sequence using
plus/minus, either in operator form (a + b, a - b) or regular call form
(a.plus(b), a.minus(b)).
Since java.nio.file.Path implements Iterable<Path>, such calls resolve to the unexpected overload of
the plus or minus function that takes a collection of elements (in this case, the individual elements
of the Path). But the intent of the code is probably to add or remove the Path itself, not the
individual elements.
Examples:
// Operator form
val paths = listOf(path) + somePath
val paths2 = setOf(path) - somePath
// Regular call form
val paths = listOf(path).plus(somePath)
val paths2 = setOf(path).minus(somePath)
Quick-fixes:
plusElement/minusElement (changes the semantics to what was originally intended):
val paths = listOf(path).plusElement(somePath)
val paths2 = setOf(path).minusElement(somePath)
Path argument to a collection to clarify intent without changing semantics:
plus: wrap the argument with toList() to preserve order.minus: wrap the argument with toSet() for efficient removal.
val paths = listOf(path).plus(somePath.toList())
val paths2 = setOf(path).minus(somePath.toSet())