Skip to content

Commit 0701093

Browse files
committed
Sustaining based on SonarQube warnings
- remove harcoded versions in build.gradle.kts files - merge into allProjects dependencies, redundant dependencies of all sub-projects - replace if/checks by require/check/requireNotNull - code Cleaning (naming,...)
1 parent 02e323a commit 0701093

File tree

28 files changed

+217
-232
lines changed

28 files changed

+217
-232
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
LICENSE
22
=======
33

4-
Copyright 2021-2022 Cosmo Tech
4+
Copyright 2021-2025 Cosmo Tech
55

66
You are authorized to use this software following the execution of a specific agreement with Cosmo Tech or with an authorized licensee of Cosmo Tech.
77

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ an html report will be generated under `/build/reports`
381381

382382
## License
383383

384-
Copyright 2021 Cosmo Tech
384+
Copyright 2025 Cosmo Tech
385385

386386
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
387387
and associated documentation files (the "Software"), to deal in the Software without

api/build.gradle.kts

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ plugins {
1111
id("org.jetbrains.kotlinx.kover")
1212
}
1313

14+
val testNgVersion = "7.8.0"
15+
val testContainersRedisVersion = "1.6.4"
16+
val testContainersPostgreSQLVersion = "1.19.7"
17+
1418
dependencies {
1519
implementation(projects.cosmotechMetaApi)
1620
implementation(projects.cosmotechConnectorApi)
@@ -21,11 +25,6 @@ dependencies {
2125
implementation(projects.cosmotechMetricsService)
2226
implementation(projects.cosmotechRunApi)
2327
implementation(projects.cosmotechRunnerApi)
24-
25-
testImplementation("org.testng:testng:7.8.0")
26-
testImplementation("com.redis.testcontainers:testcontainers-redis-junit:1.6.4")
27-
testImplementation("org.testcontainers:postgresql:1.19.7")
28-
testImplementation("org.springframework.boot:spring-boot-starter-test")
2928
testImplementation("org.springframework.security:spring-security-test")
3029
testImplementation("org.springframework.restdocs:spring-restdocs-mockmvc")
3130
}
@@ -47,6 +46,8 @@ tasks.withType<JibTask> {
4746
}
4847

4948
tasks.register<Copy>("copySubProjectsOpenAPIFiles") {
49+
group = "openapi"
50+
description = "Copy all subprojects openapi.yaml files into \$buildDir/tmp/openapi"
5051
// By convention, we expect OpenAPI files for sub-projects to be named and placed as follows:
5152
// <subproject>/src/main/openapi/<subproject>.yaml
5253
// For example: organization/src/main/openapi/organization.yaml
@@ -105,6 +106,8 @@ tasks.getByName<OpenApiMergerTask>("mergeOpenApiFiles") {
105106
}
106107

107108
tasks.register<GenerateTask>("openApiTypescriptGenerate") {
109+
group = "openapi-ts"
110+
description = "Generate OpenAPI TypeScript-Axios client"
108111
dependsOn("mergeOpenApiFiles")
109112
inputSpec.set("${rootDir}/openapi/openapi.yaml")
110113
outputDir.set("${layout.buildDirectory.get()}/generated-sources/openapi/typescript")
@@ -116,22 +119,32 @@ tasks.register<GenerateTask>("openApiTypescriptGenerate") {
116119
}
117120

118121
tasks.register<Copy>("copyTypescriptGitPushScript") {
122+
group = "openapi-ts"
123+
description =
124+
"Copy generated Typescript-Axios client project to \$buildDir/generated-sources/openapi/typescript/scripts"
119125
dependsOn("openApiTypescriptGenerate")
120126
from("${rootDir}/scripts/clients/build_override/git_push.sh")
121127
into("${layout.buildDirectory.get()}/generated-sources/openapi/typescript/scripts")
122128
}
123129

124130
tasks.register<Copy>("copyTypescriptLicense") {
131+
group = "openapi-ts"
132+
description =
133+
"Copy generated Typescript-Axios LICENSE file to \$buildDir/generated-sources/openapi/typescript/scripts"
125134
dependsOn("openApiTypescriptGenerate")
126135
from("${rootDir}/scripts/clients/build_override/LICENSE")
127136
into("${layout.buildDirectory.get()}/generated-sources/openapi/typescript")
128137
}
129138

130139
tasks.register("generateTypescriptClient") {
140+
group = "openapi-ts"
141+
description = "Push generated Typescript-Axios client project to dedicated github repository"
131142
dependsOn("copyTypescriptGitPushScript", "copyTypescriptLicense")
132143
}
133144

134145
tasks.register<GenerateTask>("openApiPythonGenerate") {
146+
group = "openapi-python"
147+
description = "Generate OpenAPI Python client"
135148
dependsOn("mergeOpenApiFiles")
136149
inputSpec.set("${rootDir}/openapi/openapi.yaml")
137150
outputDir.set("${layout.buildDirectory.get()}/generated-sources/openapi/python")
@@ -146,18 +159,27 @@ tasks.register<GenerateTask>("openApiPythonGenerate") {
146159
// PROD-14252: temporary fix waiting for upstream resolution of
147160
// https://github.com/OpenAPITools/openapi-generator/pull/20701
148161
tasks.register<Copy>("overwriteGeneratedPythonFile") {
162+
group = "openapi-python"
163+
description =
164+
"Patch OpenAPI Python client (temporary fix OpenAPITools/openapi-generator/pull/20701)"
149165
dependsOn("openApiPythonGenerate")
150166
from("${rootDir}/scripts/clients/patches/python.yml")
151167
into("${layout.buildDirectory.get()}/generated-sources/openapi/python/.github/workflows/")
152168
}
153169

154170
tasks.register<Copy>("copyPythonGitPushScript") {
171+
group = "openapi-python"
172+
description =
173+
"Copy generated Python client project to \$buildDir/generated-sources/openapi/python/scripts"
155174
dependsOn("openApiPythonGenerate")
156175
from("${rootDir}/scripts/clients/build_override/git_push.sh")
157176
into("${layout.buildDirectory.get()}/generated-sources/openapi/python/scripts")
158177
}
159178

160179
tasks.register<Copy>("copyPythonLicense") {
180+
group = "openapi-python"
181+
description =
182+
"Copy generated Python LICENSE file to \$buildDir/generated-sources/openapi/python/scripts"
161183
dependsOn("openApiPythonGenerate")
162184
from("${rootDir}/scripts/clients/build_override/LICENSE")
163185
into("${layout.buildDirectory.get()}/generated-sources/openapi/python")
@@ -166,21 +188,29 @@ tasks.register<Copy>("copyPythonLicense") {
166188
// PROD-14252: temporary fix waiting for upstream resolution
167189
// of https://github.com/OpenAPITools/openapi-generator/pull/20701
168190
tasks.register("generatePythonClient") {
191+
group = "openapi-python"
192+
description = "Push generated Python client project to dedicated github repository"
169193
dependsOn("copyPythonGitPushScript", "copyPythonLicense", "overwriteGeneratedPythonFile")
170194
}
171195

172196
tasks.register<GenerateTask>("openApiUmlGenerate") {
197+
group = "documentation"
198+
description = "Generate OpenAPI UML schema"
173199
dependsOn("mergeOpenApiFiles")
174200
inputSpec.set("${rootDir}/openapi/openapi.yaml")
175201
outputDir.set("$rootDir/openapi/plantuml")
176202
generatorName.set("plantuml")
177203
}
178204

179205
tasks.register<Delete>("openApiMarkdownClean") {
206+
group = "documentation"
207+
description = "Remove MD files generated"
180208
delete("$rootDir/doc/Apis", "$rootDir/doc/Models")
181209
}
182210

183211
tasks.register<GenerateTask>("openApiMarkdownGenerate") {
212+
group = "documentation"
213+
description = "Generate MD documentation files"
184214
dependsOn("mergeOpenApiFiles", "openApiMarkdownClean")
185215
inputSpec.set("${rootDir}/openapi/openapi.yaml")
186216
outputDir.set("$rootDir/doc")
@@ -195,6 +225,8 @@ tasks.getByName<ValidateTask>("openApiValidate") {
195225
}
196226

197227
tasks.register("generateClients") {
228+
group = "openapi"
229+
description = "Generate Python and TS API clients, UML and Markdown documentation"
198230
dependsOn(
199231
"generateTypescriptClient",
200232
"generatePythonClient",
@@ -213,32 +245,6 @@ tasks.withType<GenerateTask> {
213245
outputs.upToDateWhen { false }
214246
}
215247

216-
tasks.register<Exec>("rolloutKindDeployment") {
217-
dependsOn("jib")
218-
var apiVersion = "latest"
219-
var namespace = "phoenix"
220-
var clusterName = "kind-local-k8s-cluster"
221-
if (project.hasProperty("rollout.apiVersion")) {
222-
apiVersion = project.property("rollout.apiVersion").toString()
223-
}
224-
if (project.hasProperty("rollout.namespace")) {
225-
namespace = project.property("rollout.namespace").toString()
226-
}
227-
if (project.hasProperty("rollout.clusterName")) {
228-
clusterName = project.property("rollout.clusterName").toString()
229-
}
230-
231-
commandLine(
232-
"kubectl",
233-
"--context",
234-
clusterName,
235-
"-n",
236-
namespace,
237-
"rollout",
238-
"restart",
239-
"deployment/cosmotech-api-${apiVersion}")
240-
}
241-
242248
tasks.register<GenerateTask>("generateDocumentation") {
243249
group = "documentation"
244250
description = "Generates adoc file containing API documentation"

api/src/main/resources/banner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ ${AnsiColor.BRIGHT_GREEN}Cosmo Tech API${AnsiColor.DEFAULT}
44
.: Version : ${AnsiColor.BRIGHT_YELLOW}@projectVersion@${AnsiColor.DEFAULT} :.
55
.: Spring Boot : ${AnsiColor.BRIGHT_YELLOW}${spring-boot.formatted-version}${AnsiColor.DEFAULT} :.
66

7-
Copyright 2021 Cosmo Tech
7+
Copyright 2025 Cosmo Tech
88
-------------------------------------

build.gradle.kts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ val jedisVersion = "4.4.6"
6666
val springOauthVersion = "6.4.2"
6767
val redisOmSpringVersion = "0.9.7"
6868
val kotlinCoroutinesCoreVersion = "1.8.1"
69+
val kotlinCoroutinesTestVersion = "1.7.3"
6970
val oktaSpringBootVersion = "3.0.7"
7071
val springDocVersion = "2.8.6"
7172
val swaggerParserVersion = "2.1.25"
7273
val commonsCsvVersion = "1.10.0"
7374
val apiValidationVersion = "3.0.2"
7475
val kubernetesClientVersion = "22.0.0"
76+
val orgJsonVersion = "20240303"
77+
val jacksonModuleKotlinVersion = "2.18.3"
78+
val testNgVersion = "7.8.0"
79+
val testContainersRedisVersion = "1.6.4"
80+
val testContainersPostgreSQLVersion = "1.19.7"
81+
val commonCompressVersion = "1.27.1"
7582

7683
// Checks
7784
val detektVersion = "1.23.7"
@@ -282,7 +289,7 @@ subprojects {
282289
implementation("io.undertow:undertow-core:2.3.18.Final")
283290
}
284291
}
285-
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.3")
292+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonModuleKotlinVersion")
286293
// https://mvnrepository.com/artifact/jakarta.validation/jakarta.validation-api
287294
implementation("jakarta.validation:jakarta.validation-api:$apiValidationVersion")
288295
implementation("io.kubernetes:client-java:${kubernetesClientVersion}")
@@ -301,15 +308,21 @@ subprojects {
301308
implementation("org.springframework.data:spring-data-redis")
302309
implementation("org.springframework:spring-jdbc")
303310
implementation("org.postgresql:postgresql")
311+
implementation("org.apache.commons:commons-compress:$commonCompressVersion")
304312

305-
implementation("org.json:json:20240303")
313+
implementation("org.json:json:$orgJsonVersion")
306314

307315
testImplementation(kotlin("test"))
308316
testImplementation(platform("org.junit:junit-bom:$jUnitBomVersion"))
309317
testImplementation("org.junit.jupiter:junit-jupiter")
310318
testImplementation("io.mockk:mockk:$mockkVersion")
311319
testImplementation("org.awaitility:awaitility-kotlin:$awaitilityKVersion")
312-
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3")
320+
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesTestVersion")
321+
testImplementation("org.testng:testng:$testNgVersion")
322+
testImplementation(
323+
"com.redis.testcontainers:testcontainers-redis-junit:$testContainersRedisVersion")
324+
testImplementation("org.testcontainers:postgresql:$testContainersPostgreSQLVersion")
325+
testImplementation("org.springframework.boot:spring-boot-starter-test")
313326

314327
integrationTestImplementation("org.springframework.boot:spring-boot-starter-test") {
315328
// Drop legacy Junit < 5
@@ -359,6 +372,8 @@ subprojects {
359372
}
360373

361374
tasks.register<Copy>("copyAdocFiles") {
375+
group = "documentation"
376+
description = "Copy test generated code snippets to \$rootDir/doc/generated-snippets/"
362377
dependsOn("integrationTest")
363378
from("$testWorkingDirPath/build/generated-snippets")
364379
into("${rootDir}/doc/generated-snippets")
@@ -463,11 +478,16 @@ subprojects {
463478
openApiDefinitionFile
464479
}
465480
tasks.register<Copy>("copyOpenApiYamlToMainResources") {
481+
group = "openapi"
482+
description = "Copy openapi.yaml files to \$buildDir/resources/main/static/openapi.yaml"
466483
from(openApiFileDefinition)
467484
into("${layout.buildDirectory.get()}/resources/main/static")
468485
rename { if (it != "openapi.yaml") "openapi.yaml" else it }
469486
}
487+
470488
tasks.register<Copy>("copyOpenApiYamlToTestResources") {
489+
group = "openapi"
490+
description = "Copy test openapi.yaml files to \$buildDir/resources/test/static/openapi.yaml"
471491
from(openApiFileDefinition)
472492
into("${layout.buildDirectory.get()}/resources/test/static")
473493
rename { if (it != "openapi.yaml") "openapi.yaml" else it }
@@ -476,7 +496,7 @@ subprojects {
476496
var fullVersion = project.version.toString()
477497
var buildVersion = ""
478498
if (!rootProject.scmVersion.scmPosition.revision.isNullOrEmpty()) {
479-
buildVersion = "${rootProject.scmVersion.scmPosition.revision.substring(0, 8)}"
499+
buildVersion = rootProject.scmVersion.scmPosition.revision.substring(0, 8)
480500
fullVersion = "$fullVersion-$buildVersion"
481501
}
482502
tasks.getByName<Copy>("processResources") {
@@ -495,6 +515,8 @@ subprojects {
495515
}
496516

497517
tasks.register<Copy>("copyAboutJsonToTestResources") {
518+
group = "information"
519+
description = "Copy test about.json file to \$rootDir/api/src/main/resources/about.json"
498520
from("${rootDir}/api/src/main/resources/about.json")
499521
into("${layout.buildDirectory.get()}/resources/test/")
500522
filter<ReplaceTokens>(
@@ -571,6 +593,9 @@ val copySubProjectsDetektReportsTasks =
571593
"${subProject.projectDir.relativeTo(rootDir)}"
572594
.capitalizeAsciiOnly()
573595
.replace("/", "_")) {
596+
group = "detekt"
597+
description =
598+
"Copy sub-projects detekt reports to \$projectDir/build/reports/detekt/\$format"
574599
dependsOn("spotlessKotlin", "spotlessKotlinGradle", "spotlessJava")
575600
from(
576601
file(
@@ -583,12 +608,7 @@ val copySubProjectsDetektReportsTasks =
583608
}
584609
}
585610

586-
tasks.register<Copy>("copySubProjectsDetektReports") {
587-
shouldRunAfter("detekt")
588-
dependsOn(*copySubProjectsDetektReportsTasks.toTypedArray())
589-
}
590-
591-
tasks.getByName("detekt") { finalizedBy("copySubProjectsDetektReports") }
611+
tasks.getByName("detekt") { shouldRunAfter(*copySubProjectsDetektReportsTasks.toTypedArray()) }
592612

593613
extensions.configure<kotlinx.kover.gradle.plugin.dsl.KoverReportExtension> {
594614
defaults {
@@ -605,4 +625,7 @@ extensions.configure<kotlinx.kover.gradle.plugin.dsl.KoverReportExtension> {
605625
}
606626

607627
// https://github.com/jk1/Gradle-License-Report/blob/master/README.md
608-
tasks.register<ReportTask>("generateLicenseDoc") {}
628+
tasks.register<ReportTask>("generateLicenseDoc") {
629+
group = "license"
630+
description = "Generate Licenses report"
631+
}

connector/build.gradle.kts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ plugins { id("org.jetbrains.kotlinx.kover") }
66

77
tasks.withType<GenerateTask> { additionalProperties.put("modelMutable", false) }
88

9-
dependencies {
10-
testImplementation("org.testng:testng:7.8.0")
11-
testImplementation("com.redis.testcontainers:testcontainers-redis-junit:1.6.4")
12-
testImplementation("org.springframework.boot:spring-boot-starter-test:3.4.4")
13-
}
9+
dependencies {}

dataset/build.gradle.kts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ plugins { id("org.jetbrains.kotlinx.kover") }
77
dependencies {
88
implementation(projects.cosmotechOrganizationApi)
99
implementation(projects.cosmotechConnectorApi)
10-
implementation("org.apache.commons:commons-compress:1.27.1")
11-
testImplementation("org.testng:testng:7.8.0")
12-
testImplementation("com.redis.testcontainers:testcontainers-redis-junit:1.6.4")
13-
testImplementation("org.springframework.boot:spring-boot-starter-test:3.4.4")
14-
1510
testImplementation(projects.cosmotechSolutionApi)
1611
testImplementation(projects.cosmotechWorkspaceApi)
1712
}

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,18 +1286,16 @@ class DatasetServiceImpl(
12861286
if (csmRbac.check(dataset.getRbac(), PERMISSION_READ_SECURITY).not()) {
12871287
val username = getCurrentAccountIdentifier(csmPlatformProperties)
12881288
val retrievedAC = dataset.security!!.accessControlList.firstOrNull { it.id == username }
1289-
if (retrievedAC != null) {
1290-
return dataset.copy(
1291-
security =
1292-
DatasetSecurity(
1293-
default = dataset.security!!.default,
1294-
accessControlList = mutableListOf(retrievedAC)))
1295-
} else {
1296-
return dataset.copy(
1297-
security =
1298-
DatasetSecurity(
1299-
default = dataset.security!!.default, accessControlList = mutableListOf()))
1300-
}
1289+
val accessControlList =
1290+
if (retrievedAC != null) {
1291+
mutableListOf(retrievedAC)
1292+
} else {
1293+
mutableListOf()
1294+
}
1295+
return dataset.copy(
1296+
security =
1297+
DatasetSecurity(
1298+
default = dataset.security!!.default, accessControlList = accessControlList))
13011299
}
13021300
return dataset
13031301
}

doc/Models/SendRunDataRequest.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
| Name | Type | Description | Notes |
55
|------------ | ------------- | ------------- | -------------|
6-
| **id** | **String** | | [optional] [default to null] |
7-
| **data** | [**List**](map.md) | | [optional] [default to null] |
6+
| **id** | **String** | | [default to null] |
7+
| **data** | [**List**](map.md) | | [default to null] |
88

99
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1010

0 commit comments

Comments
 (0)