Search code examples
grailsintellij-ideagroovysonarlintsonarlint-intellij

How do I analyze Groovy code with Sonarlint for IntelliJ?


The Sonarlint plugin for IntelliJ does analysis on our Java code, but it won't analyze Groovy code in the same project.

We have a Grails project which works with sonar-runner on the command line. When I install the IntelliJ IDEA Sonarlint plugin, the plugin doesn't seem to pick up the settings from our command line config, and it doesn't show the warning highlights for issues like it does for the Java files in the editor.

Our project uses the "code-coverage" Grails plugin to generate an XML coverage report, then the sonar runner (command line tool) pulls in the metrics. In sonar-project.properties, we set:

# Project key within sonar
sonar.projectKey=com.mycompany:myapp
sonar.projectName=My Grails Project
sonar.projectVersion=1.0

# Source directories to analyze
sonar.sources=src/groovy, grails-app/domain, grails-app/services, grails-app/controllers, grails-app/utils, grails-app/taglib, grails-app/views

# Set language for the project to be Groovy
sonar.language=grvy

# Path to the Cobertura XML report
sonar.grvy.coveragePlugin=cobertura
sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml

sonar.jdbc.username=...
sonar.jdbc.password=...

sonar.host.url=http://sonar.mycompany.com

sonar.jdbc.url=...
sonar.jdbc.driverClassName=...

The properties file has JDBC settings, the coverage report path, etc.


Solution

  • SonarLint is a different product than SonarQube (even if there are some links). For example SonarLint doesn't know what is sonar-project.properties. The purpose is to integrate with IntelliJ, not with some external configuration.

    Regarding Groovy support, this is not planned since we don't have any Groovy analyzer (the SonarQube plugin for Groovy is simply reusing codenarc reports AFAIK). If you want to run Codenarc in IntelliJ, there is already a dedicated plugin for that.