detekt / detekt-intellij-plugin

detekt plugin for IntelliJ
https://plugins.jetbrains.com/plugin/10761-detekt
Apache License 2.0
290 stars 39 forks source link

inconsistent error reporting by plugin and detekt #504

Closed os97673 closed 6 months ago

os97673 commented 6 months ago

I have

potential-bugs:
  active: true
  severity: error
  ImplicitDefaultLocale:
    active: true

in my detekt.yml and when I run detekt it reports problem in the code as error image but in the editor (Android Studio Hedgehog | 2023.1.1 Patch 1) the problem is shown as a warning :-(

Screenshot 2024-01-04 at 7 44 15 AM

The detekt plugin (2.3.0) is configured to use the config, but it looks like it overrides severity with "treat detekt findings as errors" (which is not checked by my because I don't want ALL findings from the config to be reported as error) Is this expected behavior or is this a bug?

os97673 commented 6 months ago

I think the "problem" is in the way "treat as error" handled (https://github.com/detekt/detekt-intellij-plugin/blob/e808894ee69bc746446b353fb138a84caf6b9281/src/main/kotlin/io/gitlab/arturbosch/detekt/idea/DetektAnnotator.kt#L60C32-L60C54) I think instead of

val severity = if (settings.treatAsErrors) HighlightSeverity.ERROR else HighlightSeverity.WARNING

it should be something like

val severity = if (settings.treatAsErrors) HighlightSeverity.ERROR else convertSeverity(finding.severity)

Or, at least, do this for the case when user specified a custom detekt config. Of course if it is ok to make such "backward incompatible" change.

Would you be open for such PR?

schalkms commented 6 months ago

Closed with 0df1e1a