SonarLint plugin for IntelliJ IDEA doesn't detect issues

  • Operating system: macOS Ventura 13.2.1 (22D68)
  • Chip: Apple M1
  • IntelliJ IDEA version: 2023.1 (Ultimate Edition), Build #IU-231.8109.175, built on March 28, 2023
  • SonarLint plugin version: 8.1.0.65508
  • Programming language you’re coding in: Scala
  • Is connected mode used: No

Hello,

It seems like plugin doesn’t work as expected for the Scala code. I expect it to detect issues in the following example (there are some basic issues like unused variable that should be detected):

class Main extends App {

  val unusedVariable = true

  private def unusedMethod() = 1 + 1
  private def unusedMethod() = 1 + 1

  val duplicatedValue1 = "some_literal"
  val duplicatedValue2 = "some_literal"
  val duplicatedValue3 = "some_literal"
  val duplicatedValue4 = "some_literal"
  val duplicatedValue5 = "some_literal"

  // Statements should be on separate lines
  println("Hello"); println("world!")
  
}

But none has been detected.

Here are the plugin logs from the IDE SonarLint plugin log tab:

Trigger: ACTION
[ACTION] 1 file(s) submitted
Configuring analysis with org.sonarlint.intellij.java.JavaAnalysisConfigurator
Analysing 'Main.scala'...
Starting analysis with configuration:
[
  baseDir: /Users/hoffman/Projects/test-sonar-lint-plugin/untitled
  extraProperties: {sonar.java.target=11, sonar.java.source=11, sonar.java.libraries=/Users/hoffman/Library/Java/JavaVirtualMachines/openjdk-20/Contents/Home/lib/jrt-fs.jar,/Users/hoffman/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar, sonar.java.jdkHome=/Users/hoffman/Library/Java/JavaVirtualMachines/openjdk-20/Contents/Home, sonar.java.test.libraries=/Users/hoffman/Library/Java/JavaVirtualMachines/openjdk-20/Contents/Home/lib/jrt-fs.jar,/Users/hoffman/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.10/scala-library-2.13.10.jar}
  moduleKey: Module: 'untitled'
  excludedRules: []
  includedRules: []
  ruleParameters: {}
  inputFiles: [
    file:///Users/hoffman/Projects/test-sonar-lint-plugin/untitled/src/main/scala/Main.scala (UTF-8)
  ]
]

Start analysis
Index files
Language of file 'file:///Users/hoffman/Projects/test-sonar-lint-plugin/untitled/src/main/scala/Main.scala' is detected to be 'Scala'
1 file indexed
'JavaSensor' skipped because there is no related files in the current project
'Python Sensor' skipped because there is no related files in the current project
'IPython Notebooks Sensor' skipped because there is no related files in the current project
Execute Sensor: HTML
'XML Sensor' skipped because there is no related files in the current project
'Kotlin Sensor' skipped because there is no related files in the current project
'PHP sensor' skipped because there is no related files in the current project
'Analyzer for "php.ini" files' skipped because there is no related files in the current project
Execute Sensor: TextAndSecretsSensor
1 source file to be analyzed
1/1 source file has been analyzed
'JavaScript analysis' skipped because there is no related files in the current project
'TypeScript analysis' skipped because there is no related files in the current project
'JavaScript inside YAML analysis' skipped because there is no related files in the current project
'JavaScript inside HTML analysis' skipped because there is no related files in the current project
Execute Sensor: CSS Rules
No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
'Ruby Sensor' skipped because there is no related files in the current project
Done in 47ms

Processed 0 issues
Found 0 issues and 0 hotspots

Could you please help me to figure out what is the issue?
Thank you for advance.

Hi @komendant,

Scala analysis in SonarLint is only enabled when used in connected mode, which is why your file is not currently analyzed with our Scala sensor.

Thank you for using SonarLint!

Hi Nicolas,

Thank you for a quick response!

It helped. After binding the project to SonarCloud, Scala code has been analysed properly.

Thank you for help!

1 Like

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