From 86fff9fb2dd90076c3fcb02de8ef1bfbd9aa4e00 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Wed, 6 Dec 2023 18:59:37 +0100 Subject: [PATCH 01/12] Added lib folder to gitignore to ignore the Groovy SDK Signed-off-by: nikomall34 --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 45b766bb..d9c0a456 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,6 @@ bin/ # MacOS .DS_Store + +# Groovy SDK +lib From d4ab3e28da1761d265db11a8622471fc369bb6bc Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Wed, 6 Dec 2023 19:00:57 +0100 Subject: [PATCH 02/12] Fixed License in the .bat files and some files for fixed by pre-commit --- .github/linters/.groovylintrc.json | 28 +++++++++---------- .github/linters/.yaml-lint.yml | 1 - .github/workflows/override-build-and-test.yml | 11 ++++---- .../.gitattributes | 1 - pitmutationmate-override-plugin/gradlew.bat | 6 ++-- pitmutationmate/gradlew.bat | 6 ++-- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/linters/.groovylintrc.json b/.github/linters/.groovylintrc.json index 8e6da8f5..052999bd 100644 --- a/.github/linters/.groovylintrc.json +++ b/.github/linters/.groovylintrc.json @@ -1,17 +1,17 @@ { - "extends": "recommended", - "rules": { - "BlankLineBeforePackage": { - "enabled": false - }, - "JUnitPublicNonTestMethod": { - "enabled": false - }, - "MethodName": { - "enabled": false - }, - "CatchException": { - "enabled": false - } + "extends": "recommended", + "rules": { + "BlankLineBeforePackage": { + "enabled": false + }, + "JUnitPublicNonTestMethod": { + "enabled": false + }, + "MethodName": { + "enabled": false + }, + "CatchException": { + "enabled": false } + } } diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index 8b72b2df..382f7241 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -61,4 +61,3 @@ rules: new-lines: type: unix trailing-spaces: disable - diff --git a/.github/workflows/override-build-and-test.yml b/.github/workflows/override-build-and-test.yml index f5b9d240..e3ee8485 100644 --- a/.github/workflows/override-build-and-test.yml +++ b/.github/workflows/override-build-and-test.yml @@ -19,15 +19,14 @@ jobs: with: distribution: temurin java-version: 11 - + - name: Setup Gradle uses: gradle/gradle-build-action@v2 - name: Build with Gradle run: ./gradlew build --no-daemon - working-directory: 'pitmutationmate-override-plugin' - - - name: Run Tests - run: ./gradlew test --no-daemon - working-directory: 'pitmutationmate-override-plugin' + working-directory: "pitmutationmate-override-plugin" + - name: Run Tests + run: ./gradlew test --no-daemon + working-directory: "pitmutationmate-override-plugin" diff --git a/pitmutationmate-override-plugin/.gitattributes b/pitmutationmate-override-plugin/.gitattributes index e6446a23..fa392de8 100644 --- a/pitmutationmate-override-plugin/.gitattributes +++ b/pitmutationmate-override-plugin/.gitattributes @@ -10,4 +10,3 @@ # These are Windows script files and should use crlf *.bat text eol=crlf - diff --git a/pitmutationmate-override-plugin/gradlew.bat b/pitmutationmate-override-plugin/gradlew.bat index f145ab43..093fe93a 100644 --- a/pitmutationmate-override-plugin/gradlew.bat +++ b/pitmutationmate-override-plugin/gradlew.bat @@ -1,6 +1,6 @@ -REM SPDX-FileCopyrightText: the original authors -REM -REM SPDX-License-Identifier: Apache-2.0 +@rem SPDX-FileCopyrightText: the original authors +@rem +@rem SPDX-License-Identifier: Apache-2.0 @rem @rem Copyright 2015 the original author or authors. diff --git a/pitmutationmate/gradlew.bat b/pitmutationmate/gradlew.bat index 7b543672..3bdc449b 100644 --- a/pitmutationmate/gradlew.bat +++ b/pitmutationmate/gradlew.bat @@ -1,6 +1,6 @@ -REM SPDX-FileCopyrightText: the original authors -REM -REM SPDX-License-Identifier: Apache-2.0 +@rem SPDX-FileCopyrightText: the original authors +@rem +@rem SPDX-License-Identifier: Apache-2.0 @rem Copyright 2015 the original author or authors. @rem From 1f61646ba788b615f80a1792e3234911cbd99c38 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:08:03 +0100 Subject: [PATCH 03/12] Updated the Sandbox-Intellij Version to 2023.1 because of the implementation of ProjectActivity. And I deleted a conflicting kotlin dependency Signed-off-by: nikomall34 --- pitmutationmate/build.gradle.kts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pitmutationmate/build.gradle.kts b/pitmutationmate/build.gradle.kts index 31993cbf..188c5647 100644 --- a/pitmutationmate/build.gradle.kts +++ b/pitmutationmate/build.gradle.kts @@ -22,7 +22,6 @@ dependencies { implementation("org.jfree:jfreechart:1.0.19") // https://mvnrepository.com/artifact/jfree/jcommon implementation("org.jfree:jcommon:1.0.24") - implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") } group = "com.amos.pitmutationmate" @@ -35,9 +34,8 @@ repositories { // Configure Gradle IntelliJ Plugin // Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html intellij { - version.set("2022.2.5") + version.set("2023.1") type.set("IC") // Target IDE Platform - plugins.set(listOf("org.jetbrains.kotlin", "com.intellij.java")) } From a60363ab544e95656d312a8680ead98e615b4a2e Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:12:19 +0100 Subject: [PATCH 04/12] Updated the UdpMessagingServer so that the Balloon Message disappears after 6 seconds Signed-off-by: nikomall34 --- .../services/UdpMessagingServer.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt index 8bb4b335..56c7b86d 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt @@ -8,9 +8,9 @@ import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.project.Project import com.intellij.openapi.ui.MessageType import com.intellij.openapi.wm.ToolWindowManager -import org.jetbrains.kotlin.idea.gradleTooling.get import java.net.DatagramPacket import java.net.DatagramSocket +import java.util.* /** * A simple UDP server that listens on a given port and prints the received messages. @@ -65,11 +65,21 @@ class UdpMessagingServer(private val project: Project) { if (overrideClassFQN != null && message.contains(overrideClassFQN)) { // class was successfully overridden. Notify the user - ToolWindowManager.getInstance(project).notifyByBalloon( - "Pitest Result", + val proj = this.project + ToolWindowManager.getInstance(proj).notifyByBalloon( + "Pitest", MessageType.INFO, "

Successfully applied pitest target class

$overrideClassFQN.

" ) + + val timer = Timer(true); + timer.schedule(object : TimerTask() { + override fun run() { + ToolWindowManager.getInstance(proj).getToolWindowBalloon("Pitest")?.hide() + timer.cancel() + } + + }, 6000L) } } } From dfb004ba33671b1386a1dacbfd50f4d347078f6e Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:18:41 +0100 Subject: [PATCH 05/12] Added a groovy and a kotlin parser to parse the build.gradle and the build.gradle.kts files Signed-off-by: nikomall34 --- .../PluginCheck/PluginCheckerGroovy.kt | 30 ++++++++++++++++ .../PluginCheck/PluginCheckerKotlin.kt | 35 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt create mode 100644 pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt new file mode 100644 index 00000000..8cc2fc09 --- /dev/null +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +package com.amos.pitmutationmate.pitmutationmate.PluginCheck + +import org.codehaus.groovy.ast.CodeVisitorSupport +import org.codehaus.groovy.ast.expr.MethodCallExpression + +class PluginCheckerGroovy : CodeVisitorSupport() { + + var pitestPluginAvailable = false + var companionPluginAvailable = false + + override fun visitMethodCallExpression(call: MethodCallExpression?) { + val method = call?.methodAsString + if(method.equals("plugins") || method.equals("apply") || method.equals("version")){ + super.visitMethodCallExpression(call) + } else if(method.equals("id")){ + if (call != null) { + val pluginName = call.arguments.text + if(pluginName.contains("pitest")){ + pitestPluginAvailable = true + } + if(pluginName.contains("io.github.amosproj.pitmutationmate.override")){ + companionPluginAvailable = true + } + } + } + } +} diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt new file mode 100644 index 00000000..1710eabd --- /dev/null +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +package com.amos.pitmutationmate.pitmutationmate.PluginCheck + + +import org.jetbrains.kotlin.idea.structuralsearch.visitor.KotlinRecursiveElementVisitor +import org.jetbrains.kotlin.psi.KtCallExpression + + +class PluginCheckerKotlin : KotlinRecursiveElementVisitor() { + + var pitestPluginAvailable = false + var companionPluginAvailable = false + + override fun visitCallExpression(expression: KtCallExpression) { + val method = expression.calleeExpression?.text + if(method.equals("plugins")){ + expression.acceptChildren(this) + } + if(method.equals("id")){ + if(expression.valueArgumentList != null) { + for (arg in expression.valueArgumentList!!.arguments) { + val pluginName = arg.text + if(pluginName.contains("pitest")){ + pitestPluginAvailable = true + } + if(pluginName.contains("io.github.amosproj.pitmutationmate.override")){ + companionPluginAvailable = true + } + } + } + } + } +} From a2e0a29da96fb2047ef4e9f1602b9938d3a21ad8 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:20:08 +0100 Subject: [PATCH 06/12] Implemented the Startup Activity so that the two parsers are triggered in the background after the project was opened Signed-off-by: nikomall34 --- .../PluginCheck/StartupPluginChecker.kt | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt new file mode 100644 index 00000000..ef28954a --- /dev/null +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +package com.amos.pitmutationmate.pitmutationmate.PluginCheck + +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.project.Project +import com.intellij.openapi.startup.ProjectActivity +import com.intellij.openapi.ui.Messages +import com.intellij.openapi.vfs.LocalFileSystem +import com.intellij.psi.PsiManager +import org.apache.commons.io.IOUtils +import org.codehaus.groovy.ast.builder.AstBuilder +import java.io.File +import java.io.FileInputStream + +class StartupPluginChecker : ProjectActivity { + + override suspend fun execute(project: Project) { + ApplicationManager.getApplication().invokeLater { + checkGroovyBuildFile(project) + checkKotlinBuildFile(project) + } + } + + private fun checkKotlinBuildFile(project: Project) { + val buildFileName = "build.gradle.kts" + val kotlinBuildFile = File(project.basePath + "/$buildFileName") + if(kotlinBuildFile.exists()) { + val virtualFile = LocalFileSystem.getInstance().findFileByIoFile(kotlinBuildFile) + if (virtualFile != null) { + val psiFile = PsiManager.getInstance(project).findFile(virtualFile) + val pluginCheckerKotlin = PluginCheckerKotlin() + psiFile?.node?.psi?.accept(pluginCheckerKotlin) + val pitestPluginText = "id(\"info.solidsoft.pitest\") version \"1.15.0\"" + val companionPluginText = "id(\"io.github.amosproj.pitmutationmate.override\") version \"1.0\"" + throwErrorMessage(pluginCheckerKotlin.pitestPluginAvailable, + pluginCheckerKotlin.companionPluginAvailable, + buildFileName, + project, + pitestPluginText, + companionPluginText) + } + } + } + + private fun checkGroovyBuildFile(project: Project) { + val buildFileName = "build.gradle" + val groovyBuildFile = File(project.basePath + "/$buildFileName") + if(groovyBuildFile.exists()) { + val builder = AstBuilder() + val nodes = builder.buildFromString(IOUtils.toString(FileInputStream(groovyBuildFile), "UTF-8")) + val pluginCheckerGroovy = PluginCheckerGroovy() + for(node in nodes) { + node.visit(pluginCheckerGroovy) + } + val pitestPluginText = "id 'info.solidsoft.pitest' version '1.15.0'" + val companionPluginText = "id 'io.github.amosproj.pitmutationmate.override' version '1.0'" + throwErrorMessage(pluginCheckerGroovy.pitestPluginAvailable, + pluginCheckerGroovy.companionPluginAvailable, + buildFileName, + project, + pitestPluginText, + companionPluginText) + } + } + + private fun throwErrorMessage( + pitestPluginAvailable: Boolean, + companionPluginAvailable: Boolean, + buildFileName: String, + project: Project, + pitestPluginText: String, + companionPluginText: String + ) { + var errorMessage = "" + if (!pitestPluginAvailable) { + errorMessage += String.format( + ERROR_MESSAGE_PITEST_PLUGIN_MISSING, + buildFileName, + pitestPluginText + ) + } + if (!companionPluginAvailable) { + errorMessage += String.format( + ERROR_MESSAGE_COMPANION_PLUGIN_MISSING, + buildFileName, + companionPluginText + ) + } + if (errorMessage.isNotEmpty()) { + Messages.showErrorDialog(project, errorMessage, ERROR_MESSAGE_TITLE) + } + } + + companion object { + private const val ERROR_MESSAGE_TITLE = "Plugins for PITMutationPlugin are missing" + private const val ERROR_MESSAGE_PITEST_PLUGIN_MISSING = "The pitest gradle Plugin is missing.\n" + + "Please add a Gradle Pitest Plugin to the %s file like the following:\n" + + "%s\nAnd see the pitest docs for missing configurations of pitest\n\n" + private const val ERROR_MESSAGE_COMPANION_PLUGIN_MISSING = "The Companion Plugin is missing.\n" + + "Please add the following line to your %s file:\n" + + "%s\n\n" + } +} From 0d6854c869c8ff45552fd494a76b15ce0a1c49ab Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:20:49 +0100 Subject: [PATCH 07/12] Added kotlin plugin dependency and the startup activity to the plugin.xml file Signed-off-by: nikomall34 --- pitmutationmate/src/main/resources/META-INF/plugin.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/pitmutationmate/src/main/resources/META-INF/plugin.xml b/pitmutationmate/src/main/resources/META-INF/plugin.xml index b5b16a4c..14333841 100644 --- a/pitmutationmate/src/main/resources/META-INF/plugin.xml +++ b/pitmutationmate/src/main/resources/META-INF/plugin.xml @@ -25,20 +25,18 @@ com.intellij.java + org.jetbrains.kotlin - - - - - + + Date: Tue, 12 Dec 2023 22:21:36 +0100 Subject: [PATCH 08/12] Added testcases for the groovy parser and some test build scripts Signed-off-by: nikomall34 --- .../pitmutationmate/PluginCeckerTest.kt | 54 +++++++++++++++ .../test_build_scripts/testbuild1.gradle | 42 +++++++++++ .../test_build_scripts/testbuild1.gradle.kts | 52 ++++++++++++++ .../test_build_scripts/testbuild2.gradle | 50 ++++++++++++++ .../test_build_scripts/testbuild2.gradle.kts | 69 +++++++++++++++++++ .../test_build_scripts/testbuild3.gradle | 51 ++++++++++++++ .../test_build_scripts/testbuild3.gradle.kts | 42 +++++++++++ .../test_build_scripts/testbuild4.gradle | 69 +++++++++++++++++++ 8 files changed, 429 insertions(+) create mode 100644 pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle.kts create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle.kts create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle.kts create mode 100644 pitmutationmate/src/test/resources/test_build_scripts/testbuild4.gradle diff --git a/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt b/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt new file mode 100644 index 00000000..ddaa39fc --- /dev/null +++ b/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +package com.amos.pitmutationmate.pitmutationmate + +import com.amos.pitmutationmate.pitmutationmate.PluginCheck.PluginCheckerGroovy +import org.apache.commons.io.IOUtils +import org.codehaus.groovy.ast.builder.AstBuilder +import org.junit.jupiter.api.Test +import java.io.File +import java.io.FileInputStream + +class PluginCeckerTest { + + private fun runPluginCheckerForTestFile(testFile: String): PluginCheckerGroovy { + val builder = AstBuilder() + val testFile = File("src/test/resources/test_build_scripts/$testFile") + val nodes = builder.buildFromString(IOUtils.toString( FileInputStream(testFile), "UTF-8")) + val pluginCheck = PluginCheckerGroovy() + for(node in nodes) { + node.visit(pluginCheck) + } + return pluginCheck + } + + @Test + fun checkTestBuildFile1_groovy() { + val pluginCheck = runPluginCheckerForTestFile("testbuild1.gradle") + assert(pluginCheck.pitestPluginAvailable) + assert(pluginCheck.companionPluginAvailable) + } + + @Test + fun checkTestBuildFile2_groovy() { + val pluginCheck = runPluginCheckerForTestFile("testbuild2.gradle") + assert(!pluginCheck.pitestPluginAvailable) + assert(pluginCheck.companionPluginAvailable) + } + + @Test + fun checkTestBuildFile3_groovy() { + val pluginCheck = runPluginCheckerForTestFile("testbuild3.gradle") + assert(pluginCheck.pitestPluginAvailable) + assert(!pluginCheck.companionPluginAvailable) + } + + @Test + fun checkTestBuildFile4_groovy() { + val pluginCheck = runPluginCheckerForTestFile("testbuild4.gradle") + assert(!pluginCheck.pitestPluginAvailable) + assert(!pluginCheck.companionPluginAvailable) + } + +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle b/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle new file mode 100644 index 00000000..2b0567bf --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id 'java' + id 'info.solidsoft.pitest' version '1.15.0' + //id 'com.groupcdg.pitest.github' version '1.0.5' + id 'io.github.amosproj.pitmutationmate.override' version '1.0' +} + +repositories { + mavenLocal() + mavenCentral() +} + +def mockitoVersion = '5.2.0' + +dependencies { + testImplementation platform('org.junit:junit-bom:5.8.1') + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testImplementation 'org.junit.jupiter:junit-jupiter-params' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testImplementation 'org.assertj:assertj-core:3.24.2' + testImplementation "org.mockito:mockito-inline:$mockitoVersion" + testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" + implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.0' + pitest 'org.junit.platform:junit-platform-launcher' + //pitest 'com.groupcdg:pitest-git-plugin:1.1.2' +} + +tasks.test { + useJUnitPlatform() +} + +pitest { + pitestVersion = '1.15.2' + targetClasses = ['de.esolutions.*'] as Set + junit5PluginVersion = '1.2.1' + outputFormats = ['XML', 'HTML'] as Set +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle.kts b/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle.kts new file mode 100644 index 00000000..634864c7 --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild1.gradle.kts @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id("java") + id("info.solidsoft.pitest") version "1.15.0" + id ("com.groupcdg.pitest.github") version "1.0.5" + id("io.github.amosproj.pitmutationmate.override") version "1.0" +} + +repositories { + mavenCentral() +} + +val mockitoVersion = "5.2.0" + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.8.1")) + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.junit.jupiter:junit-jupiter-params") + testImplementation("org.junit.jupiter:junit-jupiter") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testImplementation("org.assertj:assertj-core:3.24.2") + testImplementation("org.mockito:mockito-inline:$mockitoVersion") + testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion") + + pitest("org.junit.platform:junit-platform-launcher") + pitest("com.groupcdg:pitest-git-plugin:1.1.2") +} + +tasks.test { + useJUnitPlatform() +} + +pitest { + mutators.set(setOf("STRONGER")) + pitestVersion.set("1.15.2") + //targetClasses.set(setOf("de.pfoerd.example.pitest.coffeemachine.service.CoffeeService")) + targetTests.set(setOf("de.pfoerd.example.*Test")) + targetClasses.set(setOf("de.pfoerd.example.*")) + junit5PluginVersion.set("1.2.1") + //features.add("+GIT(from[HEAD~1])") + outputFormats.set(setOf("gitci", "HTML", "XML")) + //features.add("+GIT(from[-EMPTY-])") + verbose.set(false) + //debug.set(false) +} + +pitestGithub { + deleteOldSummaries.set(true) +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle b/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle new file mode 100644 index 00000000..a8d4c3d1 --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle @@ -0,0 +1,50 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id 'java' + id 'io.github.amosproj.pitmutationmate.override' version '1.0' +} + +repositories { + mavenCentral() +} + +def mockitoVersion = '5.2.0' + +dependencies { + testImplementation platform('org.junit:junit-bom:5.8.1') + testImplementation 'org.junit.jupiter:junit-jupiter-api' + testImplementation 'org.junit.jupiter:junit-jupiter-params' + testImplementation 'org.junit.jupiter:junit-jupiter' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + testImplementation 'org.assertj:assertj-core:3.24.2' + testImplementation "org.mockito:mockito-inline:$mockitoVersion" + testImplementation "org.mockito:mockito-junit-jupiter:$mockitoVersion" + + pitest 'org.junit.platform:junit-platform-launcher' + pitest 'com.groupcdg:pitest-git-plugin:1.1.2' +} + +tasks.test { + useJUnitPlatform() +} + +pitest { + mutators = ['STRONGER'] as Set + pitestVersion = '1.15.2' + //targetClasses = ['de.pfoerd.example.pitest.coffeemachine.service.CoffeeService'] as Set + targetTests = ['de.pfoerd.example.*Test'] as Set + targetClasses = ['de.pfoerd.example.*'] as Set + junit5PluginVersion = '1.2.1' + //features << '+GIT(from[HEAD~1])' + outputFormats = ['gitci', 'HTML', 'XML'] as Set + //features << '+GIT(from[-EMPTY-])' + verbose = false + //debug = false +} + +pitestGithub { + deleteOldSummaries = true +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle.kts b/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle.kts new file mode 100644 index 00000000..dd29f99d --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild2.gradle.kts @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id("java") + id("org.jetbrains.kotlin.jvm") version "1.9.0" + id("org.jetbrains.intellij") version "1.15.0" + id("info.solidsoft.pitest") version "1.15.0" + //kotlin("jvm") version "1.5.31" +} +tasks.test { + useJUnitPlatform() +} + +dependencies { + implementation("org.pitest:pitest-command-line:1.7.0") + implementation("org.junit.jupiter:junit-jupiter:5.8.1") + implementation("org.junit.jupiter:junit-jupiter:5.8.1") + testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") + // https://mvnrepository.com/artifact/org.jfree/jfreechart + implementation("org.jfree:jfreechart:1.0.19") + // https://mvnrepository.com/artifact/jfree/jcommon + implementation("org.jfree:jcommon:1.0.24") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") + implementation(gradleApi()) +} + +group = "com.amos.pitmutationmate" +version = "1.0-SNAPSHOT" + +repositories { + mavenCentral() +} + +// Configure Gradle IntelliJ Plugin +// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html +intellij { + version.set("2023.1.3") + type.set("IC") // Target IDE Platform + + plugins.set(listOf("org.jetbrains.kotlin", "com.intellij.java")) +} + +tasks { + // Set the JVM compatibility versions + withType { + sourceCompatibility = "17" + targetCompatibility = "17" + } + withType { + kotlinOptions.jvmTarget = "17" + } + + patchPluginXml { + sinceBuild.set("222") + untilBuild.set("232.*") + } + + signPlugin { + certificateChain.set(System.getenv("CERTIFICATE_CHAIN")) + privateKey.set(System.getenv("PRIVATE_KEY")) + password.set(System.getenv("PRIVATE_KEY_PASSWORD")) + } + + publishPlugin { + token.set(System.getenv("PUBLISH_TOKEN")) + } +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle b/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle new file mode 100644 index 00000000..4b9d192b --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +//import org.gradle.api.tasks.testing.logging.TestLogEvent +//import pl.droidsonroids.gradle.pitest.PitestPlugin.PITEST_CONFIGURATION_NAME +//import pl.droidsonroids.gradle.pitest.PitestPluginExtension + +plugins { + id 'com.android.application' version '7.1.3' apply false + id 'com.android.library' version '7.1.3' apply false + id 'org.jetbrains.kotlin.android' version '1.8.21' apply false + id 'pl.droidsonroids.pitest' version '0.2.12' apply false +} + +buildscript { + dependencies { + classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2' + } +} + +subprojects { + tasks.withType(Test) { + useJUnitPlatform() + testLogging.events = [TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED] + } + + apply plugin: 'pl.droidsonroids.pitest' + + /*buildscript { + dependencies.add( + PITEST_CONFIGURATION_NAME, + 'com.groupcdg.pitest:pitest-kotlin-plugin:1.1.3' + ) + dependencies.add( + PITEST_CONFIGURATION_NAME, + 'com.groupcdg.pitest:pitest-accelerator-junit5:1.0.6' + ) + dependencies.add(PITEST_CONFIGURATION_NAME, 'com.groupcdg.arcmutate:base:1.2.2') + dependencies.add(PITEST_CONFIGURATION_NAME, 'com.groupcdg:pitest-git-plugin:1.1.2') + }*/ + + extensions.findByType(PitestPluginExtension)?.apply { + ['de.eso.*'].also { targets -> + targetClasses = targets + targetTests = targets.collect { "${it}Test" } + } + junit5PluginVersion = '1.0.0' + pitestVersion = '1.15.1' + mutators = ['STRONGER'/*, 'EXTENDED'*/].toSet() + } +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle.kts b/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle.kts new file mode 100644 index 00000000..a0acdb93 --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild3.gradle.kts @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id("java", "kotlin") + id("info.solidsoft.pitest") version "1.15.0" apply true + //id("com.groupcdg.pitest.github") version "1.0.5" + id("io.github.amosproj.pitmutationmate.override") version "1.0" +} + +repositories { + mavenLocal() + mavenCentral() +} + +val mockitoVersion = "5.2.0" + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.8.1")) + testImplementation("org.junit.jupiter:junit-jupiter-api") + testImplementation("org.junit.jupiter:junit-jupiter-params") + testImplementation("org.junit.jupiter:junit-jupiter") + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + testImplementation("org.assertj:assertj-core:3.24.2") + testImplementation("org.mockito:mockito-inline:$mockitoVersion") + testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion") + implementation("org.jetbrains.kotlin:kotlin-stdlib:1.9.0") + pitest("org.junit.platform:junit-platform-launcher") + //pitest("com.groupcdg:pitest-git-plugin:1.1.2") +} + +tasks.test { + useJUnitPlatform() +} + +pitest { + pitestVersion.set("1.15.2") + targetClasses.set(setOf("de.esolutions.*")) + junit5PluginVersion.set("1.2.1") + outputFormats.set(setOf("XML", "HTML")) +} diff --git a/pitmutationmate/src/test/resources/test_build_scripts/testbuild4.gradle b/pitmutationmate/src/test/resources/test_build_scripts/testbuild4.gradle new file mode 100644 index 00000000..3985a6e1 --- /dev/null +++ b/pitmutationmate/src/test/resources/test_build_scripts/testbuild4.gradle @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT +// SPDX-FileCopyrightText: 2023 + +plugins { + id 'java' + id 'org.jetbrains.kotlin.jvm' version '1.9.0' + id 'org.jetbrains.intellij' version '1.15.0' + //id 'info.solidsoft.pitest' version '1.15.0' +} + +tasks.test { + useJUnitPlatform() +} + +dependencies { + implementation 'org.pitest:pitest-command-line:1.7.0' + implementation 'org.junit.jupiter:junit-jupiter:5.8.1' + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' + implementation 'org.jfree:jfreechart:1.0.19' + implementation 'org.jfree:jcommon:1.0.24' + //implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.21' + //implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21' + //implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.9.21' + //implementation 'org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.9.21' + //implementation gradleApi() +} + +group = 'com.amos.pitmutationmate' +version = '1.0-SNAPSHOT' + +repositories { + mavenCentral() +} + +// Configure Gradle IntelliJ Plugin +// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html +intellij { + version.set('2023.2') + type.set('IC') // Target IDE Platform + + plugins.set(['org.jetbrains.kotlin', 'com.intellij.java']) +} + +tasks { + // Set the JVM compatibility versions + withType(JavaCompile) { + sourceCompatibility = '17' + targetCompatibility = '17' + } + withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { + kotlinOptions.jvmTarget = '17' + } + + patchPluginXml { + sinceBuild.set('222') + untilBuild.set('232.*') + } + + signPlugin { + certificateChain.set(System.getenv('CERTIFICATE_CHAIN')) + privateKey.set(System.getenv('PRIVATE_KEY')) + password.set(System.getenv('PRIVATE_KEY_PASSWORD')) + } + + publishPlugin { + token.set(System.getenv('PUBLISH_TOKEN')) + } +} From c4a6a90cbbe26634ea85b95cfbd3e13655097a51 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Tue, 12 Dec 2023 22:50:31 +0100 Subject: [PATCH 09/12] fixed linting and package name Signed-off-by: nikomall34 --- .../PluginCheckerGroovy.kt | 10 +++---- .../PluginCheckerKotlin.kt | 12 ++++----- .../StartupPluginChecker.kt | 26 ++++++++++++------- .../services/UdpMessagingServer.kt | 18 +++++++------ .../src/main/resources/META-INF/plugin.xml | 2 +- .../pitmutationmate/PluginCeckerTest.kt | 8 +++--- 6 files changed, 42 insertions(+), 34 deletions(-) rename pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/{PluginCheck => plugincheck}/PluginCheckerGroovy.kt (80%) rename pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/{PluginCheck => plugincheck}/PluginCheckerKotlin.kt (81%) rename pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/{PluginCheck => plugincheck}/StartupPluginChecker.kt (80%) diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt similarity index 80% rename from pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt rename to pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt index 8cc2fc09..54761491 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerGroovy.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2023 -package com.amos.pitmutationmate.pitmutationmate.PluginCheck +package com.amos.pitmutationmate.pitmutationmate.plugincheck import org.codehaus.groovy.ast.CodeVisitorSupport import org.codehaus.groovy.ast.expr.MethodCallExpression @@ -13,15 +13,15 @@ class PluginCheckerGroovy : CodeVisitorSupport() { override fun visitMethodCallExpression(call: MethodCallExpression?) { val method = call?.methodAsString - if(method.equals("plugins") || method.equals("apply") || method.equals("version")){ + if(method.equals("plugins") || method.equals("apply") || method.equals("version")) { super.visitMethodCallExpression(call) - } else if(method.equals("id")){ + } else if(method.equals("id")) { if (call != null) { val pluginName = call.arguments.text - if(pluginName.contains("pitest")){ + if(pluginName.contains("pitest")) { pitestPluginAvailable = true } - if(pluginName.contains("io.github.amosproj.pitmutationmate.override")){ + if(pluginName.contains("io.github.amosproj.pitmutationmate.override")) { companionPluginAvailable = true } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt similarity index 81% rename from pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt rename to pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt index 1710eabd..315158e9 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/PluginCheckerKotlin.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt @@ -1,13 +1,11 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2023 -package com.amos.pitmutationmate.pitmutationmate.PluginCheck - +package com.amos.pitmutationmate.pitmutationmate.plugincheck import org.jetbrains.kotlin.idea.structuralsearch.visitor.KotlinRecursiveElementVisitor import org.jetbrains.kotlin.psi.KtCallExpression - class PluginCheckerKotlin : KotlinRecursiveElementVisitor() { var pitestPluginAvailable = false @@ -15,17 +13,17 @@ class PluginCheckerKotlin : KotlinRecursiveElementVisitor() { override fun visitCallExpression(expression: KtCallExpression) { val method = expression.calleeExpression?.text - if(method.equals("plugins")){ + if(method.equals("plugins")) { expression.acceptChildren(this) } - if(method.equals("id")){ + if(method.equals("id")) { if(expression.valueArgumentList != null) { for (arg in expression.valueArgumentList!!.arguments) { val pluginName = arg.text - if(pluginName.contains("pitest")){ + if(pluginName.contains("pitest")) { pitestPluginAvailable = true } - if(pluginName.contains("io.github.amosproj.pitmutationmate.override")){ + if(pluginName.contains("io.github.amosproj.pitmutationmate.override")) { companionPluginAvailable = true } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt similarity index 80% rename from pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt rename to pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt index ef28954a..8f6b2180 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCheck/StartupPluginChecker.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT // SPDX-FileCopyrightText: 2023 -package com.amos.pitmutationmate.pitmutationmate.PluginCheck +package com.amos.pitmutationmate.pitmutationmate.plugincheck import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.project.Project @@ -34,12 +34,14 @@ class StartupPluginChecker : ProjectActivity { psiFile?.node?.psi?.accept(pluginCheckerKotlin) val pitestPluginText = "id(\"info.solidsoft.pitest\") version \"1.15.0\"" val companionPluginText = "id(\"io.github.amosproj.pitmutationmate.override\") version \"1.0\"" - throwErrorMessage(pluginCheckerKotlin.pitestPluginAvailable, + throwErrorMessage( + pluginCheckerKotlin.pitestPluginAvailable, pluginCheckerKotlin.companionPluginAvailable, buildFileName, project, pitestPluginText, - companionPluginText) + companionPluginText + ) } } } @@ -49,19 +51,24 @@ class StartupPluginChecker : ProjectActivity { val groovyBuildFile = File(project.basePath + "/$buildFileName") if(groovyBuildFile.exists()) { val builder = AstBuilder() - val nodes = builder.buildFromString(IOUtils.toString(FileInputStream(groovyBuildFile), "UTF-8")) + val nodes = builder.buildFromString( + IOUtils.toString(FileInputStream(groovyBuildFile), + "UTF-8") + ) val pluginCheckerGroovy = PluginCheckerGroovy() for(node in nodes) { node.visit(pluginCheckerGroovy) } val pitestPluginText = "id 'info.solidsoft.pitest' version '1.15.0'" val companionPluginText = "id 'io.github.amosproj.pitmutationmate.override' version '1.0'" - throwErrorMessage(pluginCheckerGroovy.pitestPluginAvailable, + throwErrorMessage( + pluginCheckerGroovy.pitestPluginAvailable, pluginCheckerGroovy.companionPluginAvailable, buildFileName, project, pitestPluginText, - companionPluginText) + companionPluginText + ) } } @@ -96,10 +103,9 @@ class StartupPluginChecker : ProjectActivity { companion object { private const val ERROR_MESSAGE_TITLE = "Plugins for PITMutationPlugin are missing" private const val ERROR_MESSAGE_PITEST_PLUGIN_MISSING = "The pitest gradle Plugin is missing.\n" + - "Please add a Gradle Pitest Plugin to the %s file like the following:\n" + - "%s\nAnd see the pitest docs for missing configurations of pitest\n\n" + "Please add a Gradle Pitest Plugin to the %s file like the following:\n" + + "%s\nAnd see the pitest docs for missing configurations of pitest\n\n" private const val ERROR_MESSAGE_COMPANION_PLUGIN_MISSING = "The Companion Plugin is missing.\n" + - "Please add the following line to your %s file:\n" + - "%s\n\n" + "Please add the following line to your %s file:\n%s\n\n" } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt index 56c7b86d..65c62262 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt @@ -72,14 +72,16 @@ class UdpMessagingServer(private val project: Project) { "

Successfully applied pitest target class

$overrideClassFQN.

" ) - val timer = Timer(true); - timer.schedule(object : TimerTask() { - override fun run() { - ToolWindowManager.getInstance(proj).getToolWindowBalloon("Pitest")?.hide() - timer.cancel() - } - - }, 6000L) + val timer = Timer(true) + timer.schedule( + object : TimerTask() { + override fun run() { + ToolWindowManager.getInstance(proj).getToolWindowBalloon("Pitest")?.hide() + timer.cancel() + } + }, + 6000L + ) } } } diff --git a/pitmutationmate/src/main/resources/META-INF/plugin.xml b/pitmutationmate/src/main/resources/META-INF/plugin.xml index 14333841..e2590fee 100644 --- a/pitmutationmate/src/main/resources/META-INF/plugin.xml +++ b/pitmutationmate/src/main/resources/META-INF/plugin.xml @@ -36,7 +36,7 @@ - + Date: Tue, 12 Dec 2023 22:59:09 +0100 Subject: [PATCH 10/12] fixed linting Signed-off-by: nikomall34 --- .../plugincheck/PluginCheckerGroovy.kt | 8 ++++---- .../plugincheck/PluginCheckerKotlin.kt | 10 +++++----- .../plugincheck/StartupPluginChecker.kt | 18 ++++++++++-------- .../pitmutationmate/PluginCeckerTest.kt | 8 +++++--- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt index 54761491..4d18d060 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerGroovy.kt @@ -13,15 +13,15 @@ class PluginCheckerGroovy : CodeVisitorSupport() { override fun visitMethodCallExpression(call: MethodCallExpression?) { val method = call?.methodAsString - if(method.equals("plugins") || method.equals("apply") || method.equals("version")) { + if (method.equals("plugins") || method.equals("apply") || method.equals("version")) { super.visitMethodCallExpression(call) - } else if(method.equals("id")) { + } else if (method.equals("id")) { if (call != null) { val pluginName = call.arguments.text - if(pluginName.contains("pitest")) { + if (pluginName.contains("pitest")) { pitestPluginAvailable = true } - if(pluginName.contains("io.github.amosproj.pitmutationmate.override")) { + if (pluginName.contains("io.github.amosproj.pitmutationmate.override")) { companionPluginAvailable = true } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt index 315158e9..3446b2db 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/PluginCheckerKotlin.kt @@ -13,17 +13,17 @@ class PluginCheckerKotlin : KotlinRecursiveElementVisitor() { override fun visitCallExpression(expression: KtCallExpression) { val method = expression.calleeExpression?.text - if(method.equals("plugins")) { + if (method.equals("plugins")) { expression.acceptChildren(this) } - if(method.equals("id")) { - if(expression.valueArgumentList != null) { + if (method.equals("id")) { + if (expression.valueArgumentList != null) { for (arg in expression.valueArgumentList!!.arguments) { val pluginName = arg.text - if(pluginName.contains("pitest")) { + if (pluginName.contains("pitest")) { pitestPluginAvailable = true } - if(pluginName.contains("io.github.amosproj.pitmutationmate.override")) { + if (pluginName.contains("io.github.amosproj.pitmutationmate.override")) { companionPluginAvailable = true } } diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt index 8f6b2180..9f4a4235 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt @@ -26,7 +26,7 @@ class StartupPluginChecker : ProjectActivity { private fun checkKotlinBuildFile(project: Project) { val buildFileName = "build.gradle.kts" val kotlinBuildFile = File(project.basePath + "/$buildFileName") - if(kotlinBuildFile.exists()) { + if (kotlinBuildFile.exists()) { val virtualFile = LocalFileSystem.getInstance().findFileByIoFile(kotlinBuildFile) if (virtualFile != null) { val psiFile = PsiManager.getInstance(project).findFile(virtualFile) @@ -49,14 +49,16 @@ class StartupPluginChecker : ProjectActivity { private fun checkGroovyBuildFile(project: Project) { val buildFileName = "build.gradle" val groovyBuildFile = File(project.basePath + "/$buildFileName") - if(groovyBuildFile.exists()) { + if (groovyBuildFile.exists()) { val builder = AstBuilder() val nodes = builder.buildFromString( - IOUtils.toString(FileInputStream(groovyBuildFile), - "UTF-8") + IOUtils.toString( + FileInputStream(groovyBuildFile), + "UTF-8" + ) ) val pluginCheckerGroovy = PluginCheckerGroovy() - for(node in nodes) { + for (node in nodes) { node.visit(pluginCheckerGroovy) } val pitestPluginText = "id 'info.solidsoft.pitest' version '1.15.0'" @@ -103,9 +105,9 @@ class StartupPluginChecker : ProjectActivity { companion object { private const val ERROR_MESSAGE_TITLE = "Plugins for PITMutationPlugin are missing" private const val ERROR_MESSAGE_PITEST_PLUGIN_MISSING = "The pitest gradle Plugin is missing.\n" + - "Please add a Gradle Pitest Plugin to the %s file like the following:\n" + - "%s\nAnd see the pitest docs for missing configurations of pitest\n\n" + "Please add a Gradle Pitest Plugin to the %s file like the following:\n" + + "%s\nAnd see the pitest docs for missing configurations of pitest\n\n" private const val ERROR_MESSAGE_COMPANION_PLUGIN_MISSING = "The Companion Plugin is missing.\n" + - "Please add the following line to your %s file:\n%s\n\n" + "Please add the following line to your %s file:\n%s\n\n" } } diff --git a/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt b/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt index 5cdad06b..af04921d 100644 --- a/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt +++ b/pitmutationmate/src/test/kotlin/com/amos/pitmutationmate/pitmutationmate/PluginCeckerTest.kt @@ -16,11 +16,13 @@ class PluginCeckerTest { val builder = AstBuilder() val testFile = File("src/test/resources/test_build_scripts/$testFile") val nodes = builder.buildFromString( - IOUtils.toString(FileInputStream(testFile), - "UTF-8") + IOUtils.toString( + FileInputStream(testFile), + "UTF-8" + ) ) val pluginCheck = PluginCheckerGroovy() - for(node in nodes) { + for (node in nodes) { node.visit(pluginCheck) } return pluginCheck From 76dd62dc1a89409da703f9a91068bebbb1360282 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Wed, 13 Dec 2023 10:43:06 +0100 Subject: [PATCH 11/12] Removed the timer for the Balloon in the UDPServer Signed-off-by: nikomall34 --- .../pitmutationmate/services/UdpMessagingServer.kt | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt index 65c62262..d55c4faf 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/services/UdpMessagingServer.kt @@ -65,23 +65,11 @@ class UdpMessagingServer(private val project: Project) { if (overrideClassFQN != null && message.contains(overrideClassFQN)) { // class was successfully overridden. Notify the user - val proj = this.project - ToolWindowManager.getInstance(proj).notifyByBalloon( + ToolWindowManager.getInstance(project).notifyByBalloon( "Pitest", MessageType.INFO, "

Successfully applied pitest target class

$overrideClassFQN.

" ) - - val timer = Timer(true) - timer.schedule( - object : TimerTask() { - override fun run() { - ToolWindowManager.getInstance(proj).getToolWindowBalloon("Pitest")?.hide() - timer.cancel() - } - }, - 6000L - ) } } } From 4b011b6d9b67594816b31e679b276e58ad733415 Mon Sep 17 00:00:00 2001 From: nikomall34 Date: Wed, 13 Dec 2023 10:46:41 +0100 Subject: [PATCH 12/12] Removed explicit version and changed it to x.y.z. Signed-off-by: nikomall34 --- .../pitmutationmate/plugincheck/StartupPluginChecker.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt index 9f4a4235..f5115a80 100644 --- a/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt +++ b/pitmutationmate/src/main/kotlin/com/amos/pitmutationmate/pitmutationmate/plugincheck/StartupPluginChecker.kt @@ -32,8 +32,8 @@ class StartupPluginChecker : ProjectActivity { val psiFile = PsiManager.getInstance(project).findFile(virtualFile) val pluginCheckerKotlin = PluginCheckerKotlin() psiFile?.node?.psi?.accept(pluginCheckerKotlin) - val pitestPluginText = "id(\"info.solidsoft.pitest\") version \"1.15.0\"" - val companionPluginText = "id(\"io.github.amosproj.pitmutationmate.override\") version \"1.0\"" + val pitestPluginText = "id(\"info.solidsoft.pitest\") version \"x.y.z\"" + val companionPluginText = "id(\"io.github.amosproj.pitmutationmate.override\") version \"x.y.z\"" throwErrorMessage( pluginCheckerKotlin.pitestPluginAvailable, pluginCheckerKotlin.companionPluginAvailable, @@ -61,8 +61,8 @@ class StartupPluginChecker : ProjectActivity { for (node in nodes) { node.visit(pluginCheckerGroovy) } - val pitestPluginText = "id 'info.solidsoft.pitest' version '1.15.0'" - val companionPluginText = "id 'io.github.amosproj.pitmutationmate.override' version '1.0'" + val pitestPluginText = "id 'info.solidsoft.pitest' version 'x.y.z'" + val companionPluginText = "id 'io.github.amosproj.pitmutationmate.override' version 'x.y.z'" throwErrorMessage( pluginCheckerGroovy.pitestPluginAvailable, pluginCheckerGroovy.companionPluginAvailable,