forked from phoedos/pmd
Merge branch 'pr-2044'
[core] Wrong deprecation warnings for unused XPath attributes
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import net.sourceforge.pmd.PMDVersion;
|
||||
|
||||
public abstract class AbstractBinaryDistributionTest {
|
||||
|
||||
protected static File getBinaryDistribution() {
|
||||
return new File(".", "target/pmd-bin-" + PMDVersion.VERSION + ".zip");
|
||||
}
|
||||
|
||||
/**
|
||||
* The temporary directory, to which the binary distribution will be extracted.
|
||||
* It will be deleted again after the test.
|
||||
*/
|
||||
protected static Path tempDir;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupTempDirectory() throws Exception {
|
||||
tempDir = Files.createTempDirectory("pmd-it-test-");
|
||||
if (getBinaryDistribution().exists()) {
|
||||
ZipFileExtractor.extractZipFile(getBinaryDistribution().toPath(), tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanupTempDirectory() throws IOException {
|
||||
if (tempDir != null && tempDir.toFile().exists()) {
|
||||
FileUtils.forceDelete(tempDir.toFile());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.it;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameter;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class AllRulesIT extends AbstractBinaryDistributionTest {
|
||||
|
||||
@Parameter
|
||||
public String language;
|
||||
|
||||
@Parameters
|
||||
public static Iterable<String> languagesToTest() {
|
||||
// note: scala and wsdl have no rules
|
||||
return Arrays.asList("java", "apex", "javascript", "jsp", "plsql", "pom", "visualforce", "velocitytemplate", "xml", "xsl");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runRuleTests() throws Exception {
|
||||
String srcDir = new File(".", "src/test/resources/sample-source/" + language + "/").getAbsolutePath();
|
||||
|
||||
ExecutionResult result = PMDExecutor.runPMDRules(tempDir, srcDir, "src/test/resources/rulesets/all-"
|
||||
+ language + ".xml");
|
||||
assertDefaultExecutionResult(result);
|
||||
}
|
||||
|
||||
private static void assertDefaultExecutionResult(ExecutionResult result) {
|
||||
result.assertExecutionResult(4, "");
|
||||
|
||||
result.assertNoError("Exception applying rule");
|
||||
result.assertNoError("Ruleset not found");
|
||||
result.assertNoError("Use of deprecated attribute");
|
||||
result.assertNoErrorInReport("Error while processing");
|
||||
result.assertNoErrorInReport("Error while parsing");
|
||||
}
|
||||
}
|
@@ -9,47 +9,17 @@ import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sourceforge.pmd.PMDVersion;
|
||||
|
||||
public class BinaryDistributionIT {
|
||||
|
||||
private static File getBinaryDistribution() {
|
||||
return new File(".", "target/pmd-bin-" + PMDVersion.VERSION + ".zip");
|
||||
}
|
||||
|
||||
/**
|
||||
* The temporary directory, to which the binary distribution will be extracted.
|
||||
* It will be deleted again after the test.
|
||||
*/
|
||||
private static Path tempDir;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupTempDirectory() throws Exception {
|
||||
tempDir = Files.createTempDirectory("pmd-it-test-");
|
||||
if (getBinaryDistribution().exists()) {
|
||||
ZipFileExtractor.extractZipFile(getBinaryDistribution().toPath(), tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void cleanupTempDirectory() throws IOException {
|
||||
if (tempDir != null && tempDir.toFile().exists()) {
|
||||
FileUtils.forceDelete(tempDir.toFile());
|
||||
}
|
||||
}
|
||||
public class BinaryDistributionIT extends AbstractBinaryDistributionTest {
|
||||
|
||||
@Test
|
||||
public void testFileExistence() {
|
||||
@@ -90,7 +60,7 @@ public class BinaryDistributionIT {
|
||||
|
||||
@Test
|
||||
public void runPMD() throws Exception {
|
||||
String srcDir = new File(".", "src/test/resources/sample-source/").getAbsolutePath();
|
||||
String srcDir = new File(".", "src/test/resources/sample-source/java/").getAbsolutePath();
|
||||
|
||||
ExecutionResult result;
|
||||
|
||||
@@ -99,7 +69,7 @@ public class BinaryDistributionIT {
|
||||
result.assertExecutionResult(0, "apex, ecmascript, java, jsp, plsql, pom, scala, text, vf, vm, wsdl, xml, xsl");
|
||||
|
||||
result = PMDExecutor.runPMDRules(tempDir, srcDir, "src/test/resources/rulesets/sample-ruleset.xml");
|
||||
result.assertExecutionResult(4, "JumbledIncrementer.java:8:");
|
||||
result.assertExecutionResult(4, "", "JumbledIncrementer.java:8:");
|
||||
|
||||
result = PMDExecutor.runPMDRules(tempDir, srcDir, "rulesets/java/quickstart.xml");
|
||||
result.assertExecutionResult(4, "");
|
||||
|
@@ -34,7 +34,7 @@ public class CpdExecutor {
|
||||
String output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
int result = process.waitFor();
|
||||
return new ExecutionResult(result, output);
|
||||
return new ExecutionResult(result, output, null, null);
|
||||
}
|
||||
|
||||
private static ExecutionResult runCpdWindows(Path tempDir, String ... arguments) throws Exception {
|
||||
@@ -46,7 +46,7 @@ public class CpdExecutor {
|
||||
String output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
int result = process.waitFor();
|
||||
return new ExecutionResult(result, output);
|
||||
return new ExecutionResult(result, output, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -5,7 +5,9 @@
|
||||
package net.sourceforge.pmd.it;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
@@ -18,10 +20,14 @@ import net.sourceforge.pmd.PMD;
|
||||
public class ExecutionResult {
|
||||
private final int exitCode;
|
||||
private final String output;
|
||||
private final String errorOutput;
|
||||
private final String report;
|
||||
|
||||
ExecutionResult(int theExitCode, String theOutput) {
|
||||
ExecutionResult(int theExitCode, String theOutput, String theErrorOutput, String theReport) {
|
||||
this.exitCode = theExitCode;
|
||||
this.output = theOutput;
|
||||
this.errorOutput = theErrorOutput;
|
||||
this.report = theReport;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -30,7 +36,9 @@ public class ExecutionResult {
|
||||
sb.append("ExecutionResult:")
|
||||
.append(PMD.EOL)
|
||||
.append(" exit code: ").append(exitCode).append(PMD.EOL)
|
||||
.append(" output:").append(PMD.EOL).append(output).append(PMD.EOL);
|
||||
.append(" output:").append(PMD.EOL).append(output).append(PMD.EOL)
|
||||
.append(" errorOutput:").append(PMD.EOL).append(errorOutput).append(PMD.EOL)
|
||||
.append(" report:").append(PMD.EOL).append(report).append(PMD.EOL);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@@ -42,10 +50,80 @@ public class ExecutionResult {
|
||||
* @param expectedOutput the output to search for
|
||||
*/
|
||||
public void assertExecutionResult(int expectedExitCode, String expectedOutput) {
|
||||
assertEquals("Command exited with wrong code", expectedExitCode, exitCode);
|
||||
assertExecutionResult(expectedExitCode, expectedOutput, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the command exited with the expected exit code and that the given expected
|
||||
* output is contained in the actual command output and the given expected report is in the
|
||||
* generated report.
|
||||
*
|
||||
* @param expectedExitCode the exit code, e.g. 0 if no rule violations are expected, or 4 if violations are found
|
||||
* @param expectedOutput the output to search for
|
||||
* @param expectedReport the string to search for tin the report
|
||||
*/
|
||||
public void assertExecutionResult(int expectedExitCode, String expectedOutput, String expectedReport) {
|
||||
assertEquals("Command exited with wrong code.\nComplete result:\n\n" + this, expectedExitCode, exitCode);
|
||||
assertNotNull("No output found", output);
|
||||
if (!output.contains(expectedOutput)) {
|
||||
fail("Expected output '" + expectedOutput + "' not present.\nComplete output:\n\n" + output);
|
||||
if (expectedOutput != null && !expectedOutput.isEmpty()) {
|
||||
if (!output.contains(expectedOutput)) {
|
||||
fail("Expected output '" + expectedOutput + "' not present.\nComplete result:\n\n" + this);
|
||||
}
|
||||
} else {
|
||||
assertTrue("The output should have been empty.\nComplete result:\n\n" + this, output.isEmpty());
|
||||
}
|
||||
if (expectedReport != null && !expectedReport.isEmpty()) {
|
||||
assertTrue("Expected report '" + expectedReport + "'.\nComplete result:\n\n" + this,
|
||||
report.contains(expectedReport));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given error message is not in the error output.
|
||||
* @param errorMessage the error message to search for
|
||||
*/
|
||||
public void assertNoError(String errorMessage) {
|
||||
assertFalse("Found error message: " + errorMessage + ".\nComplete result:\n\n" + this,
|
||||
errorOutput.contains(errorMessage));
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that the given error message is not in the report.
|
||||
* @param errorMessage the error message to search for
|
||||
*/
|
||||
public void assertNoErrorInReport(String errorMessage) {
|
||||
assertFalse("Found error message in report: " + errorMessage + ".\nComplete result:\n\n" + this,
|
||||
report.contains(errorMessage));
|
||||
}
|
||||
|
||||
static class Builder {
|
||||
private int exitCode;
|
||||
private String output;
|
||||
private String errorOutput;
|
||||
private String report;
|
||||
|
||||
Builder withExitCode(int exitCode) {
|
||||
this.exitCode = exitCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
Builder withOutput(String output) {
|
||||
this.output = output;
|
||||
return this;
|
||||
}
|
||||
|
||||
Builder withErrorOutput(String errorOutput) {
|
||||
this.errorOutput = errorOutput;
|
||||
return this;
|
||||
}
|
||||
|
||||
Builder withReport(String report) {
|
||||
this.report = report;
|
||||
return this;
|
||||
}
|
||||
|
||||
ExecutionResult build() {
|
||||
return new ExecutionResult(exitCode, output, errorOutput, report);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,13 @@
|
||||
|
||||
package net.sourceforge.pmd.it;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
@@ -24,33 +28,65 @@ public class PMDExecutor {
|
||||
private static final String RULESET_FLAG = "-R";
|
||||
private static final String FORMAT_FLAG = "-f";
|
||||
private static final String FORMATTER = "text";
|
||||
private static final String REPORTFILE_FLAG = "-r";
|
||||
|
||||
private PMDExecutor() {
|
||||
// this is a helper class only
|
||||
}
|
||||
|
||||
private static ExecutionResult runPMDUnix(Path tempDir, String ... arguments) throws Exception {
|
||||
private static ExecutionResult runPMDUnix(Path tempDir, Path reportFile, String ... arguments) throws Exception {
|
||||
String cmd = tempDir.resolve(PMD_BIN_PREFIX + PMDVersion.VERSION + "/bin/run.sh").toAbsolutePath().toString();
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd, "pmd");
|
||||
pb.command().addAll(Arrays.asList(arguments));
|
||||
pb.redirectErrorStream(true);
|
||||
Process process = pb.start();
|
||||
String output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
|
||||
|
||||
int result = process.waitFor();
|
||||
return new ExecutionResult(result, output);
|
||||
return runPMD(cmd, Arrays.asList(arguments), reportFile);
|
||||
}
|
||||
|
||||
private static ExecutionResult runPMDWindows(Path tempDir, String ... arguments) throws Exception {
|
||||
private static ExecutionResult runPMDWindows(Path tempDir, Path reportFile, String ... arguments) throws Exception {
|
||||
String cmd = tempDir.resolve(PMD_BIN_PREFIX + PMDVersion.VERSION + "/bin/pmd.bat").toAbsolutePath().toString();
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd);
|
||||
pb.command().addAll(Arrays.asList(arguments));
|
||||
pb.redirectErrorStream(true);
|
||||
Process process = pb.start();
|
||||
String output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
|
||||
return runPMD(cmd, Arrays.asList(arguments), reportFile);
|
||||
}
|
||||
|
||||
int result = process.waitFor();
|
||||
return new ExecutionResult(result, output);
|
||||
private static ExecutionResult runPMD(String cmd, List<String> arguments, Path reportFile) throws Exception {
|
||||
ProcessBuilder pb = new ProcessBuilder(cmd, "pmd");
|
||||
pb.command().addAll(arguments);
|
||||
pb.redirectErrorStream(false);
|
||||
final Process process = pb.start();
|
||||
final ExecutionResult.Builder result = new ExecutionResult.Builder();
|
||||
|
||||
Thread outputReader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String output;
|
||||
try {
|
||||
output = IOUtils.toString(process.getInputStream(), StandardCharsets.UTF_8);
|
||||
result.withOutput(output);
|
||||
} catch (IOException e) {
|
||||
result.withOutput("Exception occurred: " + e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
outputReader.start();
|
||||
Thread errorReader = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String error;
|
||||
try {
|
||||
error = IOUtils.toString(process.getErrorStream(), StandardCharsets.UTF_8);
|
||||
result.withErrorOutput(error);
|
||||
} catch (IOException e) {
|
||||
result.withErrorOutput("Exception occurred: " + e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
errorReader.start();
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
outputReader.join(TimeUnit.MINUTES.toMillis(5));
|
||||
errorReader.join(TimeUnit.MINUTES.toMillis(5));
|
||||
|
||||
String report = null;
|
||||
if (reportFile != null) {
|
||||
report = IOUtils.toString(reportFile.toUri(), StandardCharsets.UTF_8);
|
||||
}
|
||||
return result.withExitCode(exitCode).withReport(report).build();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,10 +99,15 @@ public class PMDExecutor {
|
||||
* @throws Exception if the execution fails for any reason (executable not found, ...)
|
||||
*/
|
||||
public static ExecutionResult runPMDRules(Path tempDir, String sourceDirectory, String ruleset) throws Exception {
|
||||
Path reportFile = Files.createTempFile("pmd-it-report", "txt");
|
||||
reportFile.toFile().deleteOnExit();
|
||||
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
return runPMDWindows(tempDir, SOURCE_DIRECTORY_FLAG, sourceDirectory, RULESET_FLAG, ruleset, FORMAT_FLAG, FORMATTER);
|
||||
return runPMDWindows(tempDir, reportFile, SOURCE_DIRECTORY_FLAG, sourceDirectory, RULESET_FLAG, ruleset,
|
||||
FORMAT_FLAG, FORMATTER, REPORTFILE_FLAG, reportFile.toAbsolutePath().toString());
|
||||
} else {
|
||||
return runPMDUnix(tempDir, SOURCE_DIRECTORY_FLAG, sourceDirectory, RULESET_FLAG, ruleset, FORMAT_FLAG, FORMATTER);
|
||||
return runPMDUnix(tempDir, reportFile, SOURCE_DIRECTORY_FLAG, sourceDirectory, RULESET_FLAG, ruleset,
|
||||
FORMAT_FLAG, FORMATTER, REPORTFILE_FLAG, reportFile.toAbsolutePath().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,9 +120,9 @@ public class PMDExecutor {
|
||||
*/
|
||||
public static ExecutionResult runPMD(Path tempDir, String ... arguments) throws Exception {
|
||||
if (SystemUtils.IS_OS_WINDOWS) {
|
||||
return runPMDWindows(tempDir, arguments);
|
||||
return runPMDWindows(tempDir, null, arguments);
|
||||
} else {
|
||||
return runPMDUnix(tempDir, arguments);
|
||||
return runPMDUnix(tempDir, null, arguments);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
pmd-dist/src/test/resources/rulesets/all-apex.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-apex.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All Apex 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>Every Apex Rule in PMD</description>
|
||||
|
||||
<rule ref="category/apex/bestpractices.xml" />
|
||||
<rule ref="category/apex/codestyle.xml" />
|
||||
<rule ref="category/apex/design.xml" />
|
||||
<rule ref="category/apex/documentation.xml" />
|
||||
<rule ref="category/apex/errorprone.xml" />
|
||||
<rule ref="category/apex/multithreading.xml" />
|
||||
<rule ref="category/apex/performance.xml" />
|
||||
<rule ref="category/apex/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-java.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-java.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All Java 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>Every Java Rule in PMD</description>
|
||||
|
||||
<rule ref="category/java/bestpractices.xml" />
|
||||
<rule ref="category/java/codestyle.xml" />
|
||||
<rule ref="category/java/design.xml" />
|
||||
<rule ref="category/java/documentation.xml" />
|
||||
<rule ref="category/java/errorprone.xml" />
|
||||
<rule ref="category/java/multithreading.xml" />
|
||||
<rule ref="category/java/performance.xml" />
|
||||
<rule ref="category/java/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-javascript.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-javascript.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All JavaScript 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>Every JavaScript Rule in PMD</description>
|
||||
|
||||
<rule ref="category/ecmascript/bestpractices.xml" />
|
||||
<rule ref="category/ecmascript/codestyle.xml" />
|
||||
<rule ref="category/ecmascript/design.xml" />
|
||||
<rule ref="category/ecmascript/documentation.xml" />
|
||||
<rule ref="category/ecmascript/errorprone.xml" />
|
||||
<rule ref="category/ecmascript/multithreading.xml" />
|
||||
<rule ref="category/ecmascript/performance.xml" />
|
||||
<rule ref="category/ecmascript/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-jsp.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-jsp.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All JSP 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>Every JSP Rule in PMD</description>
|
||||
|
||||
<rule ref="category/jsp/bestpractices.xml" />
|
||||
<rule ref="category/jsp/codestyle.xml" />
|
||||
<rule ref="category/jsp/design.xml" />
|
||||
<rule ref="category/jsp/documentation.xml" />
|
||||
<rule ref="category/jsp/errorprone.xml" />
|
||||
<rule ref="category/jsp/multithreading.xml" />
|
||||
<rule ref="category/jsp/performance.xml" />
|
||||
<rule ref="category/jsp/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-plsql.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-plsql.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All PLSQL 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>Every PLSQL Rule in PMD</description>
|
||||
|
||||
<rule ref="category/plsql/bestpractices.xml" />
|
||||
<rule ref="category/plsql/codestyle.xml" />
|
||||
<rule ref="category/plsql/design.xml" />
|
||||
<rule ref="category/plsql/documentation.xml" />
|
||||
<rule ref="category/plsql/errorprone.xml" />
|
||||
<rule ref="category/plsql/multithreading.xml" />
|
||||
<rule ref="category/plsql/performance.xml" />
|
||||
<rule ref="category/plsql/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-pom.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-pom.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All Maven POM 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>Every Maven POM Rule in PMD</description>
|
||||
|
||||
<rule ref="category/pom/bestpractices.xml" />
|
||||
<rule ref="category/pom/codestyle.xml" />
|
||||
<rule ref="category/pom/design.xml" />
|
||||
<rule ref="category/pom/documentation.xml" />
|
||||
<rule ref="category/pom/errorprone.xml" />
|
||||
<rule ref="category/pom/multithreading.xml" />
|
||||
<rule ref="category/pom/performance.xml" />
|
||||
<rule ref="category/pom/security.xml" />
|
||||
|
||||
</ruleset>
|
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All Velocity Template Language 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>Every Velocity Template Language Rule in PMD</description>
|
||||
|
||||
<rule ref="category/vm/bestpractices.xml" />
|
||||
<rule ref="category/vm/codestyle.xml" />
|
||||
<rule ref="category/vm/design.xml" />
|
||||
<rule ref="category/vm/documentation.xml" />
|
||||
<rule ref="category/vm/errorprone.xml" />
|
||||
<rule ref="category/vm/multithreading.xml" />
|
||||
<rule ref="category/vm/performance.xml" />
|
||||
<rule ref="category/vm/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-visualforce.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-visualforce.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All Visualforce 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>Every Visualforce Rule in PMD</description>
|
||||
|
||||
<rule ref="category/vf/bestpractices.xml" />
|
||||
<rule ref="category/vf/codestyle.xml" />
|
||||
<rule ref="category/vf/design.xml" />
|
||||
<rule ref="category/vf/documentation.xml" />
|
||||
<rule ref="category/vf/errorprone.xml" />
|
||||
<rule ref="category/vf/multithreading.xml" />
|
||||
<rule ref="category/vf/performance.xml" />
|
||||
<rule ref="category/vf/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-xml.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-xml.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<ruleset name="All XML 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>Every XML Rule in PMD</description>
|
||||
|
||||
<rule ref="category/xml/bestpractices.xml" />
|
||||
<rule ref="category/xml/codestyle.xml" />
|
||||
<rule ref="category/xml/design.xml" />
|
||||
<rule ref="category/xml/documentation.xml" />
|
||||
<rule ref="category/xml/errorprone.xml" />
|
||||
<rule ref="category/xml/multithreading.xml" />
|
||||
<rule ref="category/xml/performance.xml" />
|
||||
<rule ref="category/xml/security.xml" />
|
||||
|
||||
</ruleset>
|
18
pmd-dist/src/test/resources/rulesets/all-xsl.xml
Normal file
18
pmd-dist/src/test/resources/rulesets/all-xsl.xml
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xsl version="1.0"?>
|
||||
|
||||
<ruleset name="All XSL Rules"
|
||||
xslns="http://pmd.sourceforge.net/ruleset/2.0.0"
|
||||
xslns:xsi="http://www.w3.org/2001/xslSchema-instance"
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
|
||||
<description>Every XSL Rule in PMD</description>
|
||||
|
||||
<rule ref="category/xsl/bestpractices.xml" />
|
||||
<rule ref="category/xsl/codestyle.xml" />
|
||||
<rule ref="category/xsl/design.xml" />
|
||||
<rule ref="category/xsl/documentation.xml" />
|
||||
<rule ref="category/xsl/errorprone.xml" />
|
||||
<rule ref="category/xsl/multithreading.xml" />
|
||||
<rule ref="category/xsl/performance.xml" />
|
||||
<rule ref="category/xsl/security.xml" />
|
||||
|
||||
</ruleset>
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
(function() {
|
||||
if (true) {
|
||||
x=2;
|
||||
} else {
|
||||
x=4;
|
||||
}
|
||||
})();
|
12
pmd-dist/src/test/resources/sample-source/jsp/SampleCode.jsp
Normal file
12
pmd-dist/src/test/resources/sample-source/jsp/SampleCode.jsp
Normal file
@@ -0,0 +1,12 @@
|
||||
<%@ page errorPage="error.jsp" %>
|
||||
<%@ page import="com.foo.AClass"%>
|
||||
<%@ page import="com.foo.MyClass"%>
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<b>
|
||||
<img src="<%=Some.get()%>/foo">xx</img>
|
||||
text
|
||||
</b>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1,14 @@
|
||||
--
|
||||
-- Example 2-25 Assigning Value to Variable with SELECT INTO Statement
|
||||
-- From: https://docs.oracle.com/en/database/oracle/oracle-database/18/lnpls/plsql-language-fundamentals.html#GUID-664BFFEA-063A-48B6-A65B-95225EDDED59
|
||||
--
|
||||
DECLARE
|
||||
bonus NUMBER(8,2);
|
||||
BEGIN
|
||||
SELECT salary * 0.10 INTO bonus
|
||||
FROM employees
|
||||
WHERE employee_id = 100;
|
||||
END;
|
||||
|
||||
DBMS_OUTPUT.PUT_LINE('bonus = ' || TO_CHAR(bonus));
|
||||
/
|
17
pmd-dist/src/test/resources/sample-source/pom/pom.xml.pom
Normal file
17
pmd-dist/src/test/resources/sample-source/pom/pom.xml.pom
Normal file
@@ -0,0 +1,17 @@
|
||||
<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>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>xml-pom</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependency>
|
||||
<groupId>org.jboss.arquillian</groupId>
|
||||
<artifactId>arquillian-bom</artifactId>
|
||||
<version>${arquillian.version}</version>
|
||||
<type>bom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
#set( $foo = "Velocity" )
|
||||
Hello $foo World!
|
||||
|
||||
<script type= "text/javascript"> alert("hello"); </script>
|
||||
</body>
|
||||
</html>
|
@@ -0,0 +1 @@
|
||||
<apex:page controller="AcRestActionsController" action="{!csrfInitMethod}" >
|
35
pmd-dist/src/test/resources/sample-source/xml/samplecode.xml
Normal file
35
pmd-dist/src/test/resources/sample-source/xml/samplecode.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd"
|
||||
global-variables="false">
|
||||
<application-name>app</application-name>
|
||||
<variable-definition>
|
||||
<variable>
|
||||
<name>Application_Module_Web_ContextRoot</name>
|
||||
<value xsi:nil="false">ikb.adf.kreda.abw.webapp-Abnahmetest-ohne-SSO</value>
|
||||
</variable>
|
||||
</variable-definition>
|
||||
<module-override>
|
||||
<module-name>ikb.adf.kreda.abw.ear</module-name>
|
||||
<module-type>ear</module-type>
|
||||
<module-descriptor external="false">
|
||||
<root-element>application</root-element>
|
||||
<uri>META-INF/application.xml</uri>
|
||||
<variable-assignment>
|
||||
<name>Application_Module_Web_ContextRoot</name>
|
||||
<xpath>/application/module/web/[context-root="ikb.adf.kreda.abw.webapp-Local-ohne-SSO"]</xpath>
|
||||
<operation>replace</operation>
|
||||
</variable-assignment>
|
||||
</module-descriptor>
|
||||
</module-override>
|
||||
|
||||
<root>
|
||||
<child>
|
||||
<![CDATA[
|
||||
some text data
|
||||
]]]>
|
||||
</child>
|
||||
</root>
|
||||
|
||||
</deployment-plan>
|
@@ -0,0 +1,4 @@
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:variable name="var" select="concat('abc',concat('cd','ef'))"/>
|
||||
</xsl:stylesheet>
|
Reference in New Issue
Block a user