Skip to content

Do not generate JavaDocs for empty comments #280 #866

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 3 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class SimpleClusterCommentBuilder(
skippedIterations()
buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
var sentence = toSentence(root)

if (sentence.isEmpty()) {
return genWarnNotification()
return EMPTY_STRING
}

sentence = splitLongSentence(sentence)
sentence = lastCommaToDot(sentence)

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

if (sentence.isEmpty()) {
return listOf(DocRegularStmt(genWarnNotification())) //TODO SAT-1310
return emptyList()
}
// sentence = splitLongSentence(sentence) //TODO SAT-1309
// sentence = lastCommaToDot(sentence) //TODO SAT-1309
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import soot.jimple.internal.JInvokeStmt
import soot.jimple.internal.JVirtualInvokeExpr

private const val JVM_CRASH_REASON = "JVM crash"
const val EMPTY_STRING = ""

open class SimpleCommentBuilder(
traceTag: TraceTagWithoutExecution,
Expand All @@ -46,7 +47,11 @@ open class SimpleCommentBuilder(
skippedIterations()
buildSentenceBlock(traceTag.rootStatementTag, root, currentMethod)
var sentence = toSentence(root)
if (sentence.isEmpty()) return genWarnNotification()

if (sentence.isEmpty()) {
return EMPTY_STRING
}

sentence = splitLongSentence(sentence)
sentence = lastCommaToDot(sentence)

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

if (docStmts.isEmpty()) {
return listOf(DocRegularStmt(genWarnNotification())) //TODO SAT-1310
return emptyList()
}
// sentence = splitLongSentence(sentence) //TODO SAT-1309
// sentence = lastCommaToDot(sentence) //TODO SAT-1309
Expand All @@ -88,8 +93,6 @@ open class SimpleCommentBuilder(
return rootSentenceBlock
}

protected fun genWarnNotification(): String = " " //why is it empty?

/**
* Transforms rootSentenceBlock into String
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import soot.SootMethod
import soot.jimple.Stmt
import soot.jimple.internal.JReturnStmt

private const val EMPTY_STRING = ""

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class SimpleClusterCommentBuilderTest {
private lateinit var traceTag: TraceTag
Expand Down Expand Up @@ -48,15 +50,13 @@ class SimpleClusterCommentBuilderTest {
fun `builds empty comment if execution result is null`() {
val commentBuilder = SimpleClusterCommentBuilder(traceTag, sootToAst)
val comment = commentBuilder.buildString(sootMethod)
assertEquals(" ", comment)
assertEquals(EMPTY_STRING, comment)
}

@Test
fun `builds empty doc statement if execution result is null`() {
fun `does not build any statements for javadoc if execution result is null`() {
val commentBuilder = SimpleClusterCommentBuilder(traceTag, sootToAst)
val statements = commentBuilder.buildDocStmts(sootMethod)
assertEquals(statements.size, 1)
assertEquals(statements[0].toString(), " ")
assertEquals(statements.size, 0)
}

}