https://kotlinlang.org logo
#detekt
Title
# detekt
w

Will Hawkins

02/03/2020, 9:40 PM
Is there a reasonable way to emit a warning from a custom detekt rule?
g

gammax

02/03/2020, 10:21 PM
short answer: no
w

Will Hawkins

02/03/2020, 10:22 PM
okay! No problem
I just added a superclass to my custom rules that has such a
checkConfig
method that I call
it would be neat to add such a function to the
Rule
class. Would you accept such a PR?
g

gammax

02/03/2020, 10:23 PM
long answer: So you can technically report an issue, and specify
Severity.Warning
in the severity.
w

Will Hawkins

02/03/2020, 10:24 PM
That seems like a good way to implement a log message in the config, thanks!
g

gammax

02/03/2020, 10:27 PM
Just to clarify my initial
no
: This
Severity.Warning
that you can specify in the custom rule, is not playing any role in the detekt inspection result other than any other rule.
w

Will Hawkins

02/03/2020, 10:27 PM
right
completely understood
g

gammax

02/03/2020, 10:27 PM
In other words: a
Severity.Warning
will let your build fail as much as any other rule will do. Is more like a "label" that you can have to inform the user.
w

Will Hawkins

02/03/2020, 10:28 PM
yeah, I don't want to fail the build. I just want to alert the user that their configuration might not be exactly what they wanted
g

gammax

02/03/2020, 10:29 PM
👆 that's exactly the opposite of what I said 😅
w

Will Hawkins

02/03/2020, 10:30 PM
okay, then perhaps I am misunderstanding
would you be open to a PR for somethign like a
checkConfig
method?
g

gammax

02/03/2020, 10:36 PM
I'm not sure I follow you, but there is already configuration validation implemented in Detekt
w

Will Hawkins

02/03/2020, 10:36 PM
sorry, I have to go afk for a minute, but I will explain when I return, if that's okay?
👍 1
6 Views