Why does the ThrowsCount
rule ignore override fun
?
#6723
-
Thanks for this invaluable piece of software.
fun f1(x: Int) {
when (x) {
1 -> throw IOException()
2 -> throw IOException()
3 -> throw IOException()
}
} but not this: override fun f3(x: Int) { // does not report overridden function
when (x) {
1 -> throw IOException()
2 -> throw IOException()
3 -> throw IOException()
}
} Looking at the source code of the Still, I wonder: why? A function's body doesn't become more readable just because it's overriding some interface method. @Test
fun `reports violation by default`() {
assertThat(subject.lint(code)).hasSize(1)
} So my expectations are met by the test's name, but not the test's body and the current implementation. Which one needs to change? I'm willing to provide a PR once I know what is to be expected here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
That's odd. Could you review the git history to see if that was added from the beginning of the rule or if it was added based on an issue request? To me this seems like an issue. I can't imagine any reason to treat the override functions in a different way on this rule. If there is not issue we could removed. If there is, please link it and we can decide what to do. (probably add a configuration but let's first check it before take any decision) |
Beta Was this translation helpful? Give feedback.
@stellingsimon then, if you want to go for it just remove the if and fix the tests to reflect this. And thanks for the issue and the research :)