Skip to content

Minor refactoring in SimpleCommentBuildr and CustomJavaDocCommentBuilder #788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 29, 2022

Conversation

onewhl
Copy link
Member

@onewhl onewhl commented Aug 24, 2022

Description

There are expressions that are always null in SimpleCommentBuilder#buildThrownExceptionInfo() line 49 and CustomJavaDocCommentBuilder#buildCustomJavaDocComment() line 62.
This PR contains minor refactoring of these methods.

Fixes #787

Type of Change

Please delete options that are not relevant.

  • Minor bug fix (non-breaking small changes)

How Has This Been Tested?

Run tests in summaries-test.

Automated Testing

Run tests in summaries-test.

Checklist (remove irrelevant options):

  • The change followed the style guidelines of the UTBot project
  • Self-review of the code is passed
  • The change contains enough commentaries, particularly in hard-to-understand areas
  • New documentation is provided or existed one is altered
  • No new warnings
  • New tests have been added
  • All tests pass locally with my changes

@onewhl onewhl requested a review from Damtev August 24, 2022 15:14
Comment on lines 48 to 56
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
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess, it could be a little simplified:

if (thrownException != null) {
    val exceptionName = thrownException.javaClass.name
    val reason = findExceptionReason(currentMethod, thrownException)

    customJavaDocComment.throwsException = "{@link $exceptionName} $reason"
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, thanks!

@onewhl onewhl requested a review from Damtev August 26, 2022 12:04
@onewhl onewhl merged commit 32d7a7e into main Aug 29, 2022
@onewhl onewhl deleted the onewhl/787_refactoring_builders branch August 29, 2022 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Refactor SimpleCommentBuilder and CustomJavaDocCommentBuilder
2 participants