Skip to content

Commit

Permalink
Updated examples for Diktat 2.0 (#1877)
Browse files Browse the repository at this point in the history
### What's done:
- updated examples.

It's part of #1793
  • Loading branch information
DrAlexD authored Dec 19, 2023
1 parent 1b4b6c7 commit b8062d8
Show file tree
Hide file tree
Showing 20 changed files with 124 additions and 46 deletions.
2 changes: 1 addition & 1 deletion examples/gradle-groovy-dsl/build.gradle
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions examples/gradle-groovy-dsl/src/main/kotlin/AnotherTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package whate.ver

fun String.createPluginConfig() {
val pluginConfig = TomlDecoder.decode<T>(
serializer(),
fakeFileNode,
DecoderConf()
)
pluginConfig.configLocation = this.toPath()
pluginConfig.prop1 = property1
// comment1
pluginConfig.configLocation2 = this.toPath()
// comment2
pluginConfig.prop2 = property2
}
12 changes: 6 additions & 6 deletions examples/gradle-groovy-dsl/src/main/kotlin/Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
plugins {
kotlin("jvm")
id("com.saveourtool.diktat.diktat-gradle-plugin")
}
Original file line number Diff line number Diff line change
@@ -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

}
5 changes: 3 additions & 2 deletions examples/gradle-kotlin-dsl-multiproject/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
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 {
repositories {
mavenLocal()
mavenCentral()
}
apply(plugin = "com.saveourtool.diktat.diktat-gradle-plugin")
apply<DiktatGradlePlugin>()
configure<DiktatExtension> {
diktatConfigFile = rootProject.file("diktat-analysis.yml")
inputs { include("src/**/*.kt") }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
kotlin("jvm")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package whate.ver

fun String.createPluginConfig() {
val pluginConfig = TomlDecoder.decode<T>(
serializer(),
fakeFileNode,
DecoderConf()
)
pluginConfig.configLocation = this.toPath()
pluginConfig.prop1 = property1
// comment1
pluginConfig.configLocation2 = this.toPath()
// comment2
pluginConfig.prop2 = property2
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include(":backend")
include(":frontend")
2 changes: 1 addition & 1 deletion examples/gradle-kotlin-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Empty file.
12 changes: 12 additions & 0 deletions examples/maven-multiproject/backend/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.saveourtool.diktat</groupId>
<artifactId>diktat-examples-maven-multiproject</artifactId>
<version>0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>backend</artifactId>
</project>
12 changes: 12 additions & 0 deletions examples/maven-multiproject/frontend/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.saveourtool.diktat</groupId>
<artifactId>diktat-examples-maven-multiproject</artifactId>
<version>0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>frontend</artifactId>
</project>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package whate.ver

fun String.createPluginConfig() {
val pluginConfig = TomlDecoder.decode<T>(
serializer(),
fakeFileNode,
DecoderConf()
)
pluginConfig.configLocation = this.toPath()
pluginConfig.prop1 = property1
// comment1
pluginConfig.configLocation2 = this.toPath()
// comment2
pluginConfig.prop2 = property2
}
17 changes: 10 additions & 7 deletions examples/maven-multiproject/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.saveourtool.diktat</groupId>
<artifactId>diktat-examples-maven</artifactId>
<artifactId>diktat-examples-maven-multiproject</artifactId>
<packaging>pom</packaging>
<version>1.2.6-SNAPSHOT</version>
<version>0.0-SNAPSHOT</version>

<properties>
<diktat.version>1.2.5</diktat.version>
<diktat.version>2.0.0</diktat.version>
</properties>

<!-- This is an example of how DiKTat performs static code analysis.
Expand All @@ -26,10 +26,8 @@
<configuration>
<diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
<inputs>
<input>${project.basedir}/backend/src/main/kotlin</input>
<input>${project.basedir}/backend/src/test/kotlin</input>
<input>${project.basedir}/frontend/src/main/kotlin</input>
<input>${project.basedir}/frontend/src/test/kotlin</input>
<input>${project.basedir}/src/main/kotlin</input>
<input>${project.basedir}/src/test/kotlin</input>
</inputs>
</configuration>
<executions>
Expand All @@ -44,4 +42,9 @@
</plugin>
</plugins>
</build>

<modules>
<module>backend</module>
<module>frontend</module>
</modules>
</project>
4 changes: 2 additions & 2 deletions examples/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<groupId>com.saveourtool.diktat</groupId>
<artifactId>diktat-examples-maven</artifactId>
<packaging>pom</packaging>
<version>1.2.6-SNAPSHOT</version>
<version>0.0-SNAPSHOT</version>

<properties>
<diktat.version>1.2.5</diktat.version>
<diktat.version>2.0.0</diktat.version>
</properties>

<!-- This is an example of how DiKTat performs static code analysis.
Expand Down
15 changes: 15 additions & 0 deletions examples/maven/src/main/kotlin/AnotherTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package whate.ver

fun String.createPluginConfig() {
val pluginConfig = TomlDecoder.decode<T>(
serializer(),
fakeFileNode,
DecoderConf()
)
pluginConfig.configLocation = this.toPath()
pluginConfig.prop1 = property1
// comment1
pluginConfig.configLocation2 = this.toPath()
// comment2
pluginConfig.prop2 = property2
}
12 changes: 6 additions & 6 deletions examples/maven/src/main/kotlin/Test.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package incorrect

class incorrectname: Exception() {
fun INCORRECT_FUNCTION() {
throw Exception()
}
fun INCORRECT_FUNCTION() {
throw Exception()
}

// fun myCommentedFunction() {
// }
// fun myCommentedFunction() {
// }

val Incorrect_Val = 5
val Incorrect_Val = 5

}

0 comments on commit b8062d8

Please sign in to comment.