Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ktlint to v0.47.1 #1506

Merged
merged 32 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e4026b5
Update Ktlint to v0.47.1
renovate[bot] Oct 22, 2022
5478c7f
Migrate to the new (ktlint 0.47+) Baseline API
0x6675636b796f75676974687562 Oct 25, 2022
fb9bd6b
Configure Surefire and Failsafe plugins for better reporting
0x6675636b796f75676974687562 Oct 25, 2022
c2b0008
Suppress deprecation warnings (`RuleSet` and `RuleSetProvider` are no…
0x6675636b796f75676974687562 Oct 25, 2022
8756724
Temporarily suppress the now deprecated `ASTNode.visit()` call to mak…
0x6675636b796f75676974687562 Oct 25, 2022
ea57ecc
Use the same "me.fabriciorby:maven-surefire-junit5-tree-reporter" ver…
0x6675636b796f75676974687562 Oct 25, 2022
768af6b
Make Diktat happy
0x6675636b796f75676974687562 Oct 25, 2022
f92561e
Suppress more deprecation warnings
0x6675636b796f75676974687562 Oct 25, 2022
311c34e
Suppress more deprecation warnings
0x6675636b796f75676974687562 Oct 25, 2022
5a8a39d
Remove `DIKTAT_RULE_SET_ID` from expected lint errors (ignored in the…
0x6675636b796f75676974687562 Oct 25, 2022
05c543f
Suppress more deprecation warnings
0x6675636b796f75676974687562 Oct 25, 2022
3c73182
Bump versions in documentation and string literals
0x6675636b796f75676974687562 Oct 26, 2022
01ed8c9
Hide the stderr of Maven, if _JAVA_OPTIONS is set
0x6675636b796f75676974687562 Oct 26, 2022
f3a70b7
Correct the KDoc reference
0x6675636b796f75676974687562 Oct 26, 2022
069c1af
Drop `FeatureInAlphaState` annotations (no longer necessary)
0x6675636b796f75676974687562 Oct 26, 2022
7d4db80
Make sure rule ids are always fully-qualified (previous behaviour bro…
0x6675636b796f75676974687562 Oct 26, 2022
3efb83c
Revert "Remove `DIKTAT_RULE_SET_ID` from expected lint errors (ignore…
0x6675636b796f75676974687562 Oct 26, 2022
1135a4b
Print out stack traces when running the snapshot version of the Maven…
0x6675636b796f75676974687562 Oct 26, 2022
f5ca590
Ignore SARIF reports
0x6675636b796f75676974687562 Oct 27, 2022
a8ce2d3
Clean up and fix `OrderedRuleSet`
0x6675636b796f75676974687562 Oct 27, 2022
1598cb9
Merge branch 'master' into renovate/ktlint
0x6675636b796f75676974687562 Oct 27, 2022
f7e3e3b
Test file management
0x6675636b796f75676974687562 Oct 27, 2022
8a952b7
Fix the assertion
0x6675636b796f75676974687562 Oct 27, 2022
cfad5cb
Ignore the corrected errors when in "fix" mode
0x6675636b796f75676974687562 Oct 27, 2022
ad2a991
Allow lint errors to appear in any order
0x6675636b796f75676974687562 Oct 27, 2022
d3c05ed
Fix a smoke test
0x6675636b796f75676974687562 Oct 28, 2022
41a456d
Fix `OrderedRuleSetTest`
0x6675636b796f75676974687562 Oct 28, 2022
b6ed77e
Ignore temporary files produced by smoke tests
0x6675636b796f75676974687562 Oct 28, 2022
e03767a
Merge branch 'master' into renovate/ktlint
0x6675636b796f75676974687562 Oct 28, 2022
3838e02
Enable extra diagnostics when running diktat from save-cli
0x6675636b796f75676974687562 Oct 28, 2022
62825ef
Enable extra save-cli verbosity when running it on Windows, too
0x6675636b796f75676974687562 Oct 28, 2022
a5db5d6
When running save-cli, override the temporary directory on Windows
0x6675636b796f75676974687562 Oct 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions diktat-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,37 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
<configuration>
<excludes>
<exclude>*IntegrationTest*</exclude>
</excludes>
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<!-- Prefer @DisplayName & friends, if any. -->
<usePhrasedFileName>true</usePhrasedFileName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
</statelessTestsetReporter>
<!-- For the console output, use the tree reporter from
https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter. -->
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
<!-- Prefer @DisplayName & friends, if any. -->
<usePhrasedFileName>true</usePhrasedFileName>
<usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
<!-- Avoid null's in *.txt summary -->
<usePhrasedClassNameInTestCaseSummary>false</usePhrasedClassNameInTestCaseSummary>
</statelessTestsetInfoReporter>
</configuration>
</plugin>
<plugin>
Expand All @@ -165,6 +192,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<dependencies>
<dependency>
<groupId>me.fabriciorby</groupId>
<artifactId>maven-surefire-junit5-tree-reporter</artifactId>
<version>1.1.0</version>
0x6675636b796f75676974687562 marked this conversation as resolved.
Show resolved Hide resolved
</dependency>
</dependencies>
<configuration>
<systemProperties>
<maven.version>${maven.version}</maven.version>
Expand All @@ -175,6 +209,26 @@
</includes>
<testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
<testClassesDirectory>${project.build.testOutputDirectory}</testClassesDirectory>
<statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<!-- Prefer @DisplayName & friends, if any. -->
<usePhrasedFileName>true</usePhrasedFileName>
<usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
<usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
</statelessTestsetReporter>
<!-- For the console output, use the tree reporter from
https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter. -->
<reportFormat>plain</reportFormat>
<consoleOutputReporter>
<disable>true</disable>
</consoleOutputReporter>
<statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
<!-- Prefer @DisplayName & friends, if any. -->
<usePhrasedFileName>true</usePhrasedFileName>
<usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
<!-- Avoid null's in *.txt summary -->
<usePhrasedClassNameInTestCaseSummary>false</usePhrasedClassNameInTestCaseSummary>
</statelessTestsetInfoReporter>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import com.pinterest.ktlint.core.LintError
import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.core.RuleExecutionException
import com.pinterest.ktlint.core.RuleSet
import com.pinterest.ktlint.core.internal.CurrentBaseline
import com.pinterest.ktlint.core.internal.containsLintError
import com.pinterest.ktlint.core.internal.loadBaseline
import com.pinterest.ktlint.core.api.Baseline
import com.pinterest.ktlint.core.api.Baseline.Status.VALID
import com.pinterest.ktlint.core.api.containsLintError
import com.pinterest.ktlint.core.api.loadBaseline
import com.pinterest.ktlint.reporter.baseline.BaselineReporter
import com.pinterest.ktlint.reporter.html.HtmlReporter
import com.pinterest.ktlint.reporter.json.JsonReporter
import com.pinterest.ktlint.reporter.plain.PlainReporter
import com.pinterest.ktlint.reporter.sarif.SarifReporter
import org.apache.maven.execution.MavenSession
import org.apache.maven.plugin.AbstractMojo
import org.apache.maven.plugin.Mojo
import org.apache.maven.plugin.MojoExecutionException
import org.apache.maven.plugin.MojoFailureException
import org.apache.maven.plugins.annotations.Parameter
Expand Down Expand Up @@ -119,15 +121,15 @@ abstract class DiktatBaseMojo : AbstractMojo() {
listOf(DiktatRuleSetProvider(configFile).get())
}
val baselineResults = baseline?.let { loadBaseline(it.absolutePath) }
?: CurrentBaseline(emptyMap(), false)
?: Baseline(status = VALID)
reporterImpl = resolveReporter(baselineResults)
reporterImpl.beforeAll()
val lintErrors: MutableList<LintError> = mutableListOf()

inputs
.map(::File)
.forEach {
checkDirectory(it, lintErrors, baselineResults.baselineRules ?: emptyMap(), ruleSets)
checkDirectory(it, lintErrors, baselineResults.lintErrorsPerFile, ruleSets)
}

reporterImpl.afterAll()
Expand All @@ -136,7 +138,7 @@ abstract class DiktatBaseMojo : AbstractMojo() {
}
}

private fun resolveReporter(baselineResults: CurrentBaseline): Reporter {
private fun resolveReporter(baselineResults: Baseline): Reporter {
val output = if (this.output.isBlank()) {
if (this.githubActions) {
// need to set user.home specially for ktlint, so it will be able to put a relative path URI in SARIF
Expand Down Expand Up @@ -164,7 +166,7 @@ abstract class DiktatBaseMojo : AbstractMojo() {
}
}

return if (baselineResults.baselineGenerationNeeded) {
return if (baselineResults.status != VALID) {
val baselineReporter = BaselineReporter(PrintStream(FileOutputStream(baseline, true)))
return Reporter.from(actualReporter, baselineReporter)
} else {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<kotlin.code.style>official</kotlin.code.style>
<kotlinx.serialization.version>1.4.0</kotlinx.serialization.version>
<ktlint.version>0.46.1</ktlint.version>
<ktlint.version>0.47.1</ktlint.version>
<junit.version>5.9.0</junit.version>
<junit.platform.version>1.9.0</junit.platform.version>
<guava.version>31.1-jre</guava.version>
Expand Down