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

Diktat CLI runner #1653

Merged
merged 37 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
e884d00
### What's done:
nulls Mar 30, 2023
bbc78fb
### What's done:
nulls Mar 31, 2023
a96d996
fixed import in diktat-runner-cli
nulls Mar 31, 2023
b188481
fixed reporter creation
nulls Mar 31, 2023
3ff383a
WIP
nulls Mar 31, 2023
57be974
extracted plain reporter to a dedicated function in factory
nulls Apr 3, 2023
fee0e51
moved all ktlint to diktat-runner-ktlint-engine
nulls Apr 3, 2023
019395b
fixed DiktatMain
nulls Apr 3, 2023
2a697d1
fixed `loggerWithKtlintConfig`
nulls Apr 3, 2023
61f1103
renaming
nulls Apr 3, 2023
001781d
Merge remote-tracking branch 'origin/master' into feature/diktat-cli
nulls Apr 3, 2023
f0a1c3e
fixed renaming
nulls Apr 3, 2023
3bd0aff
Merge remote-tracking branch 'origin/master' into feature/diktat-cli
nulls Apr 5, 2023
0ca2da5
reverted unwanted changes
nulls Apr 5, 2023
d87a462
fixed DiktatMain to use a new DiktatRunner
nulls Apr 5, 2023
93d16b6
diktatFix
nulls Apr 5, 2023
bbe9ac9
fixed --version and --license
nulls Apr 5, 2023
fcd27bf
fixed --license
nulls Apr 5, 2023
57129b1
supported test using diktat-cli
nulls Apr 5, 2023
fc1203f
fixed checking condition in github's matrix
nulls Apr 5, 2023
f4abea8
fixed build of diktat-cli
nulls Apr 5, 2023
10f8efa
added dependency to diktat-api explicitly
nulls Apr 5, 2023
2f3369b
fixed clash in file name
nulls Apr 5, 2023
8751906
fixed absolute path resolving
nulls Apr 5, 2023
f47e211
fixed absolute path resolving
nulls Apr 5, 2023
863c956
matching by two globs
nulls Apr 5, 2023
484edc1
diktatFix
nulls Apr 5, 2023
32af2fd
added test for glob walker
nulls Apr 5, 2023
09d905e
review notes
nulls Apr 6, 2023
16ae41b
added a debug code
nulls Apr 6, 2023
64a1f22
Merge remote-tracking branch 'origin/master' into feature/diktat-cli
nulls Apr 6, 2023
be77b21
fixed running on Windows
nulls Apr 6, 2023
ba07c84
added more debug info
nulls Apr 6, 2023
b779464
added debug print for all cases
nulls Apr 6, 2023
ec7162b
moved debug print to tests
nulls Apr 6, 2023
031d03b
fixed test on MacOs + updated debug info
nulls Apr 6, 2023
0183ae1
cleanup debug
nulls Apr 6, 2023
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
2 changes: 0 additions & 2 deletions diktat-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ dependencies {
api(libs.kaml)
implementation(libs.apache.commons.cli)
implementation(libs.kotlin.logging)
// ktlint-core is needed only for `initKtLintKLogger` method
implementation(libs.ktlint.core)
testImplementation(libs.junit.jupiter)
testImplementation(libs.assertj.core)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cqfn.diktat.common.config.reader

import org.cqfn.diktat.common.utils.loggerWithKtlintConfig
import mu.KotlinLogging

import java.io.IOException
Expand Down Expand Up @@ -36,7 +35,7 @@ open class ApplicationProperties(propertiesFileName: String) {
}

companion object {
private val log = KotlinLogging.loggerWithKtlintConfig(ApplicationProperties::class)
private val log = KotlinLogging.logger {}
private const val EXIT_STATUS_MISSING_PROPERTIES = 4
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cqfn.diktat.common.config.reader

import org.cqfn.diktat.common.utils.loggerWithKtlintConfig
import mu.KotlinLogging

import java.io.BufferedReader
Expand Down Expand Up @@ -57,6 +56,6 @@ abstract class JsonResourceConfigReader<T> {
protected abstract fun parseResource(fileStream: BufferedReader): T

companion object {
private val log = KotlinLogging.loggerWithKtlintConfig(JsonResourceConfigReader::class)
private val log = KotlinLogging.logger { }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package org.cqfn.diktat.common.config.rules

import org.cqfn.diktat.common.config.reader.JsonResourceConfigReader
import org.cqfn.diktat.common.config.rules.RulesConfigReader.Companion.log
import org.cqfn.diktat.common.utils.loggerWithKtlintConfig

import com.charleskorn.kaml.Yaml
import com.charleskorn.kaml.YamlConfiguration
Expand Down Expand Up @@ -106,7 +105,7 @@ open class RulesConfigReader(override val classLoader: ClassLoader) : JsonResour
}

companion object {
internal val log: KLogger = KotlinLogging.loggerWithKtlintConfig(RulesConfigReader::class)
internal val log: KLogger = KotlinLogging.logger { }
}
}

Expand Down
7 changes: 1 addition & 6 deletions diktat-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@ plugins {

dependencies {
implementation(kotlin("gradle-plugin-api"))
implementation(projects.diktatRules)
implementation(projects.diktatRunner.diktatRunnerKtlintEngine)
implementation(libs.ktlint.core)
implementation(libs.ktlint.reporter.plain)
implementation(libs.ktlint.reporter.sarif)
implementation(libs.ktlint.reporter.json)
implementation(libs.ktlint.reporter.html)
implementation(libs.ktlint.reporter.baseline)
// merge sarif reports
implementation(libs.sarif4k.jvm)
implementation(libs.kotlinx.serialization.json)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.cqfn.diktat.plugin.gradle.tasks

import org.cqfn.diktat.DiktatProcessCommand
import org.cqfn.diktat.DiktatProcessor
import org.cqfn.diktat.api.DiktatProcessorListener
import org.cqfn.diktat.plugin.gradle.DiktatExtension
import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.api.tasks.util.PatternSet
import java.nio.file.Path
import javax.inject.Inject

/**
Expand All @@ -16,8 +18,13 @@ abstract class DiktatCheckTask @Inject constructor(
extension: DiktatExtension,
inputs: PatternFilterable
) : DiktatTaskBase(extension, inputs) {
override fun doRun(diktatCommand: DiktatProcessCommand, formattedContentConsumer: (String) -> Unit) {
diktatCommand.check()
override fun doRun(
diktatProcessor: DiktatProcessor,
listener: DiktatProcessorListener,
files: Sequence<Path>,
formattedContentConsumer: (Path, String) -> Unit
) {
diktatProcessor.checkAll(listener, files)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package org.cqfn.diktat.plugin.gradle.tasks

import org.cqfn.diktat.DiktatProcessCommand
import org.cqfn.diktat.DiktatProcessor
import org.cqfn.diktat.api.DiktatProcessorListener
import org.cqfn.diktat.plugin.gradle.DiktatExtension
import org.cqfn.diktat.plugin.gradle.DiktatGradlePlugin
import org.gradle.api.Project
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.util.PatternFilterable
import org.gradle.api.tasks.util.PatternSet
import java.nio.file.Path
import javax.inject.Inject

/**
Expand All @@ -16,9 +18,12 @@ abstract class DiktatFixTask @Inject constructor(
extension: DiktatExtension,
inputs: PatternFilterable
) : DiktatTaskBase(extension, inputs) {
override fun doRun(diktatCommand: DiktatProcessCommand, formattedContentConsumer: (String) -> Unit) {
val formattedText = diktatCommand.fix()
formattedContentConsumer(formattedText)
override fun doRun(
diktatProcessor: DiktatProcessor,
listener: DiktatProcessorListener,
files: Sequence<Path>, formattedContentConsumer: (Path, String) -> Unit
) {
diktatProcessor.fixAll(listener, files, formattedContentConsumer)
}

companion object {
Expand Down
Loading