From 7acbe7df40914300133ac872f169b9e878192075 Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Wed, 29 Jan 2025 10:04:17 +0100 Subject: [PATCH] chore: add github linting step --- .github/workflows/ci.yml | 7 + .project | 6 + feature/pom.xml | 81 ++-- plugin/.project | 6 + plugin/pom.xml | 6 +- .../eclipse/plugin/html/OssHtmlProvider.java | 34 +- pmd-ruleset.xml | 29 ++ pom.xml | 371 +++++++++--------- target-platform/pom.xml | 3 + tests/pom.xml | 4 + update-site/pom.xml | 97 ++--- 11 files changed, 356 insertions(+), 288 deletions(-) create mode 100644 pmd-ruleset.xml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18141ea4..40928ea2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,6 +36,13 @@ jobs: echo "$sha $fileName" > sha256.txt sha256sum -c sha256.txt + - name: Run PMD + uses: pmd/pmd-github-action@main + with: + rulesets: 'pmd-rulesets.xml' + sourcePath: 'plugin/src/main/java' + analyzeModifiedFilesOnly: true + - name: Build with Maven if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' }} run: ./mvnw clean verify -P sign -DtrimStackTrace=false diff --git a/.project b/.project index a7f3007f..5da59e4c 100644 --- a/.project +++ b/.project @@ -35,6 +35,11 @@ + + net.sourceforge.pmd.eclipse.plugin.pmdBuilder + + + org.eclipse.m2e.core.maven2Nature @@ -42,5 +47,6 @@ org.eclipse.jdt.core.javanature org.eclipse.pde.FeatureNature org.eclipse.pde.UpdateSiteNature + net.sourceforge.pmd.eclipse.plugin.pmdNature diff --git a/feature/pom.xml b/feature/pom.xml index 05a7b3dd..7f074381 100644 --- a/feature/pom.xml +++ b/feature/pom.xml @@ -1,45 +1,48 @@ - 4.0.0 - - io.snyk - parent - 3.0.0-SNAPSHOT - + 4.0.0 + + io.snyk + parent + 3.0.0-SNAPSHOT + - io.snyk.scanner + io.snyk.scanner + + ${project.parent.basedir} + - eclipse-feature + eclipse-feature - - - - org.eclipse.tycho - tycho-source-plugin - ${tycho-version} - - - feature-source - package - - feature-source - - - - - - org.eclipse.tycho - tycho-p2-plugin - - - attach-p2-metadata - package - - p2-metadata - - - - - - + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho-version} + + + feature-source + package + + feature-source + + + + + + org.eclipse.tycho + tycho-p2-plugin + + + attach-p2-metadata + package + + p2-metadata + + + + + + diff --git a/plugin/.project b/plugin/.project index 8b0bb059..8ccae640 100644 --- a/plugin/.project +++ b/plugin/.project @@ -25,10 +25,16 @@ + + net.sourceforge.pmd.eclipse.plugin.pmdBuilder + + + org.eclipse.m2e.core.maven2Nature org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sourceforge.pmd.eclipse.plugin.pmdNature diff --git a/plugin/pom.xml b/plugin/pom.xml index ac37de15..65bb61c7 100644 --- a/plugin/pom.xml +++ b/plugin/pom.xml @@ -8,8 +8,12 @@ 3.0.0-SNAPSHOT + + ${project.parent.basedir} + - io.snyk.eclipse.plugin + + io.snyk.eclipse.plugin https://snyk.io/ide-plugins/ eclipse-plugin diff --git a/plugin/src/main/java/io/snyk/eclipse/plugin/html/OssHtmlProvider.java b/plugin/src/main/java/io/snyk/eclipse/plugin/html/OssHtmlProvider.java index e056b245..95d910f8 100644 --- a/plugin/src/main/java/io/snyk/eclipse/plugin/html/OssHtmlProvider.java +++ b/plugin/src/main/java/io/snyk/eclipse/plugin/html/OssHtmlProvider.java @@ -1,24 +1,22 @@ package io.snyk.eclipse.plugin.html; public class OssHtmlProvider extends BaseHtmlProvider { - private static OssHtmlProvider instance = new OssHtmlProvider(); + private static OssHtmlProvider instance = new OssHtmlProvider(); - public static OssHtmlProvider getInstance() { - synchronized (OssHtmlProvider.class) { - if (instance == null) { - if (instance == null) { - instance = new OssHtmlProvider(); - } - } - } - return instance; - } + public static OssHtmlProvider getInstance() { + synchronized (OssHtmlProvider.class) { + if (instance == null) { + instance = new OssHtmlProvider(); + } + } + return instance; + } - @Override - public String replaceCssVariables(String html) { - html = super.replaceCssVariables(html); - html = html.replace("var(--container-background-color)", - super.getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#F0F0F0")); - return html; - } + @Override + public String replaceCssVariables(String html) { + html = super.replaceCssVariables(html); + html = html.replace("var(--container-background-color)", + super.getColorAsHex("org.eclipse.ui.workbench.DARK_BACKGROUND", "#F0F0F0")); + return html; + } } diff --git a/pmd-ruleset.xml b/pmd-ruleset.xml new file mode 100644 index 00000000..9a782252 --- /dev/null +++ b/pmd-ruleset.xml @@ -0,0 +1,29 @@ + + + + Sensible PMD rules focusing on important code quality issues + + + + + + + + + + + + + + + + + + + + .*/generated/.* + .*/target/.* + diff --git a/pom.xml b/pom.xml index 1ce73859..80abb4be 100644 --- a/pom.xml +++ b/pom.xml @@ -1,191 +1,196 @@ - 4.0.0 - io.snyk - parent - 3.0.0-SNAPSHOT - pom + 4.0.0 + io.snyk + parent + 3.0.0-SNAPSHOT + pom - - 4.0.9 - scm:git:https://github.com/snyk/snyk-eclipse-plugin.git - target-platform - UTF-8 - 17 - 17 - + + 4.0.9 + scm:git:https://github.com/snyk/snyk-eclipse-plugin.git + target-platform + UTF-8 + 17 + 17 + ${project.basedir} + - - target-platform - plugin - feature - tests - update-site - + + target-platform + plugin + feature + tests + update-site + - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.26.0 - - true - true - - - - - check - cpd-check - - verify - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho-version} - true - - - org.eclipse.tycho - target-platform-configuration - ${tycho-version} - - - - ${project.groupId} - ${target-config} - ${project.version} - - - - - win32 - win32 - x86_64 - - - linux - gtk - x86_64 - - - linux - gtk - aarch64 - - - macosx - cocoa - x86_64 - - - macosx - cocoa - aarch64 - - - - - - org.eclipse.tycho - tycho-source-plugin - ${tycho-version} - - - plugin-source - - plugin-source - - - - - - org.eclipse.tycho - tycho-packaging-plugin - - - true - - - - - org.eclipse.tycho.extras - tycho-sourceref-jgit - ${tycho-version} - - - - - - - - org.eclipse.tycho - tycho-packaging-plugin - ${tycho-version} - - - org.eclipse.tycho - tycho-p2-plugin - ${tycho-version} - - - - https://download.eclipse.org/lsp4e/snapshots - - - - - - - - - - - sign - + - - org.apache.maven.plugins - maven-jarsigner-plugin - 3.0.0 - - - sign - package - - sign - - - - - ${project.basedir}/../keystore.jks - snyk - ${env.KEYSTORE_PASS} - - - - org.eclipse.tycho - tycho-p2-plugin - ${tycho-version} - - - p2-metadata - package - - p2-metadata - - - - - false - - + + org.apache.maven.plugins + maven-pmd-plugin + 3.26.0 + + 1 + true + true + + ${pmdRuleDir}/pmd-ruleset.xml + + + + + + check + cpd-check + + verify + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + + + ${project.groupId} + ${target-config} + ${project.version} + + + + + win32 + win32 + x86_64 + + + linux + gtk + x86_64 + + + linux + gtk + aarch64 + + + macosx + cocoa + x86_64 + + + macosx + cocoa + aarch64 + + + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho-version} + + + plugin-source + + plugin-source + + + + + + org.eclipse.tycho + tycho-packaging-plugin + + + true + + + + + org.eclipse.tycho.extras + tycho-sourceref-jgit + ${tycho-version} + + + - - - + + + + org.eclipse.tycho + tycho-packaging-plugin + ${tycho-version} + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho-version} + + + + https://download.eclipse.org/lsp4e/snapshots + + + + + + + + + + + sign + + + + org.apache.maven.plugins + maven-jarsigner-plugin + 3.0.0 + + + sign + package + + sign + + + + + ${project.basedir}/../keystore.jks + snyk + ${env.KEYSTORE_PASS} + + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho-version} + + + p2-metadata + package + + p2-metadata + + + + + false + + + + + + diff --git a/target-platform/pom.xml b/target-platform/pom.xml index 8b06814c..55a6ef67 100644 --- a/target-platform/pom.xml +++ b/target-platform/pom.xml @@ -6,5 +6,8 @@ parent 3.0.0-SNAPSHOT + + ${project.parent.basedir} + eclipse-target-definition diff --git a/tests/pom.xml b/tests/pom.xml index dd7687eb..e0b21b50 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -6,6 +6,10 @@ parent 3.0.0-SNAPSHOT + + ${project.parent.basedir} + + io.snyk.eclipse.plugin.tests eclipse-test-plugin diff --git a/update-site/pom.xml b/update-site/pom.xml index 4a01acba..16814fc0 100644 --- a/update-site/pom.xml +++ b/update-site/pom.xml @@ -1,52 +1,55 @@ - 4.0.0 - update-site - - io.snyk - parent - 3.0.0-SNAPSHOT - - eclipse-repository + 4.0.0 + update-site + + io.snyk + parent + 3.0.0-SNAPSHOT + + eclipse-repository + + ${project.parent.basedir} + - - - - org.eclipse.tycho - target-platform-configuration - - none - - - - p2-installable-unit - org.eclipse.platform.ide - 0.0.0 - - - - - - - org.eclipse.tycho - tycho-p2-director-plugin - ${tycho-version} - - - create-product-distributions - - materialize-products - archive-products - - - - - - org.eclipse.tycho - tycho-p2-repository-plugin - ${tycho-version} - - - + + + + org.eclipse.tycho + target-platform-configuration + + none + + + + p2-installable-unit + org.eclipse.platform.ide + 0.0.0 + + + + + + + org.eclipse.tycho + tycho-p2-director-plugin + ${tycho-version} + + + create-product-distributions + + materialize-products + archive-products + + + + + + org.eclipse.tycho + tycho-p2-repository-plugin + ${tycho-version} + + +