saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
521 stars 39 forks source link

Diktat should recognize Detekt-specific suppressions #1627

Open 0x6675636b796f75676974687562 opened 1 year ago

0x6675636b796f75676974687562 commented 1 year ago

There's a lot of similarity between Diktat and Detekt checks, but the literals they're @Suppress'ed with are different, e.g.:

Diktat Detekt
MAGIC_NUMBER MagicNumber
TOO_MANY_PARAMETERS LongParameterList
TOO_LONG_FUNCTION LongMethod
LONG_LINE MaxLineLength

When both syntax checkers are enabled in the same project, this leads to extra verbose lists of @Suppress arguments, e.g.:

@Suppress("MAGIC_NUMBER", "MagicNumber")
fun f() {
    g(42)
}

Diktat should be Detekt-compatible and understand Detekt-specific check names.

Environment information

Related

@petertrr, @nulls, feel free to comment.

kgevorkyan commented 1 year ago

Maybe not get attached specifically to detekt, but support some common configuration/interface for all rules, which will currently contain at least one field aliases, as suggested for literals in https://github.com/saveourtool/diktat/issues/1628?

Thus, we can add aliases not only for detekt but for some other tools?

Also, we could add some short names for long suppressions via such configuration

@Suppress("SOME_UGLY_AND_LONG_WARNING")
fun foo() {
}
@Suppress("SHORT_NAME")
fun foo() {
}

where SHORT_NAME could be the short alias for SOME_UGLY_AND_LONG_WARNING?

0x6675636b796f75676974687562 commented 1 year ago

@kgevorkyan, #1628 is not literal-specific, so if we proceed and implement it, each check will support aliases.

This particular task (#1627) is about the pre-defined list of aliases some checks may have.

kgevorkyan commented 1 year ago

Oh, now I got it, good