From d6d79ab4d7013e928f1ac29cd2dd1f46884edca5 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:06 +0200 Subject: [PATCH 1/9] Update kotlin 1.7.20 --- .idea/kotlinc.xml | 3 +++ build.gradle.kts | 10 ++++------ gradle.properties | 1 - .../kotlin/fr/postgresjson/connexion/Connection.kt | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 9b02d59..8801066 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -3,4 +3,7 @@ + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 09ee113..85d61ed 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { jacoco id("maven-publish") - kotlin("jvm") version "1.5.10" + kotlin("jvm") version "1.7.20" id("org.jlleitschuh.gradle.ktlint") version "10.0.0" id("org.owasp.dependencycheck") version "6.1.1" @@ -26,8 +26,6 @@ repositories { tasks.withType { kotlinOptions { jvmTarget = "11" - sourceCompatibility = "11" - targetCompatibility = "11" } } @@ -65,8 +63,8 @@ tasks.publishToMavenLocal { } dependencies { - implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20") - implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.20") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20") + implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.20") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1") implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1") implementation("com.github.jasync-sql:jasync-postgresql:1.1.7") @@ -77,7 +75,7 @@ dependencies { testImplementation("ch.qos.logback:logback-core:1.2.3") testImplementation("io.mockk:mockk:1.10.6") testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") - testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.5.20") + testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20") testImplementation("org.amshove.kluent:kluent:1.65") } diff --git a/gradle.properties b/gradle.properties index 00a8cd7..c9ef82b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,4 @@ kotlin.code.style=official -kotlin_version=1.5.10 systemProp.sonar.host.url=https://sonarcloud.io systemProp.sonar.projectKey=postgres-json systemProp.sonar.projectName=PostgresJson diff --git a/src/main/kotlin/fr/postgresjson/connexion/Connection.kt b/src/main/kotlin/fr/postgresjson/connexion/Connection.kt index 9fcd2d6..8a58434 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/Connection.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/Connection.kt @@ -106,7 +106,7 @@ class Connection( val result = exec(sql, values) val json = result.rows[0].getString(0) return if (json === null) { - listOf() as List + emptyList() } else { serializer.deserializeList(json, typeReference) }.also { @@ -160,7 +160,7 @@ class Connection( } val json = firstLine.getString(0) val entities = if (json == null) { - listOf() as List + emptyList() } else { serializer.deserializeList(json, typeReference) } @@ -328,7 +328,7 @@ class Connection( """ |$msg | - |${parameters.joinToString(", ") { it.toString() }.prependIndent(" > ") ?: ""} + |${parameters.joinToString(", ") { it.toString() }.prependIndent(" > ")} |${sql.prependIndent(" > ")} |${result?.let { "-----" }?.prependIndent(" > ") ?: ""} |${result?.columnNames()?.joinToString(" | ")?.prependIndent(" > ") ?: ""} @@ -345,7 +345,7 @@ class Connection( """ |$msg | - |${parameters.map { ":" + it.key + " = " + it.value }.joinToString(", ").prependIndent(" > ") ?: ""} + |${parameters.map { ":" + it.key + " = " + it.value }.joinToString(", ").prependIndent(" > ")} |${sql.prependIndent(" > ")} |${result?.let { "-----" }?.prependIndent(" > ") ?: ""} |${result?.columnNames()?.joinToString(" | ")?.prependIndent(" > ") ?: ""} From 0f10b6308e03fc36adb3cffcdddb86bc5be25656 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:12 +0200 Subject: [PATCH 2/9] Update logback --- build.gradle.kts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 85d61ed..21e5506 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -68,11 +68,11 @@ dependencies { implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1") implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1") implementation("com.github.jasync-sql:jasync-postgresql:1.1.7") - implementation("org.slf4j:slf4j-api:1.7.30") + implementation("org.slf4j:slf4j-api:2.0.3") implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.0") - testImplementation("ch.qos.logback:logback-classic:1.2.3") - testImplementation("ch.qos.logback:logback-core:1.2.3") + testImplementation("ch.qos.logback:logback-classic:1.4.3") + testImplementation("ch.qos.logback:logback-core:1.4.3") testImplementation("io.mockk:mockk:1.10.6") testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20") From c5a9efe8df0e6893a56ac7f4f93f2a5c74ff4785 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:13 +0200 Subject: [PATCH 3/9] Update fasterxml --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 21e5506..496f528 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -65,8 +65,8 @@ tasks.publishToMavenLocal { dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.20") implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.20") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0-rc1") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.14.0-rc1") implementation("com.github.jasync-sql:jasync-postgresql:1.1.7") implementation("org.slf4j:slf4j-api:2.0.3") implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.0") From c5c271506fbe4345dc89f54d36575a0d965cadc1 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:14 +0200 Subject: [PATCH 4/9] Update jasync --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 496f528..0548d4a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -67,7 +67,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect:1.7.20") implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0-rc1") implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.14.0-rc1") - implementation("com.github.jasync-sql:jasync-postgresql:1.1.7") + implementation("com.github.jasync-sql:jasync-postgresql:2.1.7") implementation("org.slf4j:slf4j-api:2.0.3") implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.0") From 38170246dd28be79d5e638256c7b98a8bacdd431 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:15 +0200 Subject: [PATCH 5/9] Update com.avast.gradle.docker-compose --- build.gradle.kts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0548d4a..7aeba98 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ plugins { id("org.jlleitschuh.gradle.ktlint") version "10.0.0" id("org.owasp.dependencycheck") version "6.1.1" id("fr.coppernic.versioning") version "3.2.1" - id("com.avast.gradle.docker-compose") version "0.14.4" + id("com.avast.gradle.docker-compose") version "0.16.9" id("org.sonarqube") version "+" } @@ -69,7 +69,6 @@ dependencies { implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.14.0-rc1") implementation("com.github.jasync-sql:jasync-postgresql:2.1.7") implementation("org.slf4j:slf4j-api:2.0.3") - implementation("com.avast.gradle:gradle-docker-compose-plugin:0.14.0") testImplementation("ch.qos.logback:logback-classic:1.4.3") testImplementation("ch.qos.logback:logback-core:1.4.3") @@ -86,9 +85,9 @@ val sourcesJar by tasks.creating(Jar::class) { apply(plugin = "docker-compose") dockerCompose { - projectName = "postgres-json" - useComposeFiles = listOf("docker-compose.yml") - stopContainers = !containerAlwaysOn.toBoolean() + setProjectName("postgres-json") + setProperty("useComposeFiles", listOf("docker-compose.yml")) + setProperty("stopContainers", !containerAlwaysOn.toBoolean()) isRequiredBy(project.tasks.test) } From 1b3616df59fd4228c8cf5703b07a7873596671af Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:15 +0200 Subject: [PATCH 6/9] Update ktlint --- build.gradle.kts | 2 +- src/test/kotlin/fr/postgresjson/MigrationTest.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7aeba98..cf7c552 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { id("maven-publish") kotlin("jvm") version "1.7.20" - id("org.jlleitschuh.gradle.ktlint") version "10.0.0" + id("org.jlleitschuh.gradle.ktlint") version "11.0.0" id("org.owasp.dependencycheck") version "6.1.1" id("fr.coppernic.versioning") version "3.2.1" id("com.avast.gradle.docker-compose") version "0.16.9" diff --git a/src/test/kotlin/fr/postgresjson/MigrationTest.kt b/src/test/kotlin/fr/postgresjson/MigrationTest.kt index 6d97a34..2e04a39 100644 --- a/src/test/kotlin/fr/postgresjson/MigrationTest.kt +++ b/src/test/kotlin/fr/postgresjson/MigrationTest.kt @@ -4,9 +4,9 @@ import fr.postgresjson.connexion.Requester import fr.postgresjson.connexion.selectOne import fr.postgresjson.migration.Migration import fr.postgresjson.migration.Migrations +import org.amshove.kluent.invoking import org.amshove.kluent.`should be equal to` import org.amshove.kluent.`should contain` -import org.amshove.kluent.invoking import org.amshove.kluent.shouldThrow import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test From f06bdd732e495b6eaa173f946282688d18aea069 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:16 +0200 Subject: [PATCH 7/9] Update tests libraries --- build.gradle.kts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cf7c552..673c776 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { kotlin("jvm") version "1.7.20" id("org.jlleitschuh.gradle.ktlint") version "11.0.0" - id("org.owasp.dependencycheck") version "6.1.1" + id("org.owasp.dependencycheck") version "7.2.0" id("fr.coppernic.versioning") version "3.2.1" id("com.avast.gradle.docker-compose") version "0.16.9" id("org.sonarqube") version "+" @@ -72,10 +72,10 @@ dependencies { testImplementation("ch.qos.logback:logback-classic:1.4.3") testImplementation("ch.qos.logback:logback-core:1.4.3") - testImplementation("io.mockk:mockk:1.10.6") - testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") + testImplementation("io.mockk:mockk:1.13.2") + testImplementation("org.junit.jupiter:junit-jupiter:5.9.0") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.7.20") - testImplementation("org.amshove.kluent:kluent:1.65") + testImplementation("org.amshove.kluent:kluent:1.68") } val sourcesJar by tasks.creating(Jar::class) { From 927eff71725f8374921597dc123bbffbaaab5a76 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:17 +0200 Subject: [PATCH 8/9] remove jcenter --- build.gradle.kts | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 673c776..78fc83f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,7 +20,6 @@ version = versioning.info.tag repositories { mavenCentral() - jcenter() } tasks.withType { From 4392f1ff8fc0a8e3c7b3ebbb4d65076436498f24 Mon Sep 17 00:00:00 2001 From: Fabrice Lecomte Date: Sat, 15 Oct 2022 00:35:18 +0200 Subject: [PATCH 9/9] optimise regex --- src/main/kotlin/fr/postgresjson/connexion/Connection.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/fr/postgresjson/connexion/Connection.kt b/src/main/kotlin/fr/postgresjson/connexion/Connection.kt index 8a58434..1ffdfea 100644 --- a/src/main/kotlin/fr/postgresjson/connexion/Connection.kt +++ b/src/main/kotlin/fr/postgresjson/connexion/Connection.kt @@ -220,7 +220,7 @@ class Connection( } private fun replaceArgs(sql: String, values: Map, block: ParametersQuery.() -> T): T { - val paramRegex = "(? val name = match.groups[1]!!.value values[name] ?: values[name.trimStart('_')] ?: queryError("""Parameter "$name" missing""", sql, values) @@ -230,7 +230,7 @@ class Connection( } private fun replaceNamedArgByQuestionMark(sql: String): String = - "(?