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

scala

(Robert Martinez) #1

Hello guys,

  • Versions used SonarQube: 7.5, Scanner: sonar-scanner-3.2.0.1227-linux, 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)

Thanks!


(Quentin Jaquier) #2

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!

Best,
Quentin