From 79f41e09df34874bb9435258fe1bd156fee8f1c6 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Sat, 10 Jun 2023 20:36:23 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"feat:=20=E2=9C=A8=20Separated=20Qodan?= =?UTF-8?q?a=20and=20Spoon=20mining=20(#729)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dda44b233f64e6d50fe068cd52994515777e60aa. --- .../laughing_train/mining/PeriodicMiner.java | 53 ++++++------------- .../api/BadSmellGraphQLTest.java | 1 + 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/PeriodicMiner.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/PeriodicMiner.java index 972aae855..8343f2e72 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/PeriodicMiner.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/mining/PeriodicMiner.java @@ -81,54 +81,21 @@ private Project getKnownProject() { } void mine(@Observes StartupEvent event) { - vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoQodana())); - vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon())); + vertx.setTimer(TimeUnit.MINUTES.toMillis(5), v -> vertx.executeBlocking(it -> mineRandomRepo())); } - private void mineRandomRepoQodana() { + private void mineRandomRepo() { try { var project = queue.isEmpty() ? getRandomProject() : queue.poll(); var checkoutResult = checkoutProject(project); if (checkoutResult instanceof ProjectResult.Error) { logger.atWarning().log("Failed to checkout project %s", project); - mineRandomRepoQodana(); + mineRandomRepo(); return; } if (checkoutResult instanceof ProjectResult.Success success) { logger.atInfo().log("Successfully checked out project %s", success.project()); var qodanaResult = analyzeProject(success); - - if (qodanaResult instanceof QodanaResult.Failure failure) { - logger.atWarning().log("Failed to analyze project %s", failure.message()); - tryDeleteProject(success); - return; - } - if (qodanaResult instanceof QodanaResult.Success successResult) { - logger.atInfo().log("Successfully analyzed project %s", success.project()); - saveQodanaResults(successResult); - addOrUpdateCommitHash(success); - } - } - } catch (Exception e) { - logger.atWarning().withCause(e).log("Failed to mine random repo"); - } finally { - logger.atInfo().log("Queue size: %s", queue.size()); - logger.atInfo().log("Mining next repo in 1 minute"); - vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoQodana())); - } - } - - private void mineRandomRepoSpoon() { - try { - var project = queue.isEmpty() ? getRandomProject() : queue.poll(); - var checkoutResult = checkoutProject(project); - if (checkoutResult instanceof ProjectResult.Error) { - logger.atWarning().log("Failed to checkout project %s", project); - mineRandomRepoSpoon(); - return; - } - if (checkoutResult instanceof ProjectResult.Success success) { - logger.atInfo().log("Successfully checked out project %s", success.project()); var spoonPatternAnalyzerResult = spoonPatternAnalyzer.analyze(new AnalyzerRequest.WithProject(success.project())); @@ -139,8 +106,20 @@ private void mineRandomRepoSpoon() { } if (spoonPatternAnalyzerResult instanceof SpoonPatternAnalyzerResult.Failure failure) { logger.atWarning().log("Failed to analyze project with spoon %s", failure.message()); + registry.counter("mining.spoon.error").increment(); tryDeleteProject(success); } + if (qodanaResult instanceof QodanaResult.Failure failure) { + logger.atWarning().log("Failed to analyze project %s", failure.message()); + registry.counter("mining.qodana.error").increment(); + tryDeleteProject(success); + return; + } + if (qodanaResult instanceof QodanaResult.Success successResult) { + logger.atInfo().log("Successfully analyzed project %s", success.project()); + saveQodanaResults(successResult); + addOrUpdateCommitHash(success); + } } } catch (Exception e) { logger.atWarning().withCause(e).log("Failed to mine random repo"); @@ -148,7 +127,7 @@ private void mineRandomRepoSpoon() { } finally { logger.atInfo().log("Queue size: %s", queue.size()); logger.atInfo().log("Mining next repo in 1 minute"); - vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepoSpoon())); + vertx.setTimer(TimeUnit.MINUTES.toMillis(1), v -> vertx.executeBlocking(it -> mineRandomRepo())); } } diff --git a/github-bot/src/test/java/io/github/martinwitt/laughing_train/api/BadSmellGraphQLTest.java b/github-bot/src/test/java/io/github/martinwitt/laughing_train/api/BadSmellGraphQLTest.java index c2563758f..c0ecf51c3 100644 --- a/github-bot/src/test/java/io/github/martinwitt/laughing_train/api/BadSmellGraphQLTest.java +++ b/github-bot/src/test/java/io/github/martinwitt/laughing_train/api/BadSmellGraphQLTest.java @@ -21,6 +21,7 @@ import io.smallrye.graphql.client.dynamic.api.DynamicGraphQLClientBuilder; import jakarta.inject.Inject; import java.util.regex.Pattern; + import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test;