Underscores in numeric literals is not supported for Scala

  • versions used (SonarQube 9.2.3.50713, Scanner sonarsource/sonar-scanner-cli:4.7)
  • error observed
    Underscores in numeric literals is not supported. For example this file:
package com.zego.mapmatching

object test {
  val somevalue: Int = 10_000
}

line 4 is reported as a Code Smell (parsing error) because of the underscore although it is valid syntax

  • potential workaround
    Remove the underscore?

Hey there.

This was fixed in SonarQube v9.3 with an update to the underlying Scala parser (SONARSLANG-541). I just tested your reproducer locally and it scanned without any parsing errors!

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.