From 74af4c1a7d96672a2f5a43543ea7c2c707251e43 Mon Sep 17 00:00:00 2001 From: Pleshkova Daria Date: Tue, 12 Dec 2023 16:35:36 +0300 Subject: [PATCH] worked ### What's done: * worked --- .../ruleset/chapter2/KdocMethodsTest.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/chapter2/KdocMethodsTest.kt b/diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/chapter2/KdocMethodsTest.kt index b922bf3061..38cc753fc2 100644 --- a/diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/chapter2/KdocMethodsTest.kt +++ b/diktat-rules/src/test/kotlin/com/saveourtool/diktat/ruleset/chapter2/KdocMethodsTest.kt @@ -276,17 +276,19 @@ class KdocMethodsTest : LintTestBase(::KdocMethods) { @Tag(WarningNames.KDOC_WITHOUT_THROWS_TAG) fun `shouldn't add @throw if exception is in catch-block`() { lintMethod( - """ - |class Example { - | override fun toString() = "example" - | - | override fun equals(other: Any?) = false - | - | override fun hashCode() = 42 - |} - | - |fun main() {} - """.trimIndent() + """ + |fun parseInputNumber(onSuccess: (number: Int) -> Unit, onFailure: () -> Unit) { + | try { + | val input: Int = binding.inputEditText.text.toString().toInt() + | if (input < 0) + | throw NumberFormatException() + | + | onSuccess(input) + | } catch (e: NumberFormatException) { + | onFailure() + | } + |} + """.trimMargin() ) }