diff --git a/diktat-common/build.gradle.kts b/diktat-common/build.gradle.kts index 3dd6061bcc..a4215a0a42 100644 --- a/diktat-common/build.gradle.kts +++ b/diktat-common/build.gradle.kts @@ -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) } diff --git a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/ApplicationProperties.kt b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/ApplicationProperties.kt index 226ed29f65..0ee4fe2de3 100644 --- a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/ApplicationProperties.kt +++ b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/ApplicationProperties.kt @@ -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 @@ -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 } } diff --git a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/JsonResourceConfigReader.kt b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/JsonResourceConfigReader.kt index 4d0d918091..6da9a9a3d3 100644 --- a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/JsonResourceConfigReader.kt +++ b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/reader/JsonResourceConfigReader.kt @@ -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 @@ -57,6 +56,6 @@ abstract class JsonResourceConfigReader { protected abstract fun parseResource(fileStream: BufferedReader): T companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(JsonResourceConfigReader::class) + private val log = KotlinLogging.logger {} } } diff --git a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt index c063e840ce..a73dfde41f 100644 --- a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt +++ b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/config/rules/RulesConfigReader.kt @@ -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 @@ -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 {} } } diff --git a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/utils/LoggingUtils.kt b/diktat-common/src/main/kotlin/org/cqfn/diktat/common/utils/LoggingUtils.kt deleted file mode 100644 index 71391e8923..0000000000 --- a/diktat-common/src/main/kotlin/org/cqfn/diktat/common/utils/LoggingUtils.kt +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Utilities related to logging - */ - -package org.cqfn.diktat.common.utils - -import com.pinterest.ktlint.core.initKtLintKLogger -import mu.KotlinLogging -import kotlin.reflect.KClass - -/** - * Create a logger using [KotlinLogging] and configure it by ktlint's mechanism - * - * @param func empty fun which is used to get enclosing class name - * @return a logger - */ -fun KotlinLogging.loggerWithKtlintConfig(func: () -> Unit) = - logger(func).initKtLintKLogger() - -/** - * Create a logger using [KotlinLogging] and configure it by ktlint's mechanism - * - * @param clazz a class for which logger is needed - * @return a logger - */ -fun KotlinLogging.loggerWithKtlintConfig(clazz: KClass<*>) = - logger(clazz.java.name).initKtLintKLogger() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.kt index 2ef540c1a4..c1daba4b01 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRule.kt @@ -2,7 +2,6 @@ package org.cqfn.diktat.ruleset.rules import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.isRuleEnabled -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.EmitType import org.cqfn.diktat.ruleset.utils.getFilePath @@ -91,6 +90,6 @@ abstract class DiktatRule( abstract fun logic(node: ASTNode) companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(DiktatRule::class) + private val log = KotlinLogging.logger {} } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt index c241895a94..3e20177cc2 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt @@ -10,7 +10,6 @@ import org.cqfn.diktat.common.config.rules.DIKTAT_CONF_PROPERTY import org.cqfn.diktat.common.config.rules.DIKTAT_RULE_SET_ID import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings import org.cqfn.diktat.ruleset.rules.chapter1.FileNaming import org.cqfn.diktat.ruleset.rules.chapter1.IdentifierNaming @@ -281,6 +280,6 @@ class DiktatRuleSetProvider(private val diktatConfigFile: String = DIKTAT_ANALYS private fun resolveConfigFileFromSystemProperty(): String? = System.getProperty(DIKTAT_CONF_PROPERTY) companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(DiktatRuleSetProvider::class) + private val log = KotlinLogging.logger {} } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt index 0f3d5f8968..f505ab0074 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt @@ -3,7 +3,6 @@ package org.cqfn.diktat.ruleset.rules.chapter1 import org.cqfn.diktat.common.config.rules.CommonConfiguration import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getCommonConfiguration -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.INCORRECT_PACKAGE_SEPARATOR import org.cqfn.diktat.ruleset.constants.Warnings.PACKAGE_NAME_INCORRECT_CASE import org.cqfn.diktat.ruleset.constants.Warnings.PACKAGE_NAME_INCORRECT_PATH @@ -282,7 +281,7 @@ class PackageNaming(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(PackageNaming::class) + private val log = KotlinLogging.logger {} const val NAME_ID = "package-naming" /** diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt index 7dd72bf895..eeb74bf059 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt @@ -1,7 +1,6 @@ package org.cqfn.diktat.ruleset.rules.chapter2.comments import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.ListOfPairs import org.cqfn.diktat.ruleset.constants.Warnings.COMMENTED_OUT_CODE import org.cqfn.diktat.ruleset.rules.DiktatRule @@ -174,8 +173,8 @@ class CommentsRule(configRules: List) : DiktatRule( @Suppress("MaxLineLength") companion object { - private val logger = KotlinLogging.loggerWithKtlintConfig(CommentsRule::class) const val NAME_ID = "comments" + private val logger = KotlinLogging.logger {} private val importKeywordWithSpace = "${KtTokens.IMPORT_KEYWORD.value} " private val packageKeywordWithSpace = "${KtTokens.PACKAGE_KEYWORD.value} " private val importOrPackage = """($importKeywordWithSpace|$packageKeywordWithSpace)""".toRegex() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt index 8bfbaf0347..544302ed1c 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt @@ -3,7 +3,6 @@ package org.cqfn.diktat.ruleset.rules.chapter2.comments import org.cqfn.diktat.common.config.rules.RuleConfiguration import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getRuleConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE import org.cqfn.diktat.ruleset.constants.Warnings.HEADER_MISSING_OR_WRONG_COPYRIGHT import org.cqfn.diktat.ruleset.constants.Warnings.HEADER_NOT_BEFORE_PACKAGE @@ -274,7 +273,7 @@ class HeaderCommentRule(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(HeaderCommentRule::class) + private val log = KotlinLogging.logger {} const val CURR_YEAR_PATTERN = ";@currYear;" const val NAME_ID = "header-comment" val hyphenRegex = Regex("""\d+-\d+""") diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt index 6fb5c6ee61..5bdc4b133d 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt @@ -4,7 +4,6 @@ import org.cqfn.diktat.common.config.rules.RuleConfiguration import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getCommonConfiguration import org.cqfn.diktat.common.config.rules.getRuleConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.TRAILING_COMMA import org.cqfn.diktat.ruleset.rules.DiktatRule @@ -134,7 +133,7 @@ class TrailingCommaRule(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(TrailingCommaRule::class) + private val log = KotlinLogging.logger {} const val NAME_ID = "trailing-comma" val ktVersion = KotlinVersion(1, 4) val whenChildrenTypes = listOf(WHEN_CONDITION_WITH_EXPRESSION, WHEN_CONDITION_IS_PATTERN, WHEN_CONDITION_IN_RANGE) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt index eda4d21bc7..d80542f6b8 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt @@ -8,7 +8,6 @@ package org.cqfn.diktat.ruleset.rules.chapter3.files import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getRuleConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.WRONG_INDENTATION import org.cqfn.diktat.ruleset.rules.DiktatRule import org.cqfn.diktat.ruleset.rules.chapter3.files.IndentationAmount.NONE @@ -686,7 +685,7 @@ class IndentationRule(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(IndentationRule::class) + private val log = KotlinLogging.logger {} const val NAME_ID = "indentation" private val increasingTokens: Set = linkedSetOf(LPAR, LBRACE, LBRACKET, LONG_TEMPLATE_ENTRY_START) private val decreasingTokens: Set = linkedSetOf(RPAR, RBRACE, RBRACKET, LONG_TEMPLATE_ENTRY_END) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt index 01624e603a..241330f51b 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt @@ -3,7 +3,6 @@ package org.cqfn.diktat.ruleset.rules.chapter3.files import org.cqfn.diktat.common.config.rules.RuleConfiguration import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getRuleConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.ListOfList import org.cqfn.diktat.ruleset.constants.Warnings.COMPLEX_EXPRESSION import org.cqfn.diktat.ruleset.constants.Warnings.REDUNDANT_SEMICOLON @@ -711,7 +710,7 @@ class NewlinesRule(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(NewlinesRule::class) + private val log = KotlinLogging.logger {} const val MAX_CALLS_IN_ONE_LINE = 3 const val NAME_ID = "newlines" diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt index fecbe71c89..7d5ac884f1 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt @@ -2,7 +2,6 @@ package org.cqfn.diktat.ruleset.rules.chapter3.files import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.getRuleConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.LONG_LINE import org.cqfn.diktat.ruleset.constants.Warnings.WRONG_INDENTATION import org.cqfn.diktat.ruleset.constants.Warnings.WRONG_WHITESPACE @@ -459,7 +458,7 @@ class WhiteSpaceRule(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(WhiteSpaceRule::class) + private val log = KotlinLogging.logger {} const val NAME_ID = "horizontal-whitespace" private const val NUM_PARENTS_FOR_LAMBDA = 3 // this is the number of parent nodes needed to check if this node is lambda from argument list diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt index 192ce0e612..35ce4d6e87 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt @@ -1,7 +1,6 @@ package org.cqfn.diktat.ruleset.rules.chapter6.classes import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.ruleset.constants.Warnings.COMPACT_OBJECT_INITIALIZATION import org.cqfn.diktat.ruleset.rules.DiktatRule import org.cqfn.diktat.ruleset.utils.KotlinParser @@ -212,7 +211,7 @@ class CompactInitialization(configRules: List) : DiktatRule( } companion object { - private val log = KotlinLogging.loggerWithKtlintConfig(CompactInitialization::class) + private val log = KotlinLogging.logger {} const val NAME_ID = "class-compact-initialization" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KtlintUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KtlintUtils.kt index 6d773bd279..8823ed602a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KtlintUtils.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/KtlintUtils.kt @@ -5,7 +5,6 @@ package org.cqfn.diktat.ruleset.utils -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import com.pinterest.ktlint.core.KtLint import com.pinterest.ktlint.core.KtLint.ExperimentalParams import com.pinterest.ktlint.core.LintError @@ -13,8 +12,7 @@ import com.pinterest.ktlint.core.RuleSetProvider import mu.KotlinLogging import org.intellij.lang.annotations.Language -@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -private val log = KotlinLogging.loggerWithKtlintConfig {} +private val log = KotlinLogging.logger {} @Suppress("TYPE_ALIAS") val defaultCallback: (lintError: LintError, corrected: Boolean) -> Unit = { lintError, _ -> diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt index 982445f59d..f1f059f351 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/StringCaseUtils.kt @@ -2,14 +2,12 @@ package org.cqfn.diktat.ruleset.utils -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import com.google.common.base.CaseFormat import mu.KotlinLogging import java.util.Locale -@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -private val log = KotlinLogging.loggerWithKtlintConfig {} +private val log = KotlinLogging.logger {} /** * Available cases to name enum members diff --git a/diktat-ruleset/build.gradle.kts b/diktat-ruleset/build.gradle.kts index 43fb22d3aa..e29302719b 100644 --- a/diktat-ruleset/build.gradle.kts +++ b/diktat-ruleset/build.gradle.kts @@ -35,6 +35,8 @@ dependencies { tasks.named("shadowJar") { archiveBaseName.set("diktat") archiveClassifier.set("") + // need to relocate serialization from kaml to avoid conflicts with KtLint + relocate("kotlinx.serialization", "com.saveourtool.kotlinx_serialization") } // disable default jar diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt b/diktat-ruleset/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt similarity index 73% rename from diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt rename to diktat-ruleset/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt index 1bfcab8f82..dad43adfcc 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt +++ b/diktat-ruleset/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProviderSpi.kt @@ -3,6 +3,9 @@ package org.cqfn.diktat.ruleset.rules import org.cqfn.diktat.ktlint.KtLintRuleSetProviderWrapper.Companion.toKtLint import com.pinterest.ktlint.core.RuleSet import com.pinterest.ktlint.core.RuleSetProvider +import com.pinterest.ktlint.core.initKtLintKLogger +import mu.KotlinLogging +import org.slf4j.Logger /** * [RuleSetProvider] that provides diKTat ruleset. @@ -13,5 +16,10 @@ import com.pinterest.ktlint.core.RuleSetProvider * This class is registered in [resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider] */ class DiktatRuleSetProviderSpi : RuleSetProvider { + init { + // Need to init KtLint logger to set log level from CLI + KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).initKtLintKLogger() + } + override fun get(): RuleSet = DiktatRuleSetProvider().toKtLint().get() } diff --git a/diktat-rules/src/main/resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider b/diktat-ruleset/src/main/resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider similarity index 100% rename from diktat-rules/src/main/resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider rename to diktat-ruleset/src/main/resources/META-INF/services/com.pinterest.ktlint.core.RuleSetProvider diff --git a/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt b/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt index 3b82f5dcc9..ff02040efb 100644 --- a/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt +++ b/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSaveSmokeTest.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.ruleset.smoke -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.test.framework.processing.TestComparatorUnit import org.cqfn.diktat.test.framework.util.checkForkedJavaHome import org.cqfn.diktat.test.framework.util.deleteIfExistsRecursively @@ -129,8 +128,7 @@ class DiktatSaveSmokeTest : DiktatSmokeTestBase() { } companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val logger = KotlinLogging.loggerWithKtlintConfig { } + private val logger = KotlinLogging.logger {} private const val BASE_DIRECTORY = "src/test/resources/test/smoke" private const val SAVE_VERSION: String = "0.3.4" private const val WINDOWS_TEMP_DIRECTORY = ".save-cli" diff --git a/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestUtils.kt b/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestUtils.kt index a4c1397768..12807c7390 100644 --- a/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestUtils.kt +++ b/diktat-ruleset/src/test/kotlin/org/cqfn/diktat/ruleset/smoke/DiktatSmokeTestUtils.kt @@ -2,7 +2,6 @@ package org.cqfn.diktat.ruleset.smoke -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.test.framework.util.retry import mu.KotlinLogging import org.assertj.core.api.Assertions.fail @@ -18,8 +17,7 @@ internal const val DIKTAT_FAT_JAR_GLOB = "diktat-*.jar" internal const val KTLINT_FAT_JAR = "ktlint" internal const val KTLINT_VERSION = "0.46.1" -@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -private val logger = KotlinLogging.loggerWithKtlintConfig { } +private val logger = KotlinLogging.logger {} /** * Downloads the file from a remote URL, retrying if necessary. diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/common/LocalCommandExecutor.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/common/LocalCommandExecutor.kt index 4a6ba5a6c9..7a8e3fd402 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/common/LocalCommandExecutor.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/common/LocalCommandExecutor.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.common -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import mu.KotlinLogging import java.io.IOException @@ -37,7 +36,6 @@ class LocalCommandExecutor internal constructor(private val command: String) { } companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val log = KotlinLogging.loggerWithKtlintConfig {} + private val log = KotlinLogging.logger {} } } diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/config/TestArgumentsReader.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/config/TestArgumentsReader.kt index 72e8a420c5..fbfd9ed9ed 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/config/TestArgumentsReader.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/config/TestArgumentsReader.kt @@ -2,7 +2,6 @@ package org.cqfn.diktat.test.framework.config import org.cqfn.diktat.common.cli.CliArgument import org.cqfn.diktat.common.config.reader.JsonResourceConfigReader -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import mu.KotlinLogging import org.apache.commons.cli.CommandLine @@ -95,7 +94,6 @@ class TestArgumentsReader( } companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val log = KotlinLogging.loggerWithKtlintConfig {} + private val log = KotlinLogging.logger {} } } diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/FileComparator.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/FileComparator.kt index ebbeda730a..8d93ee66ec 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/FileComparator.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/FileComparator.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.processing -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import io.github.petertrr.diffutils.diff import io.github.petertrr.diffutils.patch.ChangeDelta import io.github.petertrr.diffutils.text.DiffRowGenerator @@ -110,8 +109,7 @@ class FileComparator( } companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val log = KotlinLogging.loggerWithKtlintConfig {} + private val log = KotlinLogging.logger {} /** * @param file file where to write these list to, separated with newlines. diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCheckWarn.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCheckWarn.kt index 8f26aa3fc0..2a25bc6015 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCheckWarn.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCheckWarn.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.processing -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.test.framework.config.TestConfig import mu.KLogger import mu.KotlinLogging @@ -9,8 +8,8 @@ import mu.KotlinLogging * [TestCompare] that uses stderr as tests output stream */ class TestCheckWarn : TestCompare() { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR", "MISSING_KDOC_CLASS_ELEMENTS") - override val log: KLogger = KotlinLogging.loggerWithKtlintConfig {} + @Suppress("MISSING_KDOC_CLASS_ELEMENTS") + override val log: KLogger = KotlinLogging.logger {} @Suppress( "UnusedPrivateMember", diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt index f9d8900487..49fb848025 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestComparatorUnit.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.processing -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import mu.KotlinLogging import java.io.IOException import java.nio.file.Path @@ -125,8 +124,7 @@ class TestComparatorUnit( } private companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val log = KotlinLogging.loggerWithKtlintConfig {} + private val log = KotlinLogging.logger {} /** * @param file the file whose content is to be read. diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCompare.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCompare.kt index 30ae35cf16..9723b17cbb 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCompare.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestCompare.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.processing -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.test.framework.common.ExecutionResult import org.cqfn.diktat.test.framework.common.TestBase import org.cqfn.diktat.test.framework.config.TestConfig @@ -17,8 +16,8 @@ import java.io.File */ @Suppress("ForbiddenComment") open class TestCompare : TestBase { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR", "MISSING_KDOC_CLASS_ELEMENTS") - protected open val log: KLogger = KotlinLogging.loggerWithKtlintConfig {} + @Suppress("MISSING_KDOC_CLASS_ELEMENTS") + protected open val log: KLogger = KotlinLogging.logger {} private lateinit var expectedResult: File // testResultFile will be used if and only if --in-place option will be used diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestProcessingFactory.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestProcessingFactory.kt index 76b23cffd6..b3279467ae 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestProcessingFactory.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/processing/TestProcessingFactory.kt @@ -1,6 +1,5 @@ package org.cqfn.diktat.test.framework.processing -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig import org.cqfn.diktat.test.framework.common.TestBase import org.cqfn.diktat.test.framework.config.TestArgumentsReader import org.cqfn.diktat.test.framework.config.TestConfig @@ -90,8 +89,7 @@ class TestProcessingFactory(private val argReader: TestArgumentsReader) { } companion object { - @Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") - private val log = KotlinLogging.loggerWithKtlintConfig {} + private val log = KotlinLogging.logger {} private const val STATUS_FIVE = 5 private const val STATUS_THREE = 3 } diff --git a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/util/TestUtils.kt b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/util/TestUtils.kt index bd0f40ad2e..589dcfaea3 100644 --- a/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/util/TestUtils.kt +++ b/diktat-test-framework/src/main/kotlin/org/cqfn/diktat/test/framework/util/TestUtils.kt @@ -4,8 +4,6 @@ package org.cqfn.diktat.test.framework.util -import org.cqfn.diktat.common.utils.loggerWithKtlintConfig - import mu.KotlinLogging import java.io.File @@ -32,8 +30,7 @@ import kotlin.io.path.div import kotlin.io.path.isDirectory import kotlin.io.path.isSameFileAs -@Suppress("EMPTY_BLOCK_STRUCTURE_ERROR") -private val logger = KotlinLogging.loggerWithKtlintConfig {} +private val logger = KotlinLogging.logger {} /** * Deletes the file if it exists, retrying as necessary if the file is diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 1203ca6a89..0fed4cae8a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -21,8 +21,7 @@ plexus = "2.0" jbool = "1.24" # downgraded to be compliance with ktlint mu-logging = "2.1.23" -# downgraded to be compliance with ktlint -kaml = "0.47.0" +kaml = "0.53.0" kotlin-multiplatform-diff = "0.4.0" sarif4k = "0.3.0" jupiter-itf-extension = "0.12.0" diff --git a/renovate.json b/renovate.json index f4bcbbb7a5..c486c7538b 100644 --- a/renovate.json +++ b/renovate.json @@ -58,13 +58,6 @@ ], "allowedVersions": "<= 2.1.23" }, - { - "managers": ["gradle"], - "matchPackageNames": [ - "com.charleskorn.kaml:kaml" - ], - "allowedVersions": "<= 0.47.0" - }, { "managers": ["gradle"], "matchPackageNames": [