Skip to content

Commit

Permalink
chore: add github linting step
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Jan 29, 2025
1 parent 4d3745b commit 7acbe7d
Show file tree
Hide file tree
Showing 11 changed files with 356 additions and 288 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.FeatureNature</nature>
<nature>org.eclipse.pde.UpdateSiteNature</nature>
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
</natures>
</projectDescription>
81 changes: 42 additions & 39 deletions feature/pom.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.snyk</groupId>
<artifactId>parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.snyk</groupId>
<artifactId>parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>io.snyk.scanner</artifactId>
<artifactId>io.snyk.scanner</artifactId>
<properties>
<pmdRuleDir>${project.parent.basedir}</pmdRuleDir>
</properties>

<packaging>eclipse-feature</packaging>
<packaging>eclipse-feature</packaging>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>feature-source</id>
<phase>package</phase>
<goals>
<goal>feature-source</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<executions>
<execution>
<id>attach-p2-metadata</id>
<phase>package</phase>
<goals>
<goal>p2-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-source-plugin</artifactId>
<version>${tycho-version}</version>
<executions>
<execution>
<id>feature-source</id>
<phase>package</phase>
<goals>
<goal>feature-source</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-plugin</artifactId>
<executions>
<execution>
<id>attach-p2-metadata</id>
<phase>package</phase>
<goals>
<goal>p2-metadata</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
6 changes: 6 additions & 0 deletions plugin/.project
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
</natures>
</projectDescription>
6 changes: 5 additions & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
<version>3.0.0-SNAPSHOT</version>
</parent>

<properties>
<pmdRuleDir>${project.parent.basedir}</pmdRuleDir>
</properties>

<artifactId>io.snyk.eclipse.plugin</artifactId>

<artifactId>io.snyk.eclipse.plugin</artifactId>
<url>https://snyk.io/ide-plugins/</url>
<packaging>eclipse-plugin</packaging>

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}
29 changes: 29 additions & 0 deletions pmd-ruleset.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>Sensible PMD rules focusing on important code quality issues</description>

<!-- Error Prone - Critical issues that are likely bugs -->
<rule ref="category/java/errorprone.xml">
<exclude name="BeanMembersShouldSerialize"/>
</rule>

<!-- Best Practices - Important coding standards -->
<rule ref="category/java/bestpractices.xml">
<exclude name="GuardLogStatement"/>
<exclude name="JUnitTestsShouldIncludeAssert"/>
</rule>

<!-- Performance - Critical performance issues -->
<rule ref="category/java/performance.xml"/>

<!-- Security - Basic security checks -->
<rule ref="category/java/security.xml"/>

<!-- Exclude generated sources -->
<exclude-pattern>.*/generated/.*</exclude-pattern>
<exclude-pattern>.*/target/.*</exclude-pattern>
</ruleset>
Loading

0 comments on commit 7acbe7d

Please sign in to comment.