Skip to content

Commit

Permalink
chore/add-linter (#254)
Browse files Browse the repository at this point in the history
* chore: add pmd to build definition

* chore: add github linting step

* chore: move pmd checks to plugin dir

* chore: change configuration to point to ruleset

* fix: ruleset location

* fix: only run PMD on linux

* fix: fail build if violations are found

* fix: build failure

* fix: build failure

* chore: use pmd 2.0.0

* fix: linting error
  • Loading branch information
bastiandoetsch authored Jan 29, 2025
1 parent 04929c9 commit a963f9b
Show file tree
Hide file tree
Showing 12 changed files with 473 additions and 393 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ jobs:
echo "$sha $fileName" > sha256.txt
sha256sum -c sha256.txt
- uses: pmd/pmd-github-action@v2
name: Lint
id: pmd
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
rulesets: 'plugin/src/main/resources/pmd-ruleset.xml'
sourcePath: 'plugin/src/main/java'
analyzeModifiedFilesOnly: true

- name: Upload SARIF file
if: ${{ matrix.os == 'ubuntu-latest' && steps.pmd.outputs.violations != 0 }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: pmd-report.sarif

- name: Fail build if violations found
if: steps.pmd.outputs.violations != 0
run: exit 1

- 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>
20 changes: 10 additions & 10 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
<extension point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension
targetID="org.eclipse.jdt.ui.JavaPerspective">
<view
id="io.snyk.eclipse.plugin.views.snyktoolview"
ratio="0.5"
<view
id="io.snyk.eclipse.plugin.views.snyktoolview"
ratio="0.5"
relative="org.eclipse.ui.views.ProblemView"
relationship="right">
</view>
Expand Down Expand Up @@ -412,13 +412,13 @@
</extension>
<extension point="org.eclipse.lsp4e.languageServer">
<server
class="io.snyk.languageserver.SnykLanguageServer"
id="io.snyk.languageserver"
label="Snyk Language Server"
clientImpl="io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient"
lastDocumentDisconnectedTimeout="3000000"
singleton="true"
markerType="io.snyk.languageserver.marker">
class="io.snyk.languageserver.SnykLanguageServer"
clientImpl="io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient"
id="io.snyk.languageserver"
label="Snyk Language Server"
lastDocumentDisconnectedTimeout="3000000"
markerType="io.snyk.languageserver.marker"
singleton="true">
</server>
<!-- snyk code -->
<contentTypeMapping
Expand Down
Loading

0 comments on commit a963f9b

Please sign in to comment.