Skip to content

Commit e6d3f9b

Browse files
authored
Do not generate JavaDocs for empty comments #280 (#866)
* Do not generate JavaDocs for empty comments #280 * Fix broken tests #280 * Review fixes #280
1 parent 23a22b3 commit e6d3f9b

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleClusterCommentBuilder.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ class SimpleClusterCommentBuilder(
3333
skippedIterations()
3434
buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
3535
var sentence = toSentence(root)
36+
3637
if (sentence.isEmpty()) {
37-
return genWarnNotification()
38+
return EMPTY_STRING
3839
}
40+
3941
sentence = splitLongSentence(sentence)
4042
sentence = lastCommaToDot(sentence)
4143

@@ -50,7 +52,7 @@ class SimpleClusterCommentBuilder(
5052
val sentence = toDocStmts(root)
5153

5254
if (sentence.isEmpty()) {
53-
return listOf(DocRegularStmt(genWarnNotification())) //TODO SAT-1310
55+
return emptyList()
5456
}
5557
// sentence = splitLongSentence(sentence) //TODO SAT-1309
5658
// sentence = lastCommaToDot(sentence) //TODO SAT-1309

utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleCommentBuilder.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import soot.jimple.internal.JInvokeStmt
2929
import soot.jimple.internal.JVirtualInvokeExpr
3030

3131
private const val JVM_CRASH_REASON = "JVM crash"
32+
const val EMPTY_STRING = ""
3233

3334
open class SimpleCommentBuilder(
3435
traceTag: TraceTagWithoutExecution,
@@ -46,7 +47,11 @@ open class SimpleCommentBuilder(
4647
skippedIterations()
4748
buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
4849
var sentence = toSentence(root)
49-
if (sentence.isEmpty()) return genWarnNotification()
50+
51+
if (sentence.isEmpty()) {
52+
return EMPTY_STRING
53+
}
54+
5055
sentence = splitLongSentence(sentence)
5156
sentence = lastCommaToDot(sentence)
5257

@@ -72,7 +77,7 @@ open class SimpleCommentBuilder(
7277
val docStmts = toDocStmts(sentenceBlock)
7378

7479
if (docStmts.isEmpty()) {
75-
return listOf(DocRegularStmt(genWarnNotification())) //TODO SAT-1310
80+
return emptyList()
7681
}
7782
// sentence = splitLongSentence(sentence) //TODO SAT-1309
7883
// sentence = lastCommaToDot(sentence) //TODO SAT-1309
@@ -88,8 +93,6 @@ open class SimpleCommentBuilder(
8893
return rootSentenceBlock
8994
}
9095

91-
protected fun genWarnNotification(): String = " " //why is it empty?
92-
9396
/**
9497
* Transforms rootSentenceBlock into String
9598
*/

utbot-summary/src/test/kotlin/org/utbot/summary/comment/SimpleClusterCommentBuilderTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import soot.SootMethod
1515
import soot.jimple.Stmt
1616
import soot.jimple.internal.JReturnStmt
1717

18+
private const val EMPTY_STRING = ""
19+
1820
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
1921
class SimpleClusterCommentBuilderTest {
2022
private lateinit var traceTag: TraceTag
@@ -48,15 +50,13 @@ class SimpleClusterCommentBuilderTest {
4850
fun `builds empty comment if execution result is null`() {
4951
val commentBuilder = SimpleClusterCommentBuilder(traceTag, sootToAst)
5052
val comment = commentBuilder.buildString(sootMethod)
51-
assertEquals(" ", comment)
53+
assertEquals(EMPTY_STRING, comment)
5254
}
5355

5456
@Test
55-
fun `builds empty doc statement if execution result is null`() {
57+
fun `does not build any statements for javadoc if execution result is null`() {
5658
val commentBuilder = SimpleClusterCommentBuilder(traceTag, sootToAst)
5759
val statements = commentBuilder.buildDocStmts(sootMethod)
58-
assertEquals(statements.size, 1)
59-
assertEquals(statements[0].toString(), " ")
60+
assertEquals(statements.size, 0)
6061
}
61-
6262
}

0 commit comments

Comments
 (0)