Skip to content

Commit

Permalink
[release-later] Logging setting: rule description display flag (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
remal committed Dec 1, 2023
1 parent 49a8076 commit 161a9ae
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ public interface SonarLintExecutionParams extends WorkParameters {

RegularFileProperty getHtmlReportLocation();

Property<Boolean> getWithDescription();

}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public void sonarProperty(String key, Object value) {
public abstract ListProperty<String> getIgnoredPaths();


private final SonarLintLoggingOptions logging = getObjectFactory().newInstance(SonarLintLoggingOptions.class);

public void logging(Action<SonarLintLoggingOptions> action) {
action.execute(logging);
}


private final SonarLintForkOptions fork = getObjectFactory().newInstance(SonarLintForkOptions.class);

public void fork(Action<SonarLintForkOptions> action) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> getWithDescription();

{
getWithDescription().convention(true);
}

}

0 comments on commit 161a9ae

Please sign in to comment.