Skip to content

Commit

Permalink
Fix for NSFE when mvn test run from /diktat-rules (#1366)
Browse files Browse the repository at this point in the history
### What's done:
- added arguments for methods in Generation.kt
  • Loading branch information
nulls authored Jun 16, 2022
1 parent 48360cd commit fc84620
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions diktat-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
</executions>
<configuration>
<mainClass>org.cqfn.diktat.ruleset.generation.GenerationKt</mainClass>
<arguments>
<argument>${project.build.sourceDirectory}</argument>
<argument>${project.basedir}/src/test/resources</argument>
</arguments>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,15 @@ private val autoGenerationComment =
| This document contains all enum properties from Warnings.kt as Strings.
""".trimMargin()

fun main() {
generateWarningNames()
validateYear()
fun main(args: Array<String>) {
require(args.size == 2) {
"Only to arguments are expected"
}
generateWarningNames(args[0])
validateYear(args[1])
}

private fun generateWarningNames() {
private fun generateWarningNames(sourceDirectory: String) {
val enumValNames = Warnings.values().map { it.name }

val propertyList = enumValNames.map {
Expand All @@ -59,11 +62,11 @@ private fun generateWarningNames() {
.addFileComment(autoGenerationComment)
.build()

kotlinFile.writeTo(Paths.get("diktat-rules/src/main/kotlin")) // fixme: need to add it to pom
kotlinFile.writeTo(Paths.get(sourceDirectory))
}

private fun validateYear() {
val folder = Paths.get("diktat-rules/src/test/resources/test/paragraph2/header")
private fun validateYear(testResourcesDirectory: String) {
val folder = Paths.get(testResourcesDirectory, "test/paragraph2/header")
Files.list(folder)
.filter { !it.name.contains("CopyrightDifferentYearTest.kt") }
.forEach { file ->
Expand Down

0 comments on commit fc84620

Please sign in to comment.