Skip to content

Commit

Permalink
Revert tool (#128)
Browse files Browse the repository at this point in the history
Revert PMD to version 6. Version 7 will be launched as a different tool
  • Loading branch information
DMarinhoCodacy authored Sep 19, 2024
1 parent aea641c commit 8b17d55
Show file tree
Hide file tree
Showing 145 changed files with 955 additions and 1,164 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: 2.1

orbs:
codacy: codacy/base@12.1.3
codacy_plugins_test: codacy/plugins-test@2.0.11
codacy: codacy/base@10.11.1
codacy_plugins_test: codacy/plugins-test@1.1.1

workflows:
version: 2
Expand Down
3 changes: 2 additions & 1 deletion .codacy.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
exclude_paths:
- "src/main/resources/docs/description/*.md"
- "src/main/resources/docs/description/*"
- "src/main/resources/docs/tests/*"
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,3 @@
.bloop
.vscode
.bsp

project/metals.sbt
14 changes: 6 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import sjsonnew.BasicJsonProtocol._

organization := "codacy"
name := "codacy-pmd"
scalaVersion := "2.13.14"
scalaVersion := "2.13.11"

lazy val toolVersionKey = SettingKey[String]("version of the underlying tool")
toolVersionKey := "7.5.0"
toolVersionKey := "6.55.0"

libraryDependencies ++= {
val toolVersion = toolVersionKey.value
Expand All @@ -20,14 +20,12 @@ libraryDependencies ++= {
"net.sourceforge.pmd" % "pmd-jsp" % toolVersion,
"net.sourceforge.pmd" % "pmd-javascript" % toolVersion,
"net.sourceforge.pmd" % "pmd-plsql" % toolVersion,
// "net.sourceforge.pmd" % "pmd-vm" % toolVersion, No official support yet only rc
"net.sourceforge.pmd" % "pmd-vm" % toolVersion,
"net.sourceforge.pmd" % "pmd-xml" % toolVersion,
"net.sourceforge.pmd" % "pmd-visualforce" % toolVersion,
"net.sourceforge.pmd" % "pmd-apex" % toolVersion,
"net.sourceforge.pmd" % "pmd" % toolVersion,
"net.sourceforge.pmd" % "pmd-kotlin" % toolVersion,
"net.sourceforge.pmd" % "pmd-velocity" % toolVersion,
"org.mozilla" % "rhino" % "1.7.15"
// Workaround for https://github.com/pmd/pmd/issues/2081
"org.mozilla" % "rhino" % "1.7.8" force ()
)
}

Expand Down Expand Up @@ -58,7 +56,7 @@ val dockerGroup = "docker"

Docker / daemonUser := dockerUser
Docker / daemonGroup := dockerGroup
dockerBaseImage := "amazoncorretto:22-alpine3.20"
dockerBaseImage := "amazoncorretto:8-alpine3.18-jre"
Compile / mainClass := Some("com.codacy.Engine")
dockerEntrypoint := Seq("/sbin/tini", "-g", "--", s"/opt/docker/bin/${name.value}")
dockerCommands := dockerCommands.value.flatMap {
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.9.2
26 changes: 8 additions & 18 deletions src/main/java/com/codacy/pmd/CodacyInMemoryRenderer.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.codacy.pmd;

import net.sourceforge.pmd.reporting.Report.ProcessingError;
import net.sourceforge.pmd.reporting.RuleViolation;
import net.sourceforge.pmd.reporting.Report.SuppressedViolation;
import net.sourceforge.pmd.Report;
import net.sourceforge.pmd.RuleViolation;
import net.sourceforge.pmd.renderers.AbstractIncrementingRenderer;

import java.io.IOException;
Expand All @@ -23,7 +22,7 @@ public class CodacyInMemoryRenderer extends AbstractIncrementingRenderer {
public CodacyInMemoryRenderer() {
super(NAME, "Codacy In Memory.");
// Using a stub writer since we are saving the violations in memory
new Writer() {
writer = new Writer() {
@Override
public void write(char[] cbuf, int off, int len) throws IOException {
// Ignore
Expand All @@ -41,11 +40,11 @@ public void close() throws IOException {
};
}

public List<ProcessingError> getErrors() {
public List<Report.ProcessingError> getErrors() {
return errors;
}

public List<SuppressedViolation> getSuppressedViolations() {
public List<Report.SuppressedViolation> getSuppressedViolations() {
return suppressed;
}

Expand All @@ -59,26 +58,17 @@ public String defaultFileExtension() {

@Override
public void start() throws IOException {
ruleViolations.clear();
// Ignore
}

@Override
public void renderFileViolations(Iterator<RuleViolation> violations) throws IOException {
// Save the violations in memory for future access
while (violations.hasNext()) {
RuleViolation rv = violations.next();
// Check if there's already a violation with the same rule, line, and file
boolean isDuplicate = ruleViolations.stream().anyMatch(existingViolation ->
existingViolation.getBeginLine() == rv.getBeginLine() &&
existingViolation.getRule().getName().equals(rv.getRule().getName()) &&
existingViolation.getFileId().equals(rv.getFileId())
);

if (!isDuplicate) {
ruleViolations.add(rv);
}
ruleViolations.add(rv);
}
}


@Override
public void end() throws IOException {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8b17d55

Please sign in to comment.