Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/extension-function-kdoc(#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
aktsay6 authored Nov 11, 2020
2 parents 47e279d + 48eec27 commit 96261ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,13 @@ class KdocComments(private val configRules: List<RulesConfig>) : Rule("kdoc-comm
val modifier = node.getFirstChildWithType(MODIFIER_LIST)
val name = node.getIdentifierName()

if (modifier.isAccessibleOutside() && kdoc == null) {
if (modifier.isAccessibleOutside() && kdoc == null && !isTopLevelFunctionStandard(node)) {
warning.warn(configRules, emitWarn, isFixMode, name!!.text, node.startOffset, node)
}
}

private fun isTopLevelFunctionStandard(node: ASTNode) : Boolean = node.elementType == FUN && node.isStandardMethod()

companion object {
private val statementsToDocument = TokenSet.create(CLASS, FUN, PROPERTY)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class KdocWarnTest : LintTestBase(::KdocComments) {
internal fun someGoodNameNew(): String {
return " ";
}
fun main() {}
""".trimIndent()
lintMethod(code,
LintError(1, 1, ruleId, "${MISSING_KDOC_TOP_LEVEL.warnText()} someGoodName"),
Expand Down Expand Up @@ -116,6 +118,8 @@ class KdocWarnTest : LintTestBase(::KdocComments) {
private class InternalClass {
}
public fun main() {}
}
""".trimIndent()
lintMethod(code,
Expand Down

0 comments on commit 96261ee

Please sign in to comment.