Collection converted to the type it already has

ID

scala.performance.redundant_collection_conversion

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Inefficient Api Usage

Language

Scala

Description

The receiver already has the requested type, so this conversion cannot change anything. Drop the call - on some collections it still copies every element.

Rationale

The receiver already has the requested type, so this conversion cannot change anything. Drop the call - on some collections it still copies every element.

The following code illustrates the pattern detected by this rule:

class RedundantCollectionConversion {
  def normalise(values: List[Int]): List[Int] = {
    // FLAGGED: Collection converted to the type it already has
    values.toList
  }
}

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved