diff --git a/diktat-gradle-plugin/build.gradle.kts b/diktat-gradle-plugin/build.gradle.kts index 7ddd98bd68..5884c5c153 100644 --- a/diktat-gradle-plugin/build.gradle.kts +++ b/diktat-gradle-plugin/build.gradle.kts @@ -15,6 +15,7 @@ repositories { jcenter() } +// default value is needed for correct gradle loading in IDEA; actual value from maven is used during build val ktlintVersion = project.properties.getOrDefault("ktlintVersion", "0.39.0") as String val diktatVersion = project.version.takeIf { it.toString() != Project.DEFAULT_VERSION } ?: "0.1.5" val junitVersion = project.properties.getOrDefault("junitVersion", "5.7.0") as String diff --git a/info/guide/guide-chapter-2.md b/info/guide/guide-chapter-2.md index 6f5592d67b..9949be1ea7 100644 --- a/info/guide/guide-chapter-2.md +++ b/info/guide/guide-chapter-2.md @@ -32,10 +32,39 @@ Use a single-line form when you store the entire KDoc block in one line (and the ### Rule 2.1.1: KDoc is used for each public, protected or internal code element -At a minimum, KDoc should be used for every public, protected, or internal decorated class, interface, enumeration, method, and member field (property). Other code blocks can also have KDocs if needed. -Instead of using comments before properties in class - use `@property` tag in a KDoc of a class. +At a minimum, KDoc should be used for every public, protected, or internal decorated class, interface, enumeration, method, and member field (property). +Other code blocks can also have KDocs if needed. +Instead of using comments or KDocs before properties in the primary constructor of a class - use `@property` tag in a KDoc of a class. All properties of the primary constructor should be also documented in a KDoc with a `@property` tag. +Incorrect example: +```kotlin +/** + * Class description + */ +class Example( + /** + * property description + */ + val foo: Foo, + // another property description + val bar: Bar +) +``` + +Correct example: +```kotlin +/** + * Class description + * @property foo property description + * @property bar another property description + */ +class Example( + val foo: Foo, + val bar: Bar +) +``` + **Exceptions:** 1. For setters/getters of properties, obvious comments (like `this getter returns field`) are optional. Note, that Kotlin generates simple `get/set` methods under the hood. @@ -125,7 +154,7 @@ This comment should contain @since tag. The right style is to write the applicat */ ``` -Other KDoc tags (such as @param type parameters and @see.) can be added as follow: +Other KDoc tags (such as @param type parameters and @see.) can be added as follows: ```kotlin /** * Description of functionality