From 659c532e5a0795e645e4bfbb45e06124599081a4 Mon Sep 17 00:00:00 2001 From: Artur Bosch Date: Sun, 25 Sep 2022 19:26:37 +0200 Subject: [PATCH] Change requires type resolution rule warning to debug level to not spam the user console --- .../kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt | 8 ++++---- .../arturbosch/detekt/core/ProcessingSettingsFactory.kt | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt index 44cc294f5bd..c6dac59e708 100644 --- a/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt +++ b/detekt-core/src/main/kotlin/io/gitlab/arturbosch/detekt/core/Analyzer.kt @@ -43,7 +43,6 @@ internal class Analyzer( ): Map> { val languageVersionSettings = settings.environment.configuration.languageVersionSettings - @Suppress("DEPRECATION") val dataFlowValueFactory = DataFlowValueFactoryImpl(languageVersionSettings) val compilerResources = CompilerResources(languageVersionSettings, dataFlowValueFactory) val findingsPerFile: FindingsResult = @@ -52,8 +51,9 @@ internal class Analyzer( } else { runSync(ktFiles, bindingContext, compilerResources) } + if (bindingContext == BindingContext.EMPTY) { - warnAboutEnabledRequiresTypeResolutionRules(settings::info) + warnAboutEnabledRequiresTypeResolutionRules() } val findingsPerRuleSet = HashMap>() @@ -144,7 +144,7 @@ internal class Analyzer( return result } - private fun warnAboutEnabledRequiresTypeResolutionRules(log: (String) -> Unit) { + private fun warnAboutEnabledRequiresTypeResolutionRules() { providers.asSequence() .map { it to config.subConfig(it.ruleSetId) } .filter { (_, ruleSetConfig) -> ruleSetConfig.isActive() } @@ -153,7 +153,7 @@ internal class Analyzer( .filter { rule -> (rule as? Rule)?.active == true } .filter { rule -> rule::class.hasAnnotation() } .forEach { rule -> - log("The rule '${rule.ruleId}' requires type resolution but it was run without it.") + settings.debug { "The rule '${rule.ruleId}' requires type resolution but it was run without it." } } } } diff --git a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettingsFactory.kt b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettingsFactory.kt index 5a9cf1d80f5..3671c3f406d 100644 --- a/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettingsFactory.kt +++ b/detekt-core/src/test/kotlin/io/gitlab/arturbosch/detekt/core/ProcessingSettingsFactory.kt @@ -27,6 +27,7 @@ fun createProcessingSettings( inputPaths = listOfNotNull(inputPath) } logging { + debug = true this.outputChannel = outputChannel errorChannel = NullPrintStream() }