Scala - False positive scala:S1764 Identical expressions should not be used on both sides of a binary operator

Hello guys,

  • Versions used SonarQube: 7.5, Scanner: sonar-scanner-, language analyzer: Scala
  • Issue: In Scala the sortWithfunction it is valid to use identical expressions on both sides of a binary operator, however, the bug scala:S1764 is shown.

Minimal code sample to reproduce:

object SonarTest extends App {
  val personList =
    List(Person("Santi", 23), Person("Robert", 25), Person("Oscar", 26), Person("Nat", 19), Person("Seba", 15))

  val sortedPersonList = personList.sortWith(_.age < _.age)

case class Person(name: String, age: Int)


1 Like

Hello Robert,

Thank you for feedback.

Indeed, this is a wrong behavior of the rule.

We are already aware of this problem and SONARSLANG-350 is here to keep track of it!