diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectExpected.kt new file mode 100644 index 0000000000..8eefefb794 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectExpected.kt @@ -0,0 +1,6 @@ +package /* AAAAAA */ com.saveourtool.diktat.some.name + +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectTest.kt new file mode 100644 index 0000000000..0e4d401671 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixIncorrectTest.kt @@ -0,0 +1,6 @@ +package /* AAAAAA */ some.buggy.way.to + +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingExpected.kt new file mode 100644 index 0000000000..ba70c6523e --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingExpected.kt @@ -0,0 +1,5 @@ +package com.saveourtool.diktat.some.name +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingTest.kt new file mode 100644 index 0000000000..fffbda7359 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingTest.kt @@ -0,0 +1,4 @@ +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected.kt new file mode 100644 index 0000000000..6c3ee751eb --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected.kt @@ -0,0 +1,7 @@ +@file:Suppress("CONSTANT_UPPERCASE") + +package com.saveourtool.diktat.some.name +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected2.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected2.kt new file mode 100644 index 0000000000..875f6040e8 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected2.kt @@ -0,0 +1,6 @@ +@file:Suppress("CONSTANT_UPPERCASE") // comment +package com.saveourtool.diktat.some.name +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected3.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected3.kt new file mode 100644 index 0000000000..448e3044a6 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationExpected3.kt @@ -0,0 +1,9 @@ +/** + * comment + */ +@file:Suppress("CONSTANT_UPPERCASE") +package com.saveourtool.diktat.some.name +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest.kt new file mode 100644 index 0000000000..b64872cacd --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest.kt @@ -0,0 +1,6 @@ +@file:Suppress("CONSTANT_UPPERCASE") + +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest2.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest2.kt new file mode 100644 index 0000000000..49bd3e6bf1 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest2.kt @@ -0,0 +1,5 @@ +@file:Suppress("CONSTANT_UPPERCASE") // comment +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest3.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest3.kt new file mode 100644 index 0000000000..974f379212 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithAnnotationTest3.kt @@ -0,0 +1,8 @@ +/** + * comment + */ +@file:Suppress("CONSTANT_UPPERCASE") +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportExpected.kt new file mode 100644 index 0000000000..b53a1a4c87 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportExpected.kt @@ -0,0 +1,7 @@ +@file:Suppress("CONSTANT_UPPERCASE") +package com.saveourtool.diktat.some.name + +val a = 5 + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportTest.kt new file mode 100644 index 0000000000..34f61483b9 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixMissingWithoutImportTest.kt @@ -0,0 +1,5 @@ +@file:Suppress("CONSTANT_UPPERCASE") +val a = 5 + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionExpected.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionExpected.kt new file mode 100644 index 0000000000..d85660ae8b --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionExpected.kt @@ -0,0 +1,6 @@ +package com.saveourtool.diktat.some.name + +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionTest.kt b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionTest.kt new file mode 100644 index 0000000000..3cb94c79cf --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph1/naming/package/src/main/kotlin/com/saveourtool/diktat/some/name/FixPackageRegressionTest.kt @@ -0,0 +1,6 @@ +package app + +import com.saveourtool.diktat.ktlint.core.Rule + +class TestPackageName { +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocExpected.kt new file mode 100644 index 0000000000..992e87a4a7 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocExpected.kt @@ -0,0 +1,7 @@ +package com.saveourtool.diktat.kdoc.methods + +val foo = 42 + +fun doNothing() { + return +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocTested.kt new file mode 100644 index 0000000000..992e87a4a7 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/EmptyKdocTested.kt @@ -0,0 +1,7 @@ +package com.saveourtool.diktat.kdoc.methods + +val foo = 42 + +fun doNothing() { + return +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullExpected.kt new file mode 100644 index 0000000000..7d058d2734 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullExpected.kt @@ -0,0 +1,36 @@ +package com.saveourtool.diktat.kdoc.methods + +class KdocMethodsFull { + fun test1() { + // this function does nothing + } + + /** + * This function is described + * partially. + * @param a + * @return + */ + fun test2(a: Int): Int { + return 2 * a + } + + companion object { + /** + * @param a + * @throws IllegalStateException + */ +fun test3(a: Int) { + throw IllegalStateException("Lorem ipsum") + } + } + + private class Nested { + /** + * @param a + * @param b + * @return + */ +fun test4(a: Int, b: Int): Int = 42 + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullTested.kt new file mode 100644 index 0000000000..aeae6553e9 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/KdocMethodsFullTested.kt @@ -0,0 +1,25 @@ +package com.saveourtool.diktat.kdoc.methods + +class KdocMethodsFull { + fun test1() { + // this function does nothing + } + + /** + * This function is described + * partially. + */ + fun test2(a: Int): Int { + return 2 * a + } + + companion object { + fun test3(a: Int) { + throw IllegalStateException("Lorem ipsum") + } + } + + private class Nested { + fun test4(a: Int, b: Int): Int = 42 + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocExpected.kt new file mode 100644 index 0000000000..814c307395 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocExpected.kt @@ -0,0 +1,14 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * @param a + * @param b + * @return + * @throws IllegalStateException + */ +fun addInts(a: Int, b: Int): Int { + if (false) throw IllegalStateException() + return a + b + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionExpected.kt new file mode 100644 index 0000000000..d695009561 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionExpected.kt @@ -0,0 +1,16 @@ +package test.paragraph2.kdoc + +class Example { + /** + * @return + */ +fun hasNoChildren() = children.size == 0 + + /** + * @return + */ +fun getFirstChild() = children.elementAtOrNull(0) + + @GetMapping("/projects") + fun getProjects() = projectService.getProjects() +} \ No newline at end of file diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionTest.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionTest.kt new file mode 100644 index 0000000000..a603211e4c --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocOnFunctionTest.kt @@ -0,0 +1,10 @@ +package test.paragraph2.kdoc + +class Example { + fun hasNoChildren() = children.size == 0 + + fun getFirstChild() = children.elementAtOrNull(0) + + @GetMapping("/projects") + fun getProjects() = projectService.getProjects() +} \ No newline at end of file diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocTested.kt new file mode 100644 index 0000000000..b4c1427c59 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocTested.kt @@ -0,0 +1,8 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + fun addInts(a: Int, b: Int): Int { + if (false) throw IllegalStateException() + return a + b + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersExpected.kt new file mode 100644 index 0000000000..3ef6b234b2 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersExpected.kt @@ -0,0 +1,15 @@ +package test.paragraph2.kdoc + +class Example { + /** + * @param a + * @param b + * @return + * @throws IllegalStateException + */ +@Deprecated("Use something else") + internal fun addInts(a: Int, b: Int): Int { + if (false) throw IllegalStateException() + return a + b + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersTest.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersTest.kt new file mode 100644 index 0000000000..763f62f864 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/MissingKdocWithModifiersTest.kt @@ -0,0 +1,9 @@ +package test.paragraph2.kdoc + +class Example { + @Deprecated("Use something else") + internal fun addInts(a: Int, b: Int): Int { + if (false) throw IllegalStateException() + return a + b + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionExpected.kt new file mode 100644 index 0000000000..1cc510f128 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionExpected.kt @@ -0,0 +1,48 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + * @param a + */ + fun test1(a: Int): Unit { } + + /** + * Lorem ipsum + * @param a + * @return integer value + */ + fun test2(a: Int): Int = 0 + + /** + * Lorem ipsum + * @param a + * @throws IllegalStateException + */ + fun test3(a: Int) { + throw IllegalStateException("dolor sit amet") + } + + /** + * Lorem ipsum + * @param a + * @return integer value + * @throws IllegalStateException + */ + fun test4(a: Int): Int { + throw IllegalStateException("dolor sit amet") + return 0 + } + + /** + * Lorem ipsum + * @param a + * @param b + * @return integer value + * @throws IllegalStateException + */ + fun test5(a: Int, b: String): Int { + throw IllegalStateException("dolor sit amet") + return 0 + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionTested.kt new file mode 100644 index 0000000000..8df496808b --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ParamTagInsertionTested.kt @@ -0,0 +1,42 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + */ + fun test1(a: Int): Unit { } + + /** + * Lorem ipsum + * @return integer value + */ + fun test2(a: Int): Int = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException + */ + fun test3(a: Int) { + throw IllegalStateException("dolor sit amet") + } + + /** + * Lorem ipsum + * @return integer value + * @throws IllegalStateException + */ + fun test4(a: Int): Int { + throw IllegalStateException("dolor sit amet") + return 0 + } + + /** + * Lorem ipsum + * @return integer value + * @throws IllegalStateException + */ + fun test5(a: Int, b: String): Int { + throw IllegalStateException("dolor sit amet") + return 0 + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionExpected.kt new file mode 100644 index 0000000000..04bddbebd8 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionExpected.kt @@ -0,0 +1,43 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + * @return + */ + fun test1(): Int = 0 + + /** + * Lorem ipsum + * @param a integer parameter + * @return + */ + fun test2(a: Int): Int = 0 + + /** + * Lorem ipsum + * @return + * @throws IllegalStateException never + */ + fun test3(): Int = 0 + + /** + * Lorem ipsum + * @param a integer parameter + * @return + * @throws IllegalStateException never + */ + fun test4(a: Int): Int = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException never + */ + fun test5() = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException never + */ + fun A.test6() = 0 +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionTested.kt new file mode 100644 index 0000000000..5182bf5734 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ReturnTagInsertionTested.kt @@ -0,0 +1,39 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + */ + fun test1(): Int = 0 + + /** + * Lorem ipsum + * @param a integer parameter + */ + fun test2(a: Int): Int = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException never + */ + fun test3(): Int = 0 + + /** + * Lorem ipsum + * @param a integer parameter + * @throws IllegalStateException never + */ + fun test4(a: Int): Int = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException never + */ + fun test5() = 0 + + /** + * Lorem ipsum + * @throws IllegalStateException never + */ + fun A.test6() = 0 +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionExpected.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionExpected.kt new file mode 100644 index 0000000000..876bb9a4b0 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionExpected.kt @@ -0,0 +1,67 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + * @throws IllegalStateException + */ + fun test1(): Unit { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @param a integer parameter + * @throws IllegalStateException + */ + fun test2(a: Int): Unit { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @param a integer parameter + * @return integer value + * @throws IllegalStateException + */ + fun test3(a: Int): Int { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @return integer value + * @throws IllegalStateException + */ + fun test4(): Int { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @throws IllegalStateException + * @throws IllegalAccessException + */ + fun test5() { + if (true) throw IllegalStateException("Lorem ipsum") + else throw IllegalAccessException("Dolor sit amet") + } + + /** + * @throws RuntimeException + */ +fun test6() { + try { + foo() + } catch (_: NullPointerException) { + println("NPE!") + } catch (e: RuntimeException) { + println("Whoops...") + throw e + } catch (e: Error) { + val x = IllegalStateException() + println("Nothing to do here") + throw x + } + } +} diff --git a/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionTested.kt b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionTested.kt new file mode 100644 index 0000000000..e72e41d9e0 --- /dev/null +++ b/diktat-rules/src/test/resources/test/paragraph2/kdoc/package/src/main/kotlin/com/saveourtool/diktat/kdoc/methods/ThrowsTagInsertionTested.kt @@ -0,0 +1,58 @@ +package com.saveourtool.diktat.kdoc.methods + +class Example { + /** + * Lorem ipsum + */ + fun test1(): Unit { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @param a integer parameter + */ + fun test2(a: Int): Unit { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @param a integer parameter + * @return integer value + */ + fun test3(a: Int): Int { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + * @return integer value + */ + fun test4(): Int { + throw IllegalStateException("Lorem ipsum") + } + + /** + * Lorem ipsum + */ + fun test5() { + if (true) throw IllegalStateException("Lorem ipsum") + else throw IllegalAccessException("Dolor sit amet") + } + + fun test6() { + try { + foo() + } catch (_: NullPointerException) { + println("NPE!") + } catch (e: RuntimeException) { + println("Whoops...") + throw e + } catch (e: Error) { + val x = IllegalStateException() + println("Nothing to do here") + throw x + } + } +} diff --git a/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptExpected.kt b/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptExpected.kt new file mode 100644 index 0000000000..44665ed894 --- /dev/null +++ b/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptExpected.kt @@ -0,0 +1,7 @@ +package com.saveourtool.diktat.scripts + +import kotlinx.browser.document + +fun main() { + (document.getElementById("myId") as HTMLElement).click() +} diff --git a/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptTest.kt b/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptTest.kt new file mode 100644 index 0000000000..e7b71e2ee5 --- /dev/null +++ b/diktat-ruleset/src/test/resources/test/smoke/src/jsMain/kotlin/com/saveourtool/diktat/scripts/ScriptTest.kt @@ -0,0 +1,7 @@ +package com.saveourtool.diktat.js + +import kotlinx.browser.document + +fun main() { + (document.getElementById("myId") as HTMLElement).click() +} \ No newline at end of file