Skip to content
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

Fixed KdocComments and KdocFormatting #1892

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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 @@ -21,14 +21,14 @@ import com.saveourtool.diktat.ruleset.constants.Warnings.MISSING_KDOC_ON_FUNCTIO
import com.saveourtool.diktat.ruleset.constants.Warnings.MISSING_KDOC_TOP_LEVEL
import com.saveourtool.diktat.ruleset.constants.Warnings.WRONG_INDENTATION
import com.saveourtool.diktat.ruleset.constants.Warnings.WRONG_NEWLINES
import com.saveourtool.diktat.ruleset.constants.Warnings.KDOC_NO_CONSTRUCTOR_PROPERTY
import com.saveourtool.diktat.ruleset.rules.chapter1.FileNaming
import com.saveourtool.diktat.ruleset.rules.chapter2.comments.CommentsRule
import com.saveourtool.diktat.ruleset.rules.chapter2.comments.HeaderCommentRule
import com.saveourtool.diktat.ruleset.rules.chapter2.kdoc.KdocComments
import com.saveourtool.diktat.ruleset.rules.chapter2.kdoc.KdocFormatting
import com.saveourtool.diktat.ruleset.rules.chapter2.kdoc.KdocMethods
import com.saveourtool.diktat.ruleset.rules.chapter3.EmptyBlock
import com.saveourtool.diktat.ruleset.rules.chapter3.files.SemicolonsRule
import com.saveourtool.diktat.ruleset.rules.chapter6.classes.InlineClassesRule
import com.saveourtool.diktat.ruleset.utils.indentation.IndentationConfig
import com.saveourtool.diktat.ruleset.utils.indentation.IndentationConfig.Companion.EXTENDED_INDENT_AFTER_OPERATORS
Expand All @@ -40,6 +40,7 @@ import com.charleskorn.kaml.YamlConfiguration
import generated.WarningNames
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Timeout
Expand Down Expand Up @@ -258,6 +259,24 @@ abstract class DiktatSmokeTestBase {
}
}

@Test
@Tag("DiktatRuleSetProvider")
@Timeout(TEST_TIMEOUT_SECONDS, unit = SECONDS)
@Disabled("https://github.com/saveourtool/diktat/issues/1889")
fun `regression - kdoc for classes`() {
val configFilePath = prepareOverriddenRulesConfig(
rulesToDisable = emptyList(),
rulesToOverride = mapOf(
KDOC_NO_CONSTRUCTOR_PROPERTY.name to mapOf(
"isParamTagsForParameters" to "true",
"isParamTagsForPrivateProperties" to "true",
"isParamTagsForGenericTypes" to "true"
)
)
)
fixAndCompare(configFilePath, "ClassKdocExpected.kt", "ClassKdocTest.kt")
}

@Test
@Tag("DiktatRuleSetProvider")
@Timeout(TEST_TIMEOUT_SECONDS, unit = SECONDS)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,332 @@
package com.saveourtool.diktat

/**
* kdoc
* class
* comment
*
DrAlexD marked this conversation as resolved.
Show resolved Hide resolved
* @param name property info
*/
class A constructor(
name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* single-line comment
*/
class A constructor(
name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* block
* comment
*/
class A constructor(
name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* kdoc property
* comment
*/
class A constructor(
name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
*/
class A constructor(
/**
* @property name property
* comment
*/
name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
*/
class A constructor(
val name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
* single-line comment
*/
class A constructor(
val name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
* block
* comment
*/
class A constructor(
val name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
* kdoc property
* comment
*/
class A constructor(
val name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
*/
class A constructor(
/**
* @property name property
* comment
*/
val name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
*/
class A constructor(
private val name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* single-line comment
*/
class A constructor(
private val name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* block
* comment
*/
class A constructor(
private val name: String
) {}

/**
* kdoc
* class
* comment
*
* @param name property info
* kdoc property
* comment
*/
class A constructor(
private val name: String
) {}

/**
* kdoc
* class
* comment
*
* @property name property info
*/
class A constructor(
/**
* @property name property
* comment
*/
private val name: String
) {}

/**
* kdoc
* class
* comment
*
* @param K
* @property openName open property info
* single-line comment
* @property openLastName open last property
* info
* block
* comment
* @property openAddr property
* info
* @property openBirthDate kdoc property
* comment
*/
open class B<K : Any> constructor(
open val openName: String,
open val openLastName: String,
open val openBirthDate: String,
/**
* @property openAddr property
* comment
*/
open val openAddr: String
) {}

/**
* kdoc
* class
* comment
*
* @param P generic type
* @param K generic type
* @param privateLastName private
* property info
* block
* comment
* @param G
* @param privateName single-line comment
* @param paramName single-line comment
* @param paramLastName block
* comment
* @param privateBirthDate kdoc property
* comment
* @param paramBirthDate kdoc property
* comment
* @property internalName internal
* property info
* single-line comment
* @property openName override
* property info
* single-line comment
* @property openAddr override
* property info
* @property protectedName single-line comment
* @property name single-line comment
* @property protectedLastName block
* comment
* @property internalLastName block
* comment
* @property openLastName block
* comment
* @property lastName block
* comment
* @property protectedBirthDate kdoc property
* comment
* @property internalBirthDate kdoc property
* comment
* @property openBirthDate kdoc property
* comment
* @property birthDate kdoc property
* comment
*/
class A<K : Any, P : Any, G : Any> constructor(
private val privateName: String,
protected val protectedName: String,
internal val internalName: String,
override val openName: String,
val name: String,
paramName: String,
private val privateLastName: String,
protected val protectedLastName: String,
internal val internalLastName: String,
override val openLastName: String,
val lastName: String,
paramLastName: String,
private val privateBirthDate: String,
protected val protectedBirthDate: String,
internal val internalBirthDate: String,
override val openBirthDate: String,
val birthDate: String,
paramBirthDate: String,
/**
* @property privateAddr property
* comment
*/
private val privateAddr: String,
/**
* @property protectedAddr property
* comment
*/
protected val protectedAddr: String,
/**
* @property internalAddr property
* comment
*/
internal val internalAddr: String,
/**
* @property openAddr property
* comment
*/
override val openAddr: String,
/**
* @property addr property
* comment
*/
val addr: String,
/**
* @property paramAddr property
* comment
*/
paramAddr: String,
) : B<K>() {}

/**
* kdoc
* class
* comment
*
* @property keyAs
* @property as
*/
actual annotation class JsonSerialize(
actual val `as`: KClass<*>,
actual val keyAs: KClass<*>,
)
Loading
Loading