-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from usefulness/mateuszkwiecinski/bump_ktlint_…
…to_0_49_0
- Loading branch information
Showing
33 changed files
with
199 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 6 additions & 15 deletions
21
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/support/BaselineUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
package io.github.usefulness.support | ||
|
||
import com.pinterest.ktlint.core.LintError | ||
import com.pinterest.ktlint.core.api.Baseline | ||
import com.pinterest.ktlint.core.api.loadBaseline | ||
import com.pinterest.ktlint.cli.reporter.baseline.Baseline | ||
import com.pinterest.ktlint.cli.reporter.baseline.loadBaseline | ||
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError | ||
import java.io.File | ||
|
||
internal fun File.readKtlintBaseline(): Map<String, List<LintError>>? { | ||
internal fun File.readKtlintBaseline(): Map<String, List<KtlintCliError>>? { | ||
val baseline = loadBaseline(absolutePath) | ||
when (baseline.status) { | ||
Baseline.Status.VALID -> Unit | ||
Baseline.Status.NOT_FOUND, | ||
Baseline.Status.INVALID, | ||
Baseline.Status.DISABLED, | ||
-> return null | ||
} | ||
}.let { } | ||
|
||
return baseline.lintErrorsPerFile | ||
} | ||
|
||
internal fun File.getBaselineKey(projectDir: File) = | ||
toRelativeString(projectDir).replace(File.separatorChar, '/') | ||
|
||
/** | ||
* Same as ktlint, avoids unnecessary incompatibility issues | ||
*/ | ||
internal fun List<LintError>.doesNotContain(lintError: LintError) = | ||
none { | ||
it.col == lintError.col && | ||
it.line == lintError.line && | ||
it.ruleId == lintError.ruleId | ||
} |
6 changes: 3 additions & 3 deletions
6
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/support/EditorConfigUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/support/KtlintEngineUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/support/KtlintErrorResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
package io.github.usefulness.support | ||
|
||
import com.pinterest.ktlint.core.LintError | ||
import com.pinterest.ktlint.cli.reporter.core.api.KtlintCliError | ||
import java.io.File | ||
import java.io.Serializable | ||
|
||
internal data class KtlintErrorResult( | ||
val file: File, | ||
val errors: List<Pair<LintError, Boolean>>, | ||
val errors: List<KtlintCliError>, | ||
) : Serializable { | ||
|
||
companion object { | ||
|
||
const val serialVersionUID = 1L | ||
const val serialVersionUID = 2L | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 9 additions & 8 deletions
17
ktlint-gradle-plugin/src/main/kotlin/io/github/usefulness/support/RuleSets.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
package io.github.usefulness.support | ||
|
||
import com.pinterest.ktlint.core.RuleProvider | ||
import com.pinterest.ktlint.core.RuleSetProviderV2 | ||
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3 | ||
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider | ||
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId | ||
import java.util.ServiceLoader | ||
|
||
internal fun resolveRuleProviders( | ||
providers: Iterable<RuleSetProviderV2>, | ||
providers: Iterable<RuleSetProviderV3>, | ||
): Set<RuleProvider> = providers | ||
.asSequence() | ||
.sortedWith( | ||
compareBy { | ||
when (it.id) { | ||
"standard" -> 0 | ||
when (it.id.value) { | ||
RuleSetId.STANDARD.value -> 0 | ||
else -> 1 | ||
} | ||
}, | ||
) | ||
.map(RuleSetProviderV2::getRuleProviders) | ||
.map(RuleSetProviderV3::getRuleProviders) | ||
.flatten() | ||
.toSet() | ||
|
||
// statically resolve providers from plugin classpath. ServiceLoader#load alone resolves classes lazily which fails when run in parallel | ||
internal val defaultRuleSetProviders: List<RuleSetProviderV2> = | ||
ServiceLoader.load(RuleSetProviderV2::class.java).toList() | ||
internal val defaultRuleSetProviders: List<RuleSetProviderV3> = | ||
ServiceLoader.load(RuleSetProviderV3::class.java).toList() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.