From 602e83e3ef054525cfa2caf7032f7aad3e0044c2 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Sat, 6 Jan 2024 17:31:23 +0100 Subject: [PATCH 1/2] fix: Update Gradle dependencies and remove unused code The build.gradle file has been adjusted to update the Gradle dependencies list. Several dependencies have been rearranged, and the 'quarkus-opentelemetry' dependency was added. Furthermore, the method 'persistResults' in AnalyzerResultPersistenceService.java was removed as it no longer serves any purpose. Finally, the application properties file was adjusted, changing the Hibernate ORM database generation property from 'drop-and-create' to 'update'. --- github-bot/build.gradle | 29 ++++++++++++------- .../AnalyzerResultPersistenceService.java | 24 --------------- .../src/main/resources/application.properties | 4 +-- 3 files changed, 19 insertions(+), 38 deletions(-) diff --git a/github-bot/build.gradle b/github-bot/build.gradle index 002ac797b..4ae2f991a 100644 --- a/github-bot/build.gradle +++ b/github-bot/build.gradle @@ -5,31 +5,38 @@ plugins { } dependencies { - implementation 'io.quarkus:quarkus-info' - implementation 'io.quarkiverse.jgit:quarkus-jgit:3.0.6' implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") + + implementation 'io.quarkus:quarkus-info' + implementation 'io.quarkiverse.jgit:quarkus-jgit:3.0.6' implementation 'io.quarkiverse.githubapi:quarkus-github-api:1.318.0' implementation 'io.quarkus:quarkus-arc' implementation "io.quarkus:quarkus-scheduler" implementation 'io.quarkus:quarkus-smallrye-health' - implementation project(path: ':spoon-analyzer') - testImplementation 'io.quarkus:quarkus-junit5' - implementation project(":code-transformation") - annotationProcessor("io.quarkus:quarkus-panache-common") + implementation("io.quarkus:quarkus-smallrye-graphql") - testImplementation("io.quarkus:quarkus-smallrye-graphql-client") implementation 'io.quarkiverse.quinoa:quarkus-quinoa:2.3.2' implementation("io.quarkus:quarkus-oidc") implementation("io.quarkus:quarkus-keycloak-authorization") implementation("io.quarkus:quarkus-micrometer-registry-prometheus") - testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.25.1' - implementation project(":commons") implementation "io.quarkiverse.loggingmanager:quarkus-logging-manager:3.0.3" - testImplementation 'org.mockito:mockito-core:5.8.0' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.1' - annotationProcessor("io.quarkus:quarkus-panache-common") implementation("io.quarkus:quarkus-hibernate-orm-panache") implementation("io.quarkus:quarkus-jdbc-mariadb") + implementation("io.quarkus:quarkus-opentelemetry") + + implementation project(":commons") + implementation project(path: ':spoon-analyzer') + implementation project(":code-transformation") + + testImplementation 'org.mockito:mockito-core:5.8.0' + testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.25.1' + testImplementation 'io.quarkus:quarkus-junit5' + testImplementation("io.quarkus:quarkus-smallrye-graphql-client") + + annotationProcessor("io.quarkus:quarkus-panache-common") + annotationProcessor("io.quarkus:quarkus-panache-common") + } diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java index 371ab1d0e..49cd18a30 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java @@ -2,14 +2,11 @@ import com.google.common.flogger.FluentLogger; import io.github.martinwitt.laughing_train.commons.GitProject; -import io.github.martinwitt.laughing_train.data.QodanaResult; import io.github.martinwitt.laughing_train.data.result.CodeAnalyzerResult; import io.github.martinwitt.laughing_train.persistence.BadSmell; import io.github.martinwitt.laughing_train.persistence.repository.BadSmellRepository; -import io.smallrye.mutiny.Multi; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import java.util.stream.Collectors; @ApplicationScoped public class AnalyzerResultPersistenceService { @@ -17,27 +14,6 @@ public class AnalyzerResultPersistenceService { @Inject BadSmellRepository badSmellRepository; - void persistResults(QodanaResult result) { - if (result instanceof QodanaResult.Success success) { - GitProject gitProject = success.gitProject(); - Multi.createFrom() - .iterable(success.result()) - .map( - badSmell -> - new BadSmell( - badSmell, gitProject.name(), gitProject.url(), gitProject.commitHash())) - .filter(v -> badSmellRepository.findByIdentifier(v.getIdentifier()).isEmpty()) - .map(badSmellRepository::save) - .collect() - .with(Collectors.counting()) - .subscribe() - .with( - badSmell -> - logger.atInfo().log( - "Persisted %d qodana bad smells for project %s", - badSmell, gitProject.name())); - } - } void persistResults(CodeAnalyzerResult.Success success) { logger.atInfo().log( diff --git a/github-bot/src/main/resources/application.properties b/github-bot/src/main/resources/application.properties index 5ddf09d4a..544031aa8 100644 --- a/github-bot/src/main/resources/application.properties +++ b/github-bot/src/main/resources/application.properties @@ -10,10 +10,8 @@ quarkus.oidc.tls.verification=none %prod.quarkus.http.auth.permission.authenticated.policy=authenticated %dev.quarkus.smallrye-graphql.log-payload=queryAndVariables quarkus.smallrye-graphql.error-extension-fields=[exception,classification,code,description,validationErrorType,queryPath] -quarkus.ssl.native=true quarkus.http.proxy.proxy-address-forwarding=true quarkus.http.proxy.allow-forwarded=true -quarkus.http.proxy.allow-x-forwarded=true quarkus.http.proxy.enable-forwarded-host=true quarkus.http.proxy.enable-forwarded-prefix=true %dev.quarkus.scheduler.enabled=false @@ -24,5 +22,5 @@ quarkus.http.cors.origins=* quarkus.vertx.max-worker-execute-time=30m %test.quarkus.scheduler.enabled=false quarkus.datasource.db-kind = mariadb -quarkus.hibernate-orm.database.generation = drop-and-create +quarkus.hibernate-orm.database.generation = update %dev.quarkus.quinoa=false \ No newline at end of file From ceeb198e01fb3d6274400284d994a19ccc81d608 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Sat, 6 Jan 2024 17:48:00 +0100 Subject: [PATCH 2/2] up --- .../services/AnalyzerResultPersistenceService.java | 1 - .../mining/AnalyzerResultsPersistenceTest.java | 2 ++ .../persistence/impl/SqlProjectRepositoryTest.java | 12 ++++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java index 49cd18a30..b65baa06b 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/services/AnalyzerResultPersistenceService.java @@ -14,7 +14,6 @@ public class AnalyzerResultPersistenceService { @Inject BadSmellRepository badSmellRepository; - void persistResults(CodeAnalyzerResult.Success success) { logger.atInfo().log( "Persisting %s results for project %s", diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java index 461d450ef..1b6da8a15 100644 --- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java +++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/mining/AnalyzerResultsPersistenceTest.java @@ -6,6 +6,7 @@ import io.github.martinwitt.laughing_train.data.result.CodeAnalyzerResult; import io.github.martinwitt.laughing_train.mining.api.AnalyzerRunRepository; import io.github.martinwitt.laughing_train.mining.requests.StoreResults; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; import org.instancio.Instancio; @@ -18,6 +19,7 @@ class AnalyzerResultsPersistenceTest { @Inject AnalyzerRunRepository analyzerRunRepository; @Test + @TestTransaction void persistResults() { StoreResults storeResults = new StoreResults( diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java index 130e76c58..ec93462f9 100644 --- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java +++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/persistence/impl/SqlProjectRepositoryTest.java @@ -1,23 +1,23 @@ package io.github.martinwitt.laughing_train.persistence.impl; -import static org.assertj.core.api.Assertions.assertThat; - import io.github.martinwitt.laughing_train.domain.entity.RemoteProject; -import io.github.martinwitt.laughing_train.mining.api.AnalyzerRunRepository; +import io.quarkus.test.TestTransaction; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; -import java.util.List; import org.instancio.Instancio; import org.junit.jupiter.api.Test; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + @QuarkusTest class SqlProjectRepositoryTest { @Inject SqlProjectRepository sqlProjectRepository; - @Inject AnalyzerRunRepository sqlAnalyzerRunRepository; - @Test + @TestTransaction void insertProject() { RemoteProject remoteProject = Instancio.create(RemoteProject.class); sqlProjectRepository.save(remoteProject);