Merge branch 'master' into pmd/7.0.x

This commit is contained in:
Andreas Dangel 2020-10-29 10:52:38 +01:00
commit 1862f4fe05
26 changed files with 237 additions and 103 deletions

View File

@ -27,4 +27,4 @@ jobs:
java-version: ${{ matrix.java }}
- name: Build with mvnw
run: |
./mvnw clean install
./mvnw -V clean install

View File

@ -34,13 +34,6 @@ jobs:
dist: bionic
env: BUILD=coveralls
if: "type = push && repo = pmd/pmd && fork = false"
- name: "macosx - mvn verify"
os: osx
env: BUILD=deploy
- name: "windows - mvn verify"
os: windows
env: BUILD=deploy
language: shell
- stage: publish
name: "Release Build - Publish"
os: linux
@ -49,7 +42,7 @@ jobs:
env: BUILD=publish
before_install:
- bash .travis/before_install.sh "11.0.8+10"
- bash .travis/before_install.sh "11"
- source ${HOME}/java.env
install: true
before_script: true

View File

@ -13,30 +13,36 @@ bash .travis/configure-maven.sh
bash .travis/install-openjdk.sh $OPENJDK_VERSION
function install_jdk() {
LOCAL_DIR=$1
TARGET_DIR=$2
DOWNLOAD_URL=$3
ARCHIVE=$(basename $DOWNLOAD_URL)
mkdir -p ${LOCAL_DIR}
mkdir -p ${TARGET_DIR}
if [ ! -e ${LOCAL_DIR}/${ARCHIVE} ]; then
log_info "Downloading from ${DOWNLOAD_URL} to ${LOCAL_DIR}"
wget --directory-prefix ${LOCAL_DIR} --timestamping --continue ${DOWNLOAD_URL}
else
log_info "Skipped download, file ${LOCAL_DIR}/${ARCHIVE} already exists"
fi
log_info "Extracting to ${TARGET_DIR}"
tar --extract --file ${LOCAL_DIR}/${ARCHIVE} -C ${TARGET_DIR} --strip-components=1
}
if travis_isLinux; then
change_ruby_version
gem install bundler
bundle config set --local path vendor/bundle
bundle config set --local with release_notes_preprocessing
bundle install
# install openjdk8 for integration test
LOCAL_DIR=${HOME}/.cache/jdk8
TARGET_DIR=${HOME}/openjdk8
OPENJDK8_ARCHIVE=OpenJDK8U-jdk_x64_linux_hotspot_8u265b01.tar.gz
DOWNLOAD_URL=https://pmd-code.org/openjdk/jdk-8u265b01/${OPENJDK8_ARCHIVE}
mkdir -p ${LOCAL_DIR}
mkdir -p ${TARGET_DIR}
if [ ! -e ${LOCAL_DIR}/${OPENJDK8_ARCHIVE} ]; then
log_info "Downloading from ${DOWNLOAD_URL} to ${LOCAL_DIR}"
wget --directory-prefix ${LOCAL_DIR} --timestamping --continue ${DOWNLOAD_URL}
else
log_info "Skipped download, file ${LOCAL_DIR}/${OPENJDK8_ARCHIVE} already exists"
fi
log_info "Extracting to ${TARGET_DIR}"
tar --extract --file ${LOCAL_DIR}/${OPENJDK8_ARCHIVE} -C ${TARGET_DIR} --strip-components=1
log_info "OpenJDK8 can be used via -Djava8.home=${TARGET_DIR}"
# install openjdk8 for integration test and pmd-regression-tests
install_jdk "${HOME}/.cache/openjdk" "${HOME}/openjdk8" "https://pmd-code.org/openjdk/latest/jdk-8-linux64.tar.gz"
log_info "OpenJDK8 can be used via -Djava8.home=${HOME}/openjdk8"
log_info "OpenJDK8 can be used from ${HOME}/openjdk8"
else
log_info "Not setting up ruby for ${TRAVIS_OS_NAME}."
log_info "Not setting up ruby and additional jvms for ${TRAVIS_OS_NAME}."
exit 0
fi

View File

@ -57,3 +57,8 @@ function travis_isWindows() {
function get_pom_version() {
echo $(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:3.0.0:exec)
}
function change_ruby_version() {
source "$HOME/.rvm/scripts/rvm"
rvm use ruby-2.7
}

View File

@ -2,36 +2,38 @@
set -e
#
# AdoptOpenJDK Builds from:
# https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/tag/jdk-11.0.4%2B11
# Downloads AdoptOpenJDK Builds from
# https://pmd-code.org/openjdk/latest/jdk-11-linux64.tar.gz
# https://pmd-code.org/openjdk/latest/jdk-11-windows64.zip
# https://pmd-code.org/openjdk/latest/jdk-11-mac64.tar.gz
#
# The Build are originally from:
# https://github.com/AdoptOpenJDK/openjdk11-binaries/releases
#
source .travis/logger.sh
source .travis/common-functions.sh
# VERSION_TAG e.g. "11.0.4+11" or "13+33"
VERSION_TAG=$1
OPENJDK_MAJOR=${VERSION_TAG/.*/}
OPENJDK_MAJOR=${OPENJDK_MAJOR/+*/}
#BASE_URL=https://github.com/AdoptOpenJDK/openjdk${OPENJDK_MAJOR}-binaries/releases/download
BASE_URL=https://pmd-code.org/openjdk
# OPENJDK_VERSION e.g. "11"
OPENJDK_VERSION=$1
BASE_URL=https://pmd-code.org/openjdk/latest/jdk-${OPENJDK_VERSION}-
log_info "Installing OpenJDK${OPENJDK_MAJOR}U ${VERSION_TAG} for ${TRAVIS_OS_NAME}"
log_info "Installing OpenJDK${OPENJDK_VERSION} for ${TRAVIS_OS_NAME}"
if travis_isOSX; then
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_mac_hotspot_${VERSION_TAG/+/_}.tar.gz
DOWNLOAD_URL=${BASE_URL}mac64.tar.gz
COMPONENTS_TO_STRIP=3 # e.g. jdk-11.0.3+7/Contents/Home/bin/java
elif travis_isWindows; then
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_windows_hotspot_${VERSION_TAG/+/_}.zip
DOWNLOAD_URL=${BASE_URL}windows64.zip
else
DOWNLOAD_URL=${BASE_URL}/jdk-${VERSION_TAG/+/%2B}/OpenJDK${OPENJDK_MAJOR}U-jdk_x64_linux_hotspot_${VERSION_TAG/+/_}.tar.gz
DOWNLOAD_URL=${BASE_URL}linux64.tar.gz
COMPONENTS_TO_STRIP=1 # e.g. openjdk-11.0.3+7/bin/java
fi
OPENJDK_ARCHIVE=$(basename $DOWNLOAD_URL)
LOCAL_DIR=${HOME}/.cache/openjdk
TARGET_DIR=${HOME}/openjdk${OPENJDK_MAJOR}
TARGET_DIR=${HOME}/openjdk${OPENJDK_VERSION}
mkdir -p ${LOCAL_DIR}
mkdir -p ${TARGET_DIR}

View File

@ -1,23 +1,67 @@
<?xml version="1.0"?>
<projectlist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="projectlist_1_0_0.xsd">
xsi:noNamespaceSchemaLocation="projectlist_1_1_0.xsd">
<description>Standard Projects</description>
<project>
<name>checkstyle</name>
<type>git</type>
<!-- <connection>https://github.com/checkstyle/checkstyle</connection> -->
<connection>https://github.com/pmd/checkstyle</connection>
<tag>checkstyle-8.10-pmd-regression</tag>
<connection>https://github.com/checkstyle/checkstyle</connection>
<tag>checkstyle-8.10</tag>
<exclude-pattern>.*/target/test-classes/com/puppycrawl/tools/checkstyle/.*</exclude-pattern>
<exclude-pattern>.*/target/generated-sources/.*</exclude-pattern>
<build-command><![CDATA[#!/usr/bin/env bash
if test -e classpath.txt; then
exit
fi
mvn test-compile
mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=classpath.txt
]]></build-command>
<auxclasspath-command>echo -n "$(pwd)/target/classes:$(pwd)/target/test-classes:"; cat classpath.txt</auxclasspath-command>
</project>
<project>
<name>spring-framework</name>
<type>git</type>
<!-- <connection>https://github.com/spring-projects/spring-framework</connection> -->
<connection>https://github.com/pmd/spring-framework</connection>
<tag>v5.0.6.RELEASE-pmd-regression</tag>
<connection>https://github.com/spring-projects/spring-framework</connection>
<tag>v5.0.6.RELEASE</tag>
<build-command><![CDATA[#!/usr/bin/env bash
if test -e classpath.txt; then
exit
fi
# Note: openjdk8 will be installed by "before_install.sh"
JAVA_HOME=${HOME}/openjdk8
PATH=$JAVA_HOME/bin:$PATH
./gradlew build -x javadoc -x dokka -x asciidoctor -x test -x testNG -x api -x distZip
cat >> build.gradle <<EOF
task createSquishClasspath {
doLast {
def dependencies = new HashSet()
dependencies.addAll(subprojects.configurations.compile.resolvedConfiguration.resolvedArtifacts.file.flatten())
dependencies.addAll(subprojects.configurations.optional.resolvedConfiguration.resolvedArtifacts.file.flatten())
dependencies.addAll(subprojects.configurations.testCompile.resolvedConfiguration.resolvedArtifacts.file.flatten())
dependencies.addAll(subprojects.configurations.testRuntime.resolvedConfiguration.resolvedArtifacts.file.flatten())
def paths = new ArrayList()
paths.addAll(subprojects.jar.outputs.files.asPath)
paths.addAll(subprojects.sourceSets.test.output.resourcesDir)
paths.addAll(subprojects.sourceSets.test.output.classesDirs.files.flatten())
paths.addAll(dependencies)
println paths.join(File.pathSeparator)
}
}
EOF
./gradlew createSquishClasspath -q > classpath.txt
]]></build-command>
<auxclasspath-command>cat classpath.txt</auxclasspath-command>
</project>
<!---<project>

View File

@ -1,6 +1,7 @@
#
# The functions here require the following scripts:
# .travis/logger.sh
# .travis/common-functions.sh
#
# The functions here require the following environment variables:
# PMD_SF_USER
@ -12,6 +13,7 @@
# In that case, just a error logging is provided.
#
function regression-tester_uploadBaseline() {
change_ruby_version
log_debug "$FUNCNAME branch=${TRAVIS_BRANCH}"
local targetUrl="https://sourceforge.net/projects/pmd/files/pmd-regression-tester/"
@ -49,6 +51,7 @@ function regression-tester_uploadBaseline() {
# In that case, just a error logging is provided.
#
function regression-tester_executeDanger() {
change_ruby_version
log_debug "$FUNCNAME"
local errexitstate="$(shopt -po errexit)"

View File

@ -25,7 +25,7 @@ limitations apply:
* Generally give **different results on Windows and Unix** because of different newlines.
(carriage return linefeed on Windows, linefeed on Unixes).
We build our releases under **Linux** on [Travis CI](https://travis-ci.org/pmd/pmd).
We build our releases under **Linux** on [Travis CI](https://travis-ci.com/pmd/pmd).
* Generally depend on the **major version of the JDK** used to compile. (Even with source/target defined,
each major JDK version changes the generated bytecode.).

View File

@ -7,6 +7,7 @@ require 'fileutils'
def get_args(base_branch)
['--local-git-repo', './pmd',
'--list-of-project', './pmd/.travis/project-list.xml',
'--base-branch', base_branch,
'--patch-branch', 'HEAD',
'--patch-config', './pmd/.travis/all-java.xml',

View File

@ -1,6 +1,6 @@
GIT
remote: https://github.com/pmd/pmd-regression-tester.git
revision: 2d250897c6f4f51cb8f9a372887193e9e5e2c7b1
revision: 6875868e8be772807498ab46411e44d163633d64
specs:
pmdtester (1.1.0.pre.SNAPSHOT)
differ (~> 0.1)
@ -41,9 +41,9 @@ GEM
multipart-post (>= 1.2, < 3)
faraday-http-cache (1.3.1)
faraday (~> 0.8)
fugit (1.3.9)
fugit (1.4.0)
et-orbi (~> 1.1, >= 1.1.8)
raabro (~> 1.3)
raabro (~> 1.4)
git (1.7.0)
rchardet (~> 1.8)
kramdown (1.17.0)
@ -54,7 +54,7 @@ GEM
no_proxy_fix (0.1.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
octokit (4.18.0)
octokit (4.19.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
open4 (1.3.4)

View File

@ -3,7 +3,7 @@
![PMD Logo](https://raw.githubusercontent.com/pmd/pmd/pmd/7.0.x/docs/images/logo/pmd-logo-300px.png)
[![Join the chat at https://gitter.im/pmd/pmd](https://badges.gitter.im/pmd/pmd.svg)](https://gitter.im/pmd/pmd?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/pmd/pmd.svg?branch=master)](https://travis-ci.org/pmd/pmd)
[![Build Status](https://travis-ci.com/pmd/pmd.svg?branch=master)](https://travis-ci.com/pmd/pmd)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd/badge.svg)](https://maven-badges.herokuapp.com/maven-central/net.sourceforge.pmd/pmd)
[![Reproducible Builds](https://img.shields.io/badge/Reproducible_Builds-ok-green?labelColor=blue)](https://github.com/jvm-repo-rebuild/reproducible-central#net.sourceforge.pmd:pmd)
[![Coverage Status](https://coveralls.io/repos/github/pmd/pmd/badge.svg)](https://coveralls.io/github/pmd/pmd)

View File

@ -163,7 +163,7 @@ git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
echo
echo "Tag has been pushed.... now check travis build: <https://travis-ci.org/pmd/pmd>"
echo "Tag has been pushed.... now check travis build: <https://travis-ci.com/pmd/pmd>"
echo
echo
echo "Press enter to continue..."

View File

@ -18,7 +18,7 @@ The complete source code can be found on github:
## Continuous Integration
We use [Travis CI](https://travis-ci.org/pmd) as our ci service. The main repo and the eclipse plugin are built for
We use [Travis CI](https://travis-ci.com/pmd) as our ci service. The main repo and the eclipse plugin are built for
every push. Each pull request is built as well.
The maven snapshot artifacts are deployed at [Sonatypes OSS snapshot repository](https://oss.sonatype.org/content/repositories/snapshots/net/sourceforge/pmd/pmd/).

View File

@ -6,7 +6,7 @@ author: Romain Pelisse <rpelisse@users.sourceforge.net>, Andreas Dangel <adangel
This page describes the current status of the release process.
Since versions 5.4.5 / 5.5.4 there is an automated release process using [travis-ci](https://travis-ci.org)
Since versions 5.4.5 / 5.5.4 there is an automated release process using [travis-ci](https://travis-ci.com)
in place. However, there are still a few steps, that need manual examination.
Note: You can find a small shell script in the root of the repo: `do-release.sh`. This script guides you

View File

@ -97,6 +97,18 @@ represented by our 1.0 implementation as strings, meaning that `@BeginLine > "1"
worked ---that's not the case in 2.0 mode.
* <code>@ArgumentCount > <b style="color:red">'</b>1<b style="color:red">'</b></code> &rarr; `@ArgumentCount > 1`
* In XPath 1.0, the expression `/Foo` matches the *children* of the root named `Foo`.
In XPath 2.0, that expression matches the root, if it is named `Foo`. Consider the following tree:
```java
Foo
└─ Foo
└─ Foo
```
Then `/Foo` will match the root in XPath 2, and the other nodes (but not the root) in XPath 1.
See eg [an issue caused by this](https://github.com/pmd/pmd/issues/1919#issuecomment-512865434) in Apex,
with nested classes.
## Rule properties
**See [Defining rule properties](pmd_userdocs_extending_defining_properties.html#for-xpath-rules)**

View File

@ -21,9 +21,12 @@ This is a {{ site.pmd.release_type }} release.
### Fixed Issues
* pmd-core
* [#1939](https://github.com/pmd/pmd/issues/1939): \[core] XPath expressions return handling
### API Changes
### External Contributions
{% endtocmaker %}

View File

@ -23,7 +23,7 @@ import net.sf.saxon.type.Type;
/**
* See {@link AstTreeInfo#getRootNode()}.
*/
class AstDocumentNode extends BaseNodeInfo {
class AstDocumentNode extends BaseNodeInfo implements AstNodeOwner {
private final AstElementNode rootElement;
private final List<AstElementNode> children;
@ -68,6 +68,8 @@ class AstDocumentNode extends BaseNodeInfo {
@Override
public Node getUnderlyingNode() {
// this is a concession to the model, so that the expression "/"
// may be interpreted as the root node
return rootElement.getUnderlyingNode();
}

View File

@ -37,7 +37,7 @@ import net.sf.saxon.type.Type;
* A wrapper for Saxon around a Node. Note: the {@link RootNode} of a tree
* corresponds to both a document node and an element node that is its child.
*/
public final class AstElementNode extends BaseNodeInfo implements SiblingCountingNode {
public final class AstElementNode extends BaseNodeInfo implements SiblingCountingNode, AstNodeOwner {
private final Node wrappedNode;
/** The index of the node in the tree according to document order */

View File

@ -0,0 +1,15 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.rule.xpath.internal;
import net.sourceforge.pmd.lang.ast.Node;
/**
* Marker interface.
*/
public interface AstNodeOwner {
Node getUnderlyingNode();
}

View File

@ -121,17 +121,15 @@ public class SaxonXPathRuleQuery {
SequenceIterator iterator = expression.iterate(xpathDynamicContext.getXPathContextObject());
Item current = iterator.next();
while (current != null) {
if (current instanceof AstElementNode) {
results.add(((AstElementNode) current).getUnderlyingNode());
if (current instanceof AstNodeOwner) {
results.add(((AstNodeOwner) current).getUnderlyingNode());
} else {
throw new RuntimeException("XPath rule expression returned a non-node (" + current.getClass() + "): " + current);
}
current = iterator.next();
}
}
/*
Map List of Saxon Nodes -> List of AST Nodes, which were detected to match the XPath expression
(i.e. violation found)
*/
final List<Node> sortedRes = new ArrayList<>(results);
sortedRes.sort(RuleChainAnalyzer.documentOrderComparator());
return sortedRes;

View File

@ -16,8 +16,11 @@ import java.util.List;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import net.sourceforge.pmd.lang.ast.DummyNodeWithListAndEnum;
import net.sourceforge.pmd.lang.ast.DummyRoot;
@ -39,6 +42,9 @@ import net.sf.saxon.value.SequenceType;
public class SaxonXPathRuleQueryTest {
@Rule
public final ExpectedException expected = ExpectedException.none();
// Unsupported: https://github.com/pmd/pmd/issues/2451
// @Test
// public void testListAttribute() {
@ -95,6 +101,45 @@ public class SaxonXPathRuleQueryTest {
assertQuery(1, "//dummyRootNode[@Enum = $prop]", dummy, prop);
}
@Test
public void testInvalidReturn() {
DummyNodeWithListAndEnum dummy = new DummyNodeWithListAndEnum();
expected.expect(RuntimeException.class);
expected.expectMessage(CoreMatchers.containsString("XPath rule expression returned a non-node"));
expected.expectMessage(CoreMatchers.containsString("Int64Value"));
createQuery("1+2").evaluate(dummy);
}
@Test
public void testRootExpression() {
DummyRoot dummy = new DummyRoot();
List<Node> result = assertQuery(1, "/", dummy);
Assert.assertEquals(dummy, result.get(0));
}
@Test
public void testRootExpressionIsADocumentNode() {
DummyRoot dummy = new DummyRoot();
List<Node> result = assertQuery(1, "(/)[self::document-node()]", dummy);
Assert.assertEquals(dummy, result.get(0));
}
@Test
public void testRootExpressionWithName() {
DummyRoot dummy = new DummyRoot();
String xpathName = dummy.getXPathNodeName();
List<Node> result = assertQuery(1, "(/)[self::document-node(element(" + xpathName + "))]", dummy);
Assert.assertEquals(dummy, result.get(0));
assertQuery(0, "(/)[self::document-node(element(DummyNodeX))]", dummy);
}
@Test
public void ruleChainVisits() {
SaxonXPathRuleQuery query = createQuery("//dummyNode[@Image='baz']/foo | //bar[@Public = 'true'] | //dummyNode[@Public = false()] | //dummyNode");
@ -288,10 +333,11 @@ public class SaxonXPathRuleQueryTest {
.replaceAll("\\$zz:zz-?\\d+", "\\$zz:zz000");
}
private static void assertQuery(int resultSize, String xpath, Node node, PropertyDescriptor<?>... descriptors) {
private static List<Node> assertQuery(int resultSize, String xpath, Node node, PropertyDescriptor<?>... descriptors) {
SaxonXPathRuleQuery query = createQuery(xpath, descriptors);
List<Node> result = query.evaluate(node);
assertEquals("Wrong number of matched nodes", resultSize, result.size());
return result;
}
private static SaxonXPathRuleQuery createQuery(String xpath, PropertyDescriptor<?>... descriptors) {

View File

@ -4,16 +4,17 @@
package net.sourceforge.pmd.lang.java.ast
import io.kotest.core.config.Project
import io.kotest.core.spec.style.DslDrivenSpec
import io.kotest.core.config.configuration
import io.kotest.core.spec.DslDrivenSpec
import io.kotest.core.spec.style.scopes.Lifecycle
import io.kotest.core.spec.style.scopes.RootScope
import io.kotest.core.spec.style.scopes.RootTestRegistration
import io.kotest.core.test.createTestName
import io.kotest.core.test.TestCaseConfig
import io.kotest.core.test.TestContext
import io.kotest.core.test.TestName
import io.kotest.core.test.TestType
import io.kotest.matchers.Matcher
import io.kotest.matchers.should as kotlintestShould
import io.kotest.runner.junit.platform.IntelliMarker
import net.sourceforge.pmd.lang.ast.Node
import net.sourceforge.pmd.lang.ast.ParseException
@ -24,7 +25,8 @@ import net.sourceforge.pmd.lang.ast.test.shouldMatchN
import net.sourceforge.pmd.lang.java.types.JTypeMirror
import net.sourceforge.pmd.lang.java.types.TypeDslMixin
import net.sourceforge.pmd.lang.java.types.TypeDslOf
import io.kotest.matchers.should as kotlintestShould
import net.sourceforge.pmd.lang.ast.test.Assertions
import net.sourceforge.pmd.lang.ast.test.IntelliMarker
/**
* Base class for grammar tests that use the DSL. Tests are layered into
@ -42,11 +44,15 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec()
override fun lifecycle(): Lifecycle = Lifecycle.from(this)
override fun defaultConfig(): TestCaseConfig = actualDefaultConfig()
override fun defaultTestCaseConfig(): TestCaseConfig? = defaultTestConfig
override fun registration(): RootTestRegistration = RootTestRegistration.from(this)
private fun actualDefaultConfig() =
defaultTestConfig ?: defaultTestCaseConfig() ?: configuration.defaultTestConfig
fun test(name: String, disabled: Boolean = false, test: suspend TestContext.() -> Unit) =
registration().addTest(
name = TestName(name),
name = createTestName(name),
xdisabled = disabled,
test = test,
config = actualDefaultConfig()
@ -72,7 +78,7 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec()
disabled: Boolean = false,
spec: suspend GroupTestCtx.() -> Unit) =
registration().addContainerTest(
name = TestName(name),
name = createTestName(name),
test = { GroupTestCtx(this).spec() },
xdisabled = disabled
)
@ -128,7 +134,7 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec()
assertions: suspend ParserTestCtx.() -> Unit) {
context.registerTestCase(
name = TestName(name),
name = createTestName(name),
test = { ParserTestCtx(javaVersion).apply { setup() }.assertions() },
config = actualDefaultConfig(),
type = TestType.Test
@ -153,7 +159,7 @@ abstract class ParserTestSpec(body: ParserTestSpec.() -> Unit) : DslDrivenSpec()
javaVersions.forEach { javaVersion ->
context.registerTestCase(
name = TestName("Java ${javaVersion.pmdName}"),
name = createTestName("Java ${javaVersion.pmdName}"),
test = { VersionedTestCtx(this, javaVersion).apply { setup() }.spec() },
config = actualDefaultConfig(),
type = TestType.Container

View File

@ -3293,16 +3293,14 @@ public class UnusedAssignmentNative {
<expected-problems>1</expected-problems>
<expected-linenumbers>2</expected-linenumbers>
<expected-messages>
<message>The field initializer for 'b' is never used (overwritten on line 9)</message>
<message>The field initializer for 'b' is never used (overwritten on line 7)</message>
</expected-messages>
<code><![CDATA[
class Test {
static int b = 0;
Test() {
System.out.println(b); // does not count as usage
}
static {
b = 2;
}

View File

@ -62,32 +62,11 @@
<execution>
<phase>package</phase>
<goals>
<!--
once https://github.com/Kotlin/dokka/issues/294 is fixed, use goal javadocJar instead
and remove the additional jar plugin execution
-->
<goal>dokka</goal>
<goal>javadocJar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>kotlin-javadoc</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classesDirectory>${project.build.directory}/dokka/pmd-lang-test</classesDirectory>
<classifier>javadoc</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -0,0 +1,21 @@
/*
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.ast.test
import org.junit.jupiter.api.TestFactory
import org.junit.jupiter.api.condition.EnabledIfSystemProperty
/**
* This is to trick Intellij into making subclasses executable (because of @TestFactory).
* But Junit does not use it because of the unsatisfiable condition. This comes from
* Kotest, but was removed in 4.2.0 without explanation.
*/
interface IntelliMarker {
@EnabledIfSystemProperty(named = "wibble", matches = "wobble")
@TestFactory
fun primer() {
}
}

View File

@ -19,7 +19,7 @@
<url>https://pmd.github.io/</url>
<ciManagement>
<url>https://travis-ci.org/pmd/pmd</url>
<url>https://travis-ci.com/pmd/pmd</url>
</ciManagement>
<inceptionYear>2002</inceptionYear>
<licenses>
@ -85,9 +85,9 @@
<kotlin.compiler.jvmTarget>${maven.compiler.test.target}</kotlin.compiler.jvmTarget>
<kotlin.version>1.3.72</kotlin.version>
<kotest.version>4.1.2</kotest.version>
<dokka.version>0.10.1</dokka.version>
<kotlin.version>1.4.10</kotlin.version>
<kotest.version>4.3.0</kotest.version>
<dokka.version>1.4.10.2</dokka.version>
<javacc.version>5.0</javacc.version>