From ac358c8f94f09640c96d7c6dddbddcc175a65e85 Mon Sep 17 00:00:00 2001 From: Zarina Kurbatova Date: Wed, 24 Aug 2022 18:05:37 +0300 Subject: [PATCH 1/2] Minor refactoring in SimpleCommentBuildr and CustomJavaDocCommentBuilder --- .../utbot/summary/comment/CustomJavaDocCommentBuilder.kt | 8 +++----- .../org/utbot/summary/comment/SimpleCommentBuilder.kt | 9 +++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt index 81e351485f..206bddfec3 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt @@ -45,16 +45,14 @@ class CustomJavaDocCommentBuilder( // builds Throws exception section val thrownException = traceTag.result.exceptionOrNull() - val exceptionThrow: String? = if (thrownException == null) { - traceTag.result.exceptionOrNull()?.let { it::class.qualifiedName } - } else { + val thrownExceptionDescription: String? = thrownException?.let { val exceptionName = thrownException.javaClass.name val reason = findExceptionReason(currentMethod, thrownException) "{@link $exceptionName} $reason" } - if (exceptionThrow != null) { - customJavaDocComment.throwsException = exceptionThrow + if (thrownExceptionDescription != null) { + customJavaDocComment.throwsException = thrownExceptionDescription } // builds Iterates section diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt index 3a57924058..2c6533fc6a 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt @@ -57,12 +57,9 @@ open class SimpleCommentBuilder( root: SimpleSentenceBlock, currentMethod: SootMethod ) { - val thrownException = traceTag.result.exceptionOrNull() - if (thrownException == null) { - root.exceptionThrow = traceTag.result.exceptionOrNull()?.let { it::class.qualifiedName } - } else { - val exceptionName = thrownException.javaClass.simpleName - val reason = findExceptionReason(currentMethod, thrownException) + traceTag.result.exceptionOrNull()?.let { + val exceptionName = it.javaClass.simpleName + val reason = findExceptionReason(currentMethod, it) root.exceptionThrow = "$exceptionName $reason" } } From 8a22643285d92ec197c25124c59142d3f095ad7d Mon Sep 17 00:00:00 2001 From: Zarina Kurbatova Date: Fri, 26 Aug 2022 15:03:57 +0300 Subject: [PATCH 2/2] Minor review fix --- .../utbot/summary/comment/CustomJavaDocCommentBuilder.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt index 206bddfec3..74296b5f87 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt @@ -45,14 +45,11 @@ class CustomJavaDocCommentBuilder( // builds Throws exception section val thrownException = traceTag.result.exceptionOrNull() - val thrownExceptionDescription: String? = thrownException?.let { + if (thrownException != null) { val exceptionName = thrownException.javaClass.name val reason = findExceptionReason(currentMethod, thrownException) - "{@link $exceptionName} $reason" - } - if (thrownExceptionDescription != null) { - customJavaDocComment.throwsException = thrownExceptionDescription + customJavaDocComment.throwsException = "{@link $exceptionName} $reason" } // builds Iterates section