saveourtool / diktat

Strict coding standard for Kotlin and a custom set of rules for detecting code smells, code style issues and bugs
https://diktat.saveourtool.com
MIT License
524 stars 39 forks source link

Empty lines in class constructor before properties with comments #1889

Open DrAlexD opened 9 months ago

DrAlexD commented 9 months ago

Describe the bug

It looks like BLANK_LINE_BETWEEN_PROPERTIES rule also applies to class constructor. And it happens only for KDoc comments.

Expected behavior

/**
 * @property name single-line comment
 * @property birthDate
 *   kdoc property
 *   comment
 */
class B<K : Any> constructor(
    val name: String,
    /*
     * block
     * comment
     */
    private val lastName: String,
    val birthDate: String,
    /**
     * @property addr property
     * comment
     */
    val addr: String
) {}

Observed behavior

/**
 * @property name single-line comment
 * @property birthDate
 *   kdoc property
 *   comment
 */
class B<K : Any> constructor(
    val name: String,
    /*
     * block
     * comment
     */
    private val lastName: String,

    val birthDate: String,

    /**
     * @property addr property
     * comment
     */
    val addr: String
) {}

Steps to Reproduce

class B<K : Any> constructor(
    // single-line comment
    val name: String,
    /*
     * block
     * comment
     */
    private val lastName: String,
    /**
     * kdoc property
     * comment
     */
    val birthDate: String,
    /**
     * @property addr property
     * comment
     */
    val addr: String
) {}