diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..6b6e7682a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Unit Tests +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + - 'releases/*' + +jobs: + junit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 + - uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: microsoft + - name: Run Tests + run: | + gradle test \ No newline at end of file diff --git a/code-transformation/build.gradle b/code-transformation/build.gradle index 79b812680..331532409 100644 --- a/code-transformation/build.gradle +++ b/code-transformation/build.gradle @@ -16,7 +16,6 @@ jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } dependencies { - // implementation 'fr.inria.gforge.spoon:spoon-core:10.0.1-beta-2' implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit', version: '6.3.0.202209071007-r' implementation group: 'org.eclipse.jgit', name: 'org.eclipse.jgit.ssh.apache', version: '6.3.0.202209071007-r' testImplementation "com.google.truth:truth:1.1.3" diff --git a/code-transformation/src/main/java/xyz/keksdose/spoon/code_solver/analyzer/qodana/rules/UnnecessaryModifier.java b/code-transformation/src/main/java/xyz/keksdose/spoon/code_solver/analyzer/qodana/rules/UnnecessaryModifier.java index 761178cbd..922fb11e2 100644 --- a/code-transformation/src/main/java/xyz/keksdose/spoon/code_solver/analyzer/qodana/rules/UnnecessaryModifier.java +++ b/code-transformation/src/main/java/xyz/keksdose/spoon/code_solver/analyzer/qodana/rules/UnnecessaryModifier.java @@ -43,6 +43,9 @@ public void refactor(ChangeListener listener, CtType type) { } for (CtElement match : PositionScanner.findLineOnly(type, result.position())) { if (match instanceof CtModifiable ctModifierHandler) { + if (!hasModifier(ctModifierHandler, modifier)) { + continue; + } var modifiers = new HashSet<>(ctModifierHandler.getModifiers()); modifiers.removeIf(v -> v.toString().equals(modifier.toLowerCase())); ctModifierHandler.setModifiers(modifiers); @@ -59,6 +62,11 @@ public void refactor(ChangeListener listener, CtType type) { } } + private boolean hasModifier(CtModifiable ctModifierHandler, String modifier) { + return ctModifierHandler.getModifiers().stream() + .anyMatch(v -> v.toString().equalsIgnoreCase(modifier)); + } + @Override public List getHandledBadSmells() { return List.of(UNNECESSARY_MODIFIER); diff --git a/github-bot/build.gradle b/github-bot/build.gradle index 9599423c1..a34e64934 100644 --- a/github-bot/build.gradle +++ b/github-bot/build.gradle @@ -22,7 +22,6 @@ dependencies { implementation("io.quarkus:quarkus-oidc") implementation("io.quarkus:quarkus-keycloak-authorization") testImplementation group: 'org.assertj', name: 'assertj-core', version: '3.23.1' - implementation 'io.vertx:vertx-junit5:+' } group 'io.github.martinwitt' diff --git a/github-bot/src/main/java/io/github/martinwitt/laughing_train/ChangelogPrinter.java b/github-bot/src/main/java/io/github/martinwitt/laughing_train/ChangelogPrinter.java index 73f181918..859305098 100644 --- a/github-bot/src/main/java/io/github/martinwitt/laughing_train/ChangelogPrinter.java +++ b/github-bot/src/main/java/io/github/martinwitt/laughing_train/ChangelogPrinter.java @@ -52,7 +52,7 @@ private String toYaml(AnalyzerResult analyzerResult) { public String printRepairedIssues(Collection changes) { StringBuilder sb = new StringBuilder(); sb.append("# Repairing Code Style Issues\n"); - sb.append(""); + sb.append("\n"); changes.stream().map(Change::getBadSmell).distinct().forEach(v -> sb.append( "## " + v.getName().asText() + "\n") .append(v.getDescription().asMarkdown())