name.remal.sonarlint

Plugin class: name.remal.gradle_plugins.plugins.code_quality.sonar.SonarLintPlugin

plugins {
    id 'name.remal.sonarlint' version '1.1.6'
}
plugins {
    id("name.remal.sonarlint") version "1.1.6"
}

 

This plugin executes SonarLint inspections without connecting to a SonarQube server. SonarLint's core JARs and plugins' JARs are downloaded via sonarlintCore and sonarlintPlugins configurations accordingly.

To resolve dependencies, the plugin adds SonarSource Maven repository to the project's repositories.

By default, the plugin uses these Sonar plugins:

 

If java Gradle plugin is applied, sonarlint* task is created for each SourceSet.

The plugin creates sonarlint extension of type SonarLintExtension (it extends CodeQualityExtension) that allows to configure sonarlint* tasks globally.

 

Usage:

sonarlint {
    ignoreFailures = false
    excludes {
        message 'java:S1214'
        message 'kotlin:S100'
        message 'xml:S125'
    }
    includes {
        message 'java:S4266' // Enable java:S4266 which is disabled by default
    }
    ruleParameter('java:S119', 'format', '^[A-Z][a-zA-Z0-9]*$') // Allow upper camel-case for type parameter names
}
import name.remal.gradle_plugins.plugins.code_quality.sonar.SonarLintExtension

configure<SonarLintExtension> {
    isIgnoreFailures = false
    excludes {
        message("java:S1214")
        message("kotlin:S100")
        message("xml:S125")
    }
    includes {
        message("java:S4266") // Enable java:S4266 which is disabled by default
    }
    ruleParameter("java:S119", "format", "^[A-Z][a-zA-Z0-9]*\$") // Allow upper camel-case for type parameter names
}

 

name.remal.gradle_plugins.plugins.code_quality.sonar.SonarLintExtension

Property Type Description
excludes ExcludesExtension Global excludes.
includes ExcludesExtension Global includes.
sonarProperties MutableMap<String, String?> Extra Sonar properties.
ruleParameters MutableMap<String, MutableMap<String, String?>> Sonar rule properties.
Method Description
void sonarProperty(Object? name, Object? value) Adds new Sonar property.
void sonarProperties(Map<Object?, Object?> map) Copy Sonar properties from the map.
void ruleParameter(Object ruleId, Object? name, Object? value) Adds new Sonar rule property.
void ruleParameters(Object ruleId, Map<Object?, Object?> map) Copy Sonar rule properties from the map.

name.remal.gradle_plugins.plugins.code_quality.ExcludesExtension

Property Type Description
sources MutableSet<String> ANT like exclude/include patterns of source files.
messages MutableSet<String> Excluded/included violation messages.
Method Description
void source(String value) Add ANT like exclude/include pattern of source files.
void sources(String... values) Add ANT like exclude/include patterns of source files.
void sources(Iterable<String> values) Add ANT like exclude/include patterns of source files.
void message(String value) Add violation message to excludes/includes.
void messages(String... values) Add violation messages to excludes/includes.
void messages(Iterable<String> values) Add violation messages to excludes/includes.