From b8062d8085cfbcee954bcd3322c4aeecdd11b278 Mon Sep 17 00:00:00 2001 From: Alexander Drugakov Date: Tue, 19 Dec 2023 13:30:02 +0300 Subject: [PATCH] Updated examples for Diktat 2.0 (#1877) ### What's done: - updated examples. It's part of #1793 --- examples/gradle-groovy-dsl/build.gradle | 2 +- .../src/main/kotlin/AnotherTest.kt | 15 +++++++++++++++ .../gradle-groovy-dsl/src/main/kotlin/Test.kt | 12 ++++++------ .../backend/build.gradle.kts | 1 - .../backend/src/main/kotlin/Test.kt | 14 +++++++------- .../build.gradle.kts | 5 +++-- .../frontend/build.gradle.kts | 3 +++ .../frontend/src/main/kotlin/AnotherTest.kt | 15 +++++++++++++++ .../settings.gradle.kts | 1 + examples/gradle-kotlin-dsl/build.gradle.kts | 2 +- examples/gradle-kotlin-dsl/settings.gradle.kts | 0 examples/maven-multiproject/backend/pom.xml | 12 ++++++++++++ .../src/main/kotlin/{Main.kt => Test.kt} | 0 examples/maven-multiproject/frontend/pom.xml | 12 ++++++++++++ .../frontend/src/main/kotlin/AnotherMain.kt | 13 ------------- .../frontend/src/main/kotlin/AnotherTest.kt | 15 +++++++++++++++ examples/maven-multiproject/pom.xml | 17 ++++++++++------- examples/maven/pom.xml | 4 ++-- examples/maven/src/main/kotlin/AnotherTest.kt | 15 +++++++++++++++ examples/maven/src/main/kotlin/Test.kt | 12 ++++++------ 20 files changed, 124 insertions(+), 46 deletions(-) create mode 100644 examples/gradle-groovy-dsl/src/main/kotlin/AnotherTest.kt create mode 100644 examples/gradle-kotlin-dsl-multiproject/frontend/build.gradle.kts create mode 100644 examples/gradle-kotlin-dsl-multiproject/frontend/src/main/kotlin/AnotherTest.kt create mode 100644 examples/gradle-kotlin-dsl/settings.gradle.kts create mode 100644 examples/maven-multiproject/backend/pom.xml rename examples/maven-multiproject/backend/src/main/kotlin/{Main.kt => Test.kt} (100%) create mode 100644 examples/maven-multiproject/frontend/pom.xml delete mode 100644 examples/maven-multiproject/frontend/src/main/kotlin/AnotherMain.kt create mode 100644 examples/maven-multiproject/frontend/src/main/kotlin/AnotherTest.kt create mode 100644 examples/maven/src/main/kotlin/AnotherTest.kt diff --git a/examples/gradle-groovy-dsl/build.gradle b/examples/gradle-groovy-dsl/build.gradle index bd9acd3387..8d0d6bea01 100644 --- a/examples/gradle-groovy-dsl/build.gradle +++ b/examples/gradle-groovy-dsl/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.saveourtool.diktat.diktat-gradle-plugin" version "1.2.5" + id "com.saveourtool.diktat" version "2.0.0" } repositories { diff --git a/examples/gradle-groovy-dsl/src/main/kotlin/AnotherTest.kt b/examples/gradle-groovy-dsl/src/main/kotlin/AnotherTest.kt new file mode 100644 index 0000000000..f694d51893 --- /dev/null +++ b/examples/gradle-groovy-dsl/src/main/kotlin/AnotherTest.kt @@ -0,0 +1,15 @@ +package whate.ver + +fun String.createPluginConfig() { + val pluginConfig = TomlDecoder.decode( + serializer(), + fakeFileNode, + DecoderConf() + ) + pluginConfig.configLocation = this.toPath() + pluginConfig.prop1 = property1 + // comment1 + pluginConfig.configLocation2 = this.toPath() + // comment2 + pluginConfig.prop2 = property2 +} diff --git a/examples/gradle-groovy-dsl/src/main/kotlin/Test.kt b/examples/gradle-groovy-dsl/src/main/kotlin/Test.kt index 22c0f205f5..a6908961a8 100644 --- a/examples/gradle-groovy-dsl/src/main/kotlin/Test.kt +++ b/examples/gradle-groovy-dsl/src/main/kotlin/Test.kt @@ -2,12 +2,12 @@ package incorrect class incorrectname: Exception() { fun INCORRECT_FUNCTION() { - throw Exception() - } - - // fun myCommentedFunction() { - // } + throw Exception() + } -val Incorrect_Val = 5 + // fun myCommentedFunction() { + // } + + val Incorrect_Val = 5 } diff --git a/examples/gradle-kotlin-dsl-multiproject/backend/build.gradle.kts b/examples/gradle-kotlin-dsl-multiproject/backend/build.gradle.kts index 8990dfba43..444baaa3c8 100644 --- a/examples/gradle-kotlin-dsl-multiproject/backend/build.gradle.kts +++ b/examples/gradle-kotlin-dsl-multiproject/backend/build.gradle.kts @@ -1,4 +1,3 @@ plugins { kotlin("jvm") - id("com.saveourtool.diktat.diktat-gradle-plugin") } diff --git a/examples/gradle-kotlin-dsl-multiproject/backend/src/main/kotlin/Test.kt b/examples/gradle-kotlin-dsl-multiproject/backend/src/main/kotlin/Test.kt index 80975f0974..a6908961a8 100644 --- a/examples/gradle-kotlin-dsl-multiproject/backend/src/main/kotlin/Test.kt +++ b/examples/gradle-kotlin-dsl-multiproject/backend/src/main/kotlin/Test.kt @@ -1,13 +1,13 @@ package incorrect -class incorrectname: Exception { - fun INCORRECT_FUNCTION() { - throw Exception() - } +class incorrectname: Exception() { + fun INCORRECT_FUNCTION() { + throw Exception() + } - // fun myCommentedFunction() { - // } + // fun myCommentedFunction() { + // } - val Incorrect_Val = 5 + val Incorrect_Val = 5 } diff --git a/examples/gradle-kotlin-dsl-multiproject/build.gradle.kts b/examples/gradle-kotlin-dsl-multiproject/build.gradle.kts index 48df7edf2f..99a0dc0a0b 100644 --- a/examples/gradle-kotlin-dsl-multiproject/build.gradle.kts +++ b/examples/gradle-kotlin-dsl-multiproject/build.gradle.kts @@ -1,8 +1,9 @@ import com.saveourtool.diktat.plugin.gradle.DiktatExtension +import com.saveourtool.diktat.plugin.gradle.DiktatGradlePlugin plugins { kotlin("jvm") version "1.9.21" - id("com.saveourtool.diktat.diktat-gradle-plugin") + id("com.saveourtool.diktat") version "2.0.0" apply false } allprojects { @@ -10,7 +11,7 @@ allprojects { mavenLocal() mavenCentral() } - apply(plugin = "com.saveourtool.diktat.diktat-gradle-plugin") + apply() configure { diktatConfigFile = rootProject.file("diktat-analysis.yml") inputs { include("src/**/*.kt") } diff --git a/examples/gradle-kotlin-dsl-multiproject/frontend/build.gradle.kts b/examples/gradle-kotlin-dsl-multiproject/frontend/build.gradle.kts new file mode 100644 index 0000000000..444baaa3c8 --- /dev/null +++ b/examples/gradle-kotlin-dsl-multiproject/frontend/build.gradle.kts @@ -0,0 +1,3 @@ +plugins { + kotlin("jvm") +} diff --git a/examples/gradle-kotlin-dsl-multiproject/frontend/src/main/kotlin/AnotherTest.kt b/examples/gradle-kotlin-dsl-multiproject/frontend/src/main/kotlin/AnotherTest.kt new file mode 100644 index 0000000000..f694d51893 --- /dev/null +++ b/examples/gradle-kotlin-dsl-multiproject/frontend/src/main/kotlin/AnotherTest.kt @@ -0,0 +1,15 @@ +package whate.ver + +fun String.createPluginConfig() { + val pluginConfig = TomlDecoder.decode( + serializer(), + fakeFileNode, + DecoderConf() + ) + pluginConfig.configLocation = this.toPath() + pluginConfig.prop1 = property1 + // comment1 + pluginConfig.configLocation2 = this.toPath() + // comment2 + pluginConfig.prop2 = property2 +} diff --git a/examples/gradle-kotlin-dsl-multiproject/settings.gradle.kts b/examples/gradle-kotlin-dsl-multiproject/settings.gradle.kts index e91656892d..02438cade7 100644 --- a/examples/gradle-kotlin-dsl-multiproject/settings.gradle.kts +++ b/examples/gradle-kotlin-dsl-multiproject/settings.gradle.kts @@ -1 +1,2 @@ include(":backend") +include(":frontend") diff --git a/examples/gradle-kotlin-dsl/build.gradle.kts b/examples/gradle-kotlin-dsl/build.gradle.kts index be4038109d..38717360ae 100644 --- a/examples/gradle-kotlin-dsl/build.gradle.kts +++ b/examples/gradle-kotlin-dsl/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("com.saveourtool.diktat.diktat-gradle-plugin") version "1.2.5" + id("com.saveourtool.diktat") version "2.0.0" } repositories { diff --git a/examples/gradle-kotlin-dsl/settings.gradle.kts b/examples/gradle-kotlin-dsl/settings.gradle.kts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/maven-multiproject/backend/pom.xml b/examples/maven-multiproject/backend/pom.xml new file mode 100644 index 0000000000..af3fc7df6d --- /dev/null +++ b/examples/maven-multiproject/backend/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + com.saveourtool.diktat + diktat-examples-maven-multiproject + 0.0-SNAPSHOT + ../pom.xml + + backend + diff --git a/examples/maven-multiproject/backend/src/main/kotlin/Main.kt b/examples/maven-multiproject/backend/src/main/kotlin/Test.kt similarity index 100% rename from examples/maven-multiproject/backend/src/main/kotlin/Main.kt rename to examples/maven-multiproject/backend/src/main/kotlin/Test.kt diff --git a/examples/maven-multiproject/frontend/pom.xml b/examples/maven-multiproject/frontend/pom.xml new file mode 100644 index 0000000000..e7a0636b0f --- /dev/null +++ b/examples/maven-multiproject/frontend/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + com.saveourtool.diktat + diktat-examples-maven-multiproject + 0.0-SNAPSHOT + ../pom.xml + + frontend + diff --git a/examples/maven-multiproject/frontend/src/main/kotlin/AnotherMain.kt b/examples/maven-multiproject/frontend/src/main/kotlin/AnotherMain.kt deleted file mode 100644 index c350958f09..0000000000 --- a/examples/maven-multiproject/frontend/src/main/kotlin/AnotherMain.kt +++ /dev/null @@ -1,13 +0,0 @@ -package incorrect - -class anotherincorrectname: Exception() { - fun ANOTHER_INCORRECT_FUNCTION() { - throw Exception() - } - - // fun anotherCommentedFunction() { - // } - - val Another_Incorrect_Val = 5 - -} diff --git a/examples/maven-multiproject/frontend/src/main/kotlin/AnotherTest.kt b/examples/maven-multiproject/frontend/src/main/kotlin/AnotherTest.kt new file mode 100644 index 0000000000..f694d51893 --- /dev/null +++ b/examples/maven-multiproject/frontend/src/main/kotlin/AnotherTest.kt @@ -0,0 +1,15 @@ +package whate.ver + +fun String.createPluginConfig() { + val pluginConfig = TomlDecoder.decode( + serializer(), + fakeFileNode, + DecoderConf() + ) + pluginConfig.configLocation = this.toPath() + pluginConfig.prop1 = property1 + // comment1 + pluginConfig.configLocation2 = this.toPath() + // comment2 + pluginConfig.prop2 = property2 +} diff --git a/examples/maven-multiproject/pom.xml b/examples/maven-multiproject/pom.xml index aaa5d6d39d..03f84fb47b 100644 --- a/examples/maven-multiproject/pom.xml +++ b/examples/maven-multiproject/pom.xml @@ -3,12 +3,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.saveourtool.diktat - diktat-examples-maven + diktat-examples-maven-multiproject pom - 1.2.6-SNAPSHOT + 0.0-SNAPSHOT - 1.2.5 + 2.0.0