Skip to content

Commit a963f9b

Browse files
chore/add-linter (#254)
* 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
1 parent 04929c9 commit a963f9b

File tree

12 files changed

+473
-393
lines changed

12 files changed

+473
-393
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ jobs:
3636
echo "$sha $fileName" > sha256.txt
3737
sha256sum -c sha256.txt
3838
39+
- uses: pmd/pmd-github-action@v2
40+
name: Lint
41+
id: pmd
42+
if: ${{ matrix.os == 'ubuntu-latest' }}
43+
with:
44+
rulesets: 'plugin/src/main/resources/pmd-ruleset.xml'
45+
sourcePath: 'plugin/src/main/java'
46+
analyzeModifiedFilesOnly: true
47+
48+
- name: Upload SARIF file
49+
if: ${{ matrix.os == 'ubuntu-latest' && steps.pmd.outputs.violations != 0 }}
50+
uses: github/codeql-action/upload-sarif@v3
51+
with:
52+
sarif_file: pmd-report.sarif
53+
54+
- name: Fail build if violations found
55+
if: steps.pmd.outputs.violations != 0
56+
run: exit 1
57+
3958
- name: Build with Maven
4059
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' }}
4160
run: ./mvnw clean verify -P sign -DtrimStackTrace=false

.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@
3535
<arguments>
3636
</arguments>
3737
</buildCommand>
38+
<buildCommand>
39+
<name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
40+
<arguments>
41+
</arguments>
42+
</buildCommand>
3843
</buildSpec>
3944
<natures>
4045
<nature>org.eclipse.m2e.core.maven2Nature</nature>
4146
<nature>org.eclipse.pde.PluginNature</nature>
4247
<nature>org.eclipse.jdt.core.javanature</nature>
4348
<nature>org.eclipse.pde.FeatureNature</nature>
4449
<nature>org.eclipse.pde.UpdateSiteNature</nature>
50+
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
4551
</natures>
4652
</projectDescription>

feature/pom.xml

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3-
<modelVersion>4.0.0</modelVersion>
4-
<parent>
5-
<groupId>io.snyk</groupId>
6-
<artifactId>parent</artifactId>
7-
<version>3.0.0-SNAPSHOT</version>
8-
</parent>
3+
<modelVersion>4.0.0</modelVersion>
4+
<parent>
5+
<groupId>io.snyk</groupId>
6+
<artifactId>parent</artifactId>
7+
<version>3.0.0-SNAPSHOT</version>
8+
</parent>
99

10-
<artifactId>io.snyk.scanner</artifactId>
10+
<artifactId>io.snyk.scanner</artifactId>
11+
<properties>
12+
<pmdRuleDir>${project.parent.basedir}</pmdRuleDir>
13+
</properties>
1114

12-
<packaging>eclipse-feature</packaging>
15+
<packaging>eclipse-feature</packaging>
1316

14-
<build>
15-
<plugins>
16-
<plugin>
17-
<groupId>org.eclipse.tycho</groupId>
18-
<artifactId>tycho-source-plugin</artifactId>
19-
<version>${tycho-version}</version>
20-
<executions>
21-
<execution>
22-
<id>feature-source</id>
23-
<phase>package</phase>
24-
<goals>
25-
<goal>feature-source</goal>
26-
</goals>
27-
</execution>
28-
</executions>
29-
</plugin>
30-
<plugin>
31-
<groupId>org.eclipse.tycho</groupId>
32-
<artifactId>tycho-p2-plugin</artifactId>
33-
<executions>
34-
<execution>
35-
<id>attach-p2-metadata</id>
36-
<phase>package</phase>
37-
<goals>
38-
<goal>p2-metadata</goal>
39-
</goals>
40-
</execution>
41-
</executions>
42-
</plugin>
43-
</plugins>
44-
</build>
17+
<build>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.eclipse.tycho</groupId>
21+
<artifactId>tycho-source-plugin</artifactId>
22+
<version>${tycho-version}</version>
23+
<executions>
24+
<execution>
25+
<id>feature-source</id>
26+
<phase>package</phase>
27+
<goals>
28+
<goal>feature-source</goal>
29+
</goals>
30+
</execution>
31+
</executions>
32+
</plugin>
33+
<plugin>
34+
<groupId>org.eclipse.tycho</groupId>
35+
<artifactId>tycho-p2-plugin</artifactId>
36+
<executions>
37+
<execution>
38+
<id>attach-p2-metadata</id>
39+
<phase>package</phase>
40+
<goals>
41+
<goal>p2-metadata</goal>
42+
</goals>
43+
</execution>
44+
</executions>
45+
</plugin>
46+
</plugins>
47+
</build>
4548
</project>

plugin/.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@
2525
<arguments>
2626
</arguments>
2727
</buildCommand>
28+
<buildCommand>
29+
<name>net.sourceforge.pmd.eclipse.plugin.pmdBuilder</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
2833
</buildSpec>
2934
<natures>
3035
<nature>org.eclipse.m2e.core.maven2Nature</nature>
3136
<nature>org.eclipse.pde.PluginNature</nature>
3237
<nature>org.eclipse.jdt.core.javanature</nature>
38+
<nature>net.sourceforge.pmd.eclipse.plugin.pmdNature</nature>
3339
</natures>
3440
</projectDescription>

plugin/plugin.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<extension point="org.eclipse.ui.perspectiveExtensions">
2121
<perspectiveExtension
2222
targetID="org.eclipse.jdt.ui.JavaPerspective">
23-
<view
24-
id="io.snyk.eclipse.plugin.views.snyktoolview"
25-
ratio="0.5"
23+
<view
24+
id="io.snyk.eclipse.plugin.views.snyktoolview"
25+
ratio="0.5"
2626
relative="org.eclipse.ui.views.ProblemView"
2727
relationship="right">
2828
</view>
@@ -412,13 +412,13 @@
412412
</extension>
413413
<extension point="org.eclipse.lsp4e.languageServer">
414414
<server
415-
class="io.snyk.languageserver.SnykLanguageServer"
416-
id="io.snyk.languageserver"
417-
label="Snyk Language Server"
418-
clientImpl="io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient"
419-
lastDocumentDisconnectedTimeout="3000000"
420-
singleton="true"
421-
markerType="io.snyk.languageserver.marker">
415+
class="io.snyk.languageserver.SnykLanguageServer"
416+
clientImpl="io.snyk.languageserver.protocolextension.SnykExtendedLanguageClient"
417+
id="io.snyk.languageserver"
418+
label="Snyk Language Server"
419+
lastDocumentDisconnectedTimeout="3000000"
420+
markerType="io.snyk.languageserver.marker"
421+
singleton="true">
422422
</server>
423423
<!-- snyk code -->
424424
<contentTypeMapping

0 commit comments

Comments
 (0)