diff --git a/README.md b/README.md index 511b9e2..754e20f 100644 --- a/README.md +++ b/README.md @@ -52,18 +52,22 @@ sonarLint { exclude('java', 'kotlin') // Disable Java and Kotlin languages, all other languages remain enabled } - sonarProperty('sonar.nodejs.executable', '/usr/bin/node') // configure Node.js executable path via `sonar.nodejs.executable` Sonar property + sonarProperty('sonar.nodejs.executable', '/usr/bin/node') // Configure Node.js executable path via `sonar.nodejs.executable` Sonar property sonarProperties = ['sonar.nodejs.executable': '/usr/bin/node'] // `sonarProperties` - a mutable map of Sonar properties - ignoredPaths.add('**/dto/**') // ignore all files which relative path matches `**/dto/**` glob for all rules + ignoredPaths.add('**/dto/**') // Ignore all files which relative path matches `**/dto/**` glob for all rules rules { rule('java:S100') { - ignoredPaths.add('**/dto/**') // ignore all files which relative path matches `**/dto/**` glob for rule `java:S100` + ignoredPaths.add('**/dto/**') // Ignore all files which relative path matches `**/dto/**` glob for rule `java:S100` } } testSourceSets = sourceSets.matching { true } // Which source-sets contain test sources. Source-sets created by plugins like `name.remal.test-source-sets` are automatically integrated. Most probably, you don't have to configure anything yourself. + logging { + withDescription = false // Hide rule descriptions from console output + } + // `sonarLint` extension extends `CodeQualityExtension` (see https://docs.gradle.org/current/javadoc/org/gradle/api/plugins/quality/CodeQualityExtension.html). // You can use all fields of `CodeQualityExtension` the same way as for `checkstyle`, for example. } diff --git a/cross-compile--common/src/main/java/name/remal/gradle_plugins/sonarlint/internal/SonarLintExecutionParams.java b/cross-compile--common/src/main/java/name/remal/gradle_plugins/sonarlint/internal/SonarLintExecutionParams.java index d322598..ae69c11 100644 --- a/cross-compile--common/src/main/java/name/remal/gradle_plugins/sonarlint/internal/SonarLintExecutionParams.java +++ b/cross-compile--common/src/main/java/name/remal/gradle_plugins/sonarlint/internal/SonarLintExecutionParams.java @@ -51,4 +51,6 @@ public interface SonarLintExecutionParams extends WorkParameters { RegularFileProperty getHtmlReportLocation(); + Property getWithDescription(); + } diff --git a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintAction.java b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintAction.java index e653bf9..3c90393 100644 --- a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintAction.java +++ b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintAction.java @@ -59,7 +59,11 @@ public void execute() { } if (isNotEmpty(issues)) { - logger.error(new TextIssuesRenderer().renderIssues(issues)); + logger.error( + new TextIssuesRenderer() + .withDescription(params.getWithDescription().getOrElse(true)) + .renderIssues(issues) + ); if (!params.getIsIgnoreFailures().get()) { throw new AssertionError(format( @@ -75,7 +79,7 @@ public void execute() { params.getSonarLintVersion().get() ); val rulesDoc = rulesDocumentationCollector.collectRulesDocumentation(params); - logger.warn(rulesDoc.renderToText()); + logger.quiet(rulesDoc.renderToText()); } else if (command == HELP_PROPERTIES) { val propertiesDocumentationCollector = loadSonarLintService( @@ -98,7 +102,7 @@ public void execute() { propDef.setDefaultValue(defaultValue(params.getDefaultNodeJsVersion().getOrNull())); }); - logger.warn(propertiesDoc.renderToText()); + logger.quiet(propertiesDoc.renderToText()); } else { throw new AssertionError("Unsupported SonarLint runner command: " + command); diff --git a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintExtension.java b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintExtension.java index 7c0beed..489a0ea 100644 --- a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintExtension.java +++ b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintExtension.java @@ -51,6 +51,13 @@ public void sonarProperty(String key, Object value) { public abstract ListProperty getIgnoredPaths(); + private final SonarLintLoggingOptions logging = getObjectFactory().newInstance(SonarLintLoggingOptions.class); + + public void logging(Action action) { + action.execute(logging); + } + + private final SonarLintForkOptions fork = getObjectFactory().newInstance(SonarLintForkOptions.class); public void fork(Action action) { diff --git a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintForkOptions.java b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintForkOptions.java index 7e881ce..df066cd 100644 --- a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintForkOptions.java +++ b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintForkOptions.java @@ -2,9 +2,13 @@ import static name.remal.gradle_plugins.toolkit.internal.Flags.isInFunctionTest; +import lombok.Getter; +import lombok.Setter; import org.gradle.api.provider.Property; import org.gradle.api.tasks.Internal; +@Getter +@Setter public abstract class SonarLintForkOptions { static final boolean IS_FORK_ENABLED_DEFAULT = !isInFunctionTest(); diff --git a/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintLoggingOptions.java b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintLoggingOptions.java new file mode 100644 index 0000000..bc61585 --- /dev/null +++ b/src/main/java/name/remal/gradle_plugins/sonarlint/SonarLintLoggingOptions.java @@ -0,0 +1,19 @@ +package name.remal.gradle_plugins.sonarlint; + +import lombok.Getter; +import lombok.Setter; +import org.gradle.api.provider.Property; +import org.gradle.api.tasks.Internal; + +@Getter +@Setter +public abstract class SonarLintLoggingOptions { + + @Internal + public abstract Property getWithDescription(); + + { + getWithDescription().convention(true); + } + +}