From c7abfc91bbafaf8498a20c42a18dae53dd33bbbd Mon Sep 17 00:00:00 2001 From: kentr0w Date: Tue, 9 Feb 2021 17:48:37 +0300 Subject: [PATCH] Multiple error ### What's done: Added atomic counter --- .../diktat/common/config/rules/RulesConfigReader.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 94394510b2..1bb210e853 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 @@ -17,6 +17,7 @@ import java.io.File import kotlinx.serialization.Serializable import kotlinx.serialization.decodeFromString +import java.util.concurrent.atomic.AtomicInteger const val DIKTAT_COMMON = "DIKTAT_COMMON" @@ -122,7 +123,9 @@ data class CommonConfiguration(private val configuration: Map?) */ val kotlinVersion: KotlinVersion by lazy { configuration?.get("kotlinVersion")?.kotlinVersion() ?: run { - log.error("Kotlin version not specified in the configuration file. Will be using ${KotlinVersion.CURRENT} version") + if(visitorCounter.incrementAndGet() == 1) { + log.error("Kotlin version not specified in the configuration file. Will be using ${KotlinVersion.CURRENT} version") + } KotlinVersion.CURRENT } } @@ -131,6 +134,13 @@ data class CommonConfiguration(private val configuration: Map?) * False if configuration has been read from config file, true if defaults are used */ val isDefault = configuration == null + + companion object { + /** + * Counter that helps not to raise multiple warnings about kotlin version + */ + var visitorCounter = AtomicInteger(0) + } } // ================== utils for List from yml config