Skip to content

Commit

Permalink
Upgraded ktlint.version from 0.48.2 to 0.50.0 (#564)
Browse files Browse the repository at this point in the history
Bumps `ktlint.version` from 0.48.2 to 0.50.0.
  • Loading branch information
freemanjp committed Aug 20, 2023
1 parent 304000f commit ab041ec
Show file tree
Hide file tree
Showing 22 changed files with 428 additions and 206 deletions.
52 changes: 43 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
<java.require.version>11</java.require.version>
<jdeps.multiRelease>11</jdeps.multiRelease>
<kotlin.version>1.8.0</kotlin.version>
<ktlint.version>0.48.2</ktlint.version>
<kotlin.version>1.8.22</kotlin.version>
<ktlint.version>0.50.0</ktlint.version>
<license-maven-plugin.version>1.20</license-maven-plugin.version>
<maven-plugin-plugin.version>3.6.4</maven-plugin-plugin.version>
<maven.compiler.release>8</maven.compiler.release>
Expand Down Expand Up @@ -82,7 +82,17 @@
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-core</artifactId>
<artifactId>ktlint-cli-reporter</artifactId>
<version>${ktlint.version}</version>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-cli-ruleset-core</artifactId>
<version>${ktlint.version}</version>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-reporter-baseline</artifactId>
<version>${ktlint.version}</version>
</dependency>
<dependency>
Expand All @@ -102,7 +112,12 @@
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-ruleset-experimental</artifactId>
<artifactId>ktlint-rule-engine</artifactId>
<version>${ktlint.version}</version>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-rule-engine-core</artifactId>
<version>${ktlint.version}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -291,7 +306,19 @@
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-core</artifactId>
<artifactId>ktlint-cli-reporter</artifactId>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-cli-ruleset-core</artifactId>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-reporter-plain</artifactId>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-rule-engine</artifactId>
<exclusions>
<exclusion>
<!-- Slf4j is natively supported by Maven -->
Expand All @@ -302,7 +329,14 @@
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-reporter-plain</artifactId>
<artifactId>ktlint-rule-engine-core</artifactId>
<exclusions>
<exclusion>
<!-- Slf4j is natively supported by Maven -->
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down Expand Up @@ -377,17 +411,17 @@
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-reporter-checkstyle</artifactId>
<artifactId>ktlint-reporter-baseline</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-reporter-json</artifactId>
<artifactId>ktlint-reporter-checkstyle</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.pinterest.ktlint</groupId>
<artifactId>ktlint-ruleset-experimental</artifactId>
<artifactId>ktlint-reporter-json</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ abstract class AbstractBaseMojo : AbstractMojo() {
@Parameter(property = "ktlint.includeScripts", defaultValue = "true", required = true)
protected var includeScripts = true

/**
* File file encoding of the Kotlin source files.
*/
@Parameter(property = "encoding", defaultValue = "\${project.build.sourceEncoding}")
protected val encoding: String? = null

/**
* A list of inclusion filters for the source files to be processed under the source roots.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ package com.github.gantsign.maven.plugin.ktlint

import com.github.gantsign.maven.plugin.ktlint.internal.Check
import com.github.gantsign.maven.plugin.ktlint.internal.Sources
import com.pinterest.ktlint.reporter.plain.Color
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.UTF_8
import com.pinterest.ktlint.cli.reporter.plain.Color
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
Expand Down Expand Up @@ -109,9 +107,6 @@ class CheckMojo : AbstractBaseMojo() {
excludes = scriptsExcludes,
),
),
charset = encoding?.trim()?.takeUnless(String::isEmpty)
?.let { Charset.forName(it) }
?: UTF_8,
android = android,
reporterConfig = reporters ?: emptySet(),
verbose = verbose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ package com.github.gantsign.maven.plugin.ktlint

import com.github.gantsign.maven.plugin.ktlint.internal.Format
import com.github.gantsign.maven.plugin.ktlint.internal.Sources
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.UTF_8
import org.apache.maven.plugins.annotations.LifecyclePhase
import org.apache.maven.plugins.annotations.Mojo
import org.apache.maven.plugins.annotations.Parameter
Expand Down Expand Up @@ -78,9 +76,6 @@ class FormatMojo : AbstractBaseMojo() {
excludes = scriptsExcludes,
),
),
charset = encoding?.trim()?.takeUnless(String::isEmpty)
?.let { Charset.forName(it) }
?: UTF_8,
android = android,
enableExperimentalRules = experimental,
)()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import com.github.gantsign.maven.plugin.ktlint.internal.Report
import com.github.gantsign.maven.plugin.ktlint.internal.Sources
import com.github.gantsign.maven.plugin.ktlint.internal.get
import java.io.File
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.UTF_8
import java.util.Locale
import java.util.ResourceBundle
import org.apache.maven.plugins.annotations.LifecyclePhase
Expand Down Expand Up @@ -206,9 +204,6 @@ class KtlintReport : AbstractMavenReport() {
excludes = scriptsExcludes,
),
),
charset = encoding?.trim()?.takeUnless(String::isEmpty)
?.let { Charset.forName(it) }
?: UTF_8,
android = android,
reporterConfig = reporters ?: emptySet(),
verbose = verbose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
package com.github.gantsign.maven.plugin.ktlint

import com.pinterest.ktlint.core.LintError
import com.pinterest.ktlint.core.Reporter
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError
import com.pinterest.ktlint.cli.reporter.core.api.ReporterV2
import java.io.File
import java.util.concurrent.ConcurrentHashMap
import org.apache.maven.plugin.logging.Log
Expand All @@ -37,17 +37,15 @@ class MavenLogReporter(
val verbose: Boolean,
val groupByFile: Boolean,
val pad: Boolean,
) : Reporter {
) : ReporterV2 {

private val acc = ConcurrentHashMap<String, MutableList<LintError>>()
private val acc = ConcurrentHashMap<String, MutableList<KtlintCliError>>()

override fun onLintError(file: String, err: LintError, corrected: Boolean) {
if (corrected) return

val (line, col, ruleId, detail) = err
override fun onLintError(file: String, ktlintCliError: KtlintCliError) {
val (line, col, ruleId, detail) = ktlintCliError

if (groupByFile) {
acc.getOrPut(file) { ArrayList() }.add(err)
acc.getOrPut<String?, MutableList<KtlintCliError>?>(file, ::ArrayList)!!.add(ktlintCliError)
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
*/
package com.github.gantsign.maven.plugin.ktlint

import com.pinterest.ktlint.core.ReporterProvider
import com.pinterest.ktlint.cli.reporter.core.api.ReporterProviderV2
import java.io.PrintStream
import org.apache.maven.plugin.logging.Log

class MavenLogReporterProvider : ReporterProvider<MavenLogReporter> {
class MavenLogReporterProvider : ReporterProviderV2<MavenLogReporter> {

override val id: String = "maven"

Expand Down

0 comments on commit ab041ec

Please sign in to comment.