Merge branch 'xpath-warnings' of github.com:oowekyala/pmd into pr-2425
This commit is contained in:
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
23
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -1,10 +1,19 @@
|
||||
<!--
|
||||
Please, prefix the PR title with the language it applies to within brackets, such as *[java]* or *[apex]*. If not specific to a language, you can use *[core]*
|
||||
-->
|
||||
## Describe the PR
|
||||
|
||||
Before submitting a PR, please check that:
|
||||
- [ ] The PR is submitted against `master`. The PMD team will merge back to support branches as needed.
|
||||
- [ ] `./mvnw clean verify` passes. This will [build](https://github.com/pmd/pmd/blob/master/BUILDING.md) and test PMD, execute PMD and checkstyle rules. [Check this for more info](https://github.com/pmd/pmd/blob/master/CONTRIBUTING.md#code-style)
|
||||
<!-- A clear and concise description of the bug the PR fixes or the feature the PR introduces. -->
|
||||
|
||||
**PR Description:**
|
||||
## Related issues
|
||||
|
||||
<!-- PR relates to issues in the `pmd` repo: -->
|
||||
|
||||
- Fixes #
|
||||
|
||||
## Ready?
|
||||
|
||||
<!-- If you feel like you can help to check off the following tasks, that'd be great. If not, don't worry - we will take care of it. -->
|
||||
|
||||
- [ ] Added unit tests for fixed bug/feature
|
||||
- [ ] Passing all unit tests
|
||||
- [ ] Complete build `./mvnw clean verify` passes (checked automatically by travis)
|
||||
- [ ] Added (in-code) documentation (if needed)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# Make sure, everything is English...
|
||||
@ -15,7 +15,7 @@ if [ ! -f pom.xml -o ! -d ../pmd.github.io ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
LAST_VERSION=
|
||||
RELEASE_VERSION=
|
||||
DEVELOPMENT_VERSION=
|
||||
CURRENT_BRANCH=
|
||||
@ -33,11 +33,16 @@ PATCH=$(echo $RELEASE_VERSION | cut -d . -f 3)
|
||||
if [ "$PATCH" == "0" ]; then
|
||||
NEXT_MINOR=$(expr ${MINOR} + 1)
|
||||
NEXT_PATCH="0"
|
||||
LAST_MINOR=$(expr ${MINOR} - 1)
|
||||
LAST_PATCH="0"
|
||||
else
|
||||
# this is a bugfixing release
|
||||
NEXT_MINOR="${MINOR}"
|
||||
NEXT_PATCH=$(expr ${PATCH} + 1)
|
||||
LAST_MINOR="${MINOR}"
|
||||
LAST_PATCH=$(expr ${PATCH} - 1)
|
||||
fi
|
||||
LAST_VERSION="$MAJOR.$LAST_MINOR.$LAST_PATCH"
|
||||
DEVELOPMENT_VERSION="$MAJOR.$NEXT_MINOR.$NEXT_PATCH"
|
||||
DEVELOPMENT_VERSION="${DEVELOPMENT_VERSION}-SNAPSHOT"
|
||||
|
||||
@ -52,17 +57,18 @@ CURRENT_BRANCH=$(git symbolic-ref -q HEAD)
|
||||
CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/}
|
||||
CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD}
|
||||
|
||||
echo "RELEASE_VERSION: ${RELEASE_VERSION}"
|
||||
echo "DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION}"
|
||||
echo "LAST_VERSION: ${LAST_VERSION}"
|
||||
echo "RELEASE_VERSION: ${RELEASE_VERSION} (this release)"
|
||||
echo "DEVELOPMENT_VERSION: ${DEVELOPMENT_VERSION} (the next version after the release)"
|
||||
echo "CURRENT_BRANCH: ${CURRENT_BRANCH}"
|
||||
|
||||
echo
|
||||
echo "Is this correct?"
|
||||
echo
|
||||
echo "Press enter to continue..."
|
||||
echo "Press enter to continue... (or CTRL+C to cancel)"
|
||||
read
|
||||
|
||||
|
||||
export LAST_VERSION
|
||||
export RELEASE_VERSION
|
||||
export DEVELOPMENT_VERSION
|
||||
export CURRENT_BRANCH
|
||||
@ -89,6 +95,26 @@ echo
|
||||
echo "Press enter to continue..."
|
||||
read
|
||||
|
||||
|
||||
# calculating stats for release notes
|
||||
|
||||
STATS=$(
|
||||
echo "### Stats"
|
||||
echo "* $(git log pmd_releases/${LAST_VERSION}..HEAD --oneline --no-merges |wc -l) commits"
|
||||
echo "* $(curl -s https://api.github.com/repos/pmd/pmd/milestones|jq ".[] | select(.title == \"$RELEASE_VERSION\") | .closed_issues") closed tickets & PRs"
|
||||
echo "* Days since last release: $(( ( $(date +%s) - $(git log --max-count=1 --format="%at" pmd_releases/${LAST_VERSION}) ) / 86400))"
|
||||
)
|
||||
|
||||
TEMP_RELEASE_NOTES=$(cat docs/pages/release_notes.md)
|
||||
TEMP_RELEASE_NOTES=${TEMP_RELEASE_NOTES/\{\% endtocmaker \%\}/$STATS$'\n'$'\n'\{\% endtocmaker \%\}$'\n'}
|
||||
echo "${TEMP_RELEASE_NOTES}" > docs/pages/release_notes.md
|
||||
|
||||
echo
|
||||
echo "Updated stats in release notes:"
|
||||
echo "$STATS"
|
||||
echo
|
||||
echo
|
||||
|
||||
# install bundles needed for rendering release notes
|
||||
bundle install --with=release_notes_preprocessing --path vendor/bundle
|
||||
|
||||
|
@ -53,6 +53,25 @@ The designer lives at [pmd/pmd-designer](https://github.com/pmd/pmd-designer).
|
||||
Update property `pmd-designer.version` in **pom.xml** to reference the latest pmd-designer release.
|
||||
See <https://search.maven.org/search?q=g:net.sourceforge.pmd%20AND%20a:pmd-ui&core=gav> for the available releases.
|
||||
|
||||
Starting with PMD 6.23.0 we'll provide small statistics for every release. This needs to be added
|
||||
to the release notes as the last section. To count the closed issues and pull requests, the milestone
|
||||
on github with the title of the new release is searched. Make sure, there is a milestone
|
||||
on <https://github.com/pmd/pmd/milestones>. The following snippet will
|
||||
create the numbers, that can be attached to the release notes as a last section:
|
||||
|
||||
```shell
|
||||
LAST_VERSION=6.22.0
|
||||
NEW_VERSION=6.23.0
|
||||
NEW_VERSION_COMMITISH=HEAD
|
||||
|
||||
echo "### Stats"
|
||||
echo "* $(git log pmd_releases/${LAST_VERSION}..${NEW_VERSION_COMMITISH} --oneline --no-merges |wc -l) commits"
|
||||
echo "* $(curl -s https://api.github.com/repos/pmd/pmd/milestones|jq ".[] | select(.title == \"$NEW_VERSION\") | .closed_issues") closed tickets & PRs"
|
||||
echo "* Days since last release: $(( ( $(date +%s) - $(git log --max-count=1 --format="%at" pmd_releases/${LAST_VERSION}) ) / 86400))"
|
||||
```
|
||||
|
||||
Note: this part is also integrated into `do-release.sh`.
|
||||
|
||||
Check in all (version) changes to branch master or any other branch, from which the release takes place:
|
||||
|
||||
$ git commit -a -m "Prepare pmd release <version>"
|
||||
|
@ -51,6 +51,8 @@ Note that XPath 1.0 support, the default XPath version, is deprecated since PMD
|
||||
* [#2356](https://github.com/pmd/pmd/issues/2356): \[doc] Add missing doc about pmd.github.io
|
||||
* java
|
||||
* [#2378](https://github.com/pmd/pmd/issues/2378): \[java] AbstractJUnitRule has bad performance on large code bases
|
||||
* java-bestpractices
|
||||
* [#2398](https://github.com/pmd/pmd/issues/2398): \[java] AbstractClassWithoutAbstractMethod false negative with inner abstract classes
|
||||
* java-codestyle
|
||||
* [#1164](https://github.com/pmd/pmd/issues/1164): \[java] ClassNamingConventions suggests to add Util for class containing only static constants
|
||||
* [#1723](https://github.com/pmd/pmd/issues/1723): \[java] UseDiamondOperator false-positive inside lambda
|
||||
@ -60,6 +62,8 @@ Note that XPath 1.0 support, the default XPath version, is deprecated since PMD
|
||||
* [#2402](https://github.com/pmd/pmd/issues/2402): \[java] CloseResource possible false positive with Primitive Streams
|
||||
* java-multithreading
|
||||
* [#2313](https://github.com/pmd/pmd/issues/2313): \[java] Documenation for DoNotUseThreads is outdated
|
||||
* javascript-errorprone
|
||||
* [#384](https://github.com/pmd/pmd/issues/384): \[javascript] Trailing commas not detected on French default locale
|
||||
|
||||
### API Changes
|
||||
|
||||
@ -155,6 +159,7 @@ In the **Java AST** the following attributes are deprecated and will issue a war
|
||||
* [#2403](https://github.com/pmd/pmd/pull/2403): \[java] #2402 fix false-positives on Primitive Streams - [Bernd Farka](https://github.com/BerndFarkaDyna)
|
||||
* [#2409](https://github.com/pmd/pmd/pull/2409): \[java] ClassNamingConventions suggests to add Util for class containing only static constants, fixes #1164 - [Binu R J](https://github.com/binu-r)
|
||||
* [#2411](https://github.com/pmd/pmd/pull/2411): \[java] Fix UseAssertEqualsInsteadOfAssertTrue Example - [Moritz Scheve](https://github.com/Blightbuster)
|
||||
* [#2423](https://github.com/pmd/pmd/pull/2423): \[core] Fix Checkstyle OperatorWrap in AbstractTokenizer - [Harsh Kukreja](https://github.com/harsh-kukreja)
|
||||
|
||||
{% endtocmaker %}
|
||||
|
||||
|
@ -99,7 +99,7 @@ public abstract class AbstractTokenizer implements Tokenizer {
|
||||
private int parseString(StringBuilder token, int loc, char stringDelimiter) {
|
||||
boolean escaped = false;
|
||||
boolean done = false;
|
||||
char tok = ' '; // this will be replaced.
|
||||
char tok;
|
||||
while (loc < currentLine.length() && !done) {
|
||||
tok = currentLine.charAt(loc);
|
||||
if (escaped && tok == stringDelimiter) { // Found an escaped string
|
||||
@ -107,30 +107,24 @@ public abstract class AbstractTokenizer implements Tokenizer {
|
||||
} else if (tok == stringDelimiter && token.length() > 0) {
|
||||
// We are done, we found the end of the string...
|
||||
done = true;
|
||||
} else if (tok == '\\') { // Found an escaped char
|
||||
escaped = true;
|
||||
} else { // Adding char...
|
||||
escaped = false;
|
||||
} else {
|
||||
// Found an escaped char?
|
||||
escaped = tok == '\\';
|
||||
}
|
||||
// Adding char to String:" + token.toString());
|
||||
token.append(tok);
|
||||
loc++;
|
||||
}
|
||||
// Handling multiple lines string
|
||||
if (!done && // ... we didn't find the end of the string
|
||||
loc >= currentLine.length() && // ... we have reach the end of
|
||||
// the line ( the String is
|
||||
// incomplete, for the moment at
|
||||
// least)
|
||||
spanMultipleLinesString && // ... the language allow multiple
|
||||
// line span Strings
|
||||
lineNumber < code.size() - 1 // ... there is still more lines to
|
||||
// parse
|
||||
if (!done // ... we didn't find the end of the string (but the end of the line)
|
||||
&& spanMultipleLinesString // ... the language allow multiple line span Strings
|
||||
&& lineNumber < code.size() - 1 // ... there is still more lines to parse
|
||||
) {
|
||||
// removes last character, if it is the line continuation (e.g.
|
||||
// backslash) character
|
||||
if (spanMultipleLinesLineContinuationCharacter != null && token.length() > 0
|
||||
&& token.charAt(token.length() - 1) == spanMultipleLinesLineContinuationCharacter.charValue()) {
|
||||
if (spanMultipleLinesLineContinuationCharacter != null
|
||||
&& token.length() > 0
|
||||
&& token.charAt(token.length() - 1) == spanMultipleLinesLineContinuationCharacter) {
|
||||
token.deleteCharAt(token.length() - 1);
|
||||
}
|
||||
// parsing new line
|
||||
|
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
@ -228,7 +228,6 @@ public class AbstractNodeTest {
|
||||
assertEquals(0, grandChild.getNumChildren());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeprecatedAttributeXPathQuery() throws JaxenException {
|
||||
class MyRootNode extends DummyNode implements RootNode {
|
||||
@ -248,5 +247,4 @@ public class AbstractNodeTest {
|
||||
assertTrue(log.contains("dummyNode/@Size"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.mozilla.javascript.ScriptRuntime;
|
||||
import org.mozilla.javascript.ast.ArrayComprehension;
|
||||
import org.mozilla.javascript.ast.ArrayComprehensionLoop;
|
||||
import org.mozilla.javascript.ast.ArrayLiteral;
|
||||
@ -220,13 +221,18 @@ public final class EcmascriptTreeBuilder implements NodeVisitor {
|
||||
TrailingCommaNode trailingCommaNode = (TrailingCommaNode) node;
|
||||
int nodeStart = node.getNode().getAbsolutePosition();
|
||||
int nodeEnd = nodeStart + node.getNode().getLength() - 1;
|
||||
|
||||
// This will fetch the localized message
|
||||
// See https://github.com/pmd/pmd/issues/384
|
||||
String trailingCommaLocalizedMessage = ScriptRuntime.getMessage0("msg.extra.trailing.comma");
|
||||
|
||||
for (ParseProblem parseProblem : parseProblems) {
|
||||
|
||||
// The node overlaps the comma (i.e. end of the problem)?
|
||||
int problemStart = parseProblem.getFileOffset();
|
||||
int commaPosition = problemStart + parseProblem.getLength() - 1;
|
||||
if (nodeStart <= commaPosition && commaPosition <= nodeEnd) {
|
||||
if ("Trailing comma is not legal in an ECMA-262 object initializer"
|
||||
.equals(parseProblem.getMessage())) {
|
||||
if (trailingCommaLocalizedMessage.equals(parseProblem.getMessage())) {
|
||||
// Report on the shortest code block containing the
|
||||
// problem (i.e. inner most code in nested structures).
|
||||
EcmascriptNode<?> currentNode = (EcmascriptNode<?>) parseProblemToNode.get(parseProblem);
|
||||
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.rules.TestRule;
|
||||
import org.junit.runner.Description;
|
||||
import org.junit.runners.model.Statement;
|
||||
|
||||
/**
|
||||
* A JUnit rule to change the system locale during a test.
|
||||
*/
|
||||
public class DefaultLocale implements TestRule {
|
||||
|
||||
private boolean statementIsExecuting = false;
|
||||
private Locale loc = Locale.getDefault();
|
||||
|
||||
/** Set the locale value (overwrites previously set value). */
|
||||
public void set(Locale locale) {
|
||||
if (statementIsExecuting) {
|
||||
Locale.setDefault(locale);
|
||||
} else {
|
||||
this.loc = locale;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statement apply(Statement base, Description description) {
|
||||
return new EnvironmentVariablesStatement(base);
|
||||
}
|
||||
|
||||
private class EnvironmentVariablesStatement extends Statement {
|
||||
|
||||
final Statement baseStatement;
|
||||
|
||||
EnvironmentVariablesStatement(Statement baseStatement) {
|
||||
this.baseStatement = baseStatement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
Locale prev = Locale.getDefault();
|
||||
statementIsExecuting = true;
|
||||
try {
|
||||
Locale.setDefault(loc);
|
||||
baseStatement.evaluate();
|
||||
} finally {
|
||||
statementIsExecuting = false;
|
||||
Locale.setDefault(prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TrailingCommaTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Rule
|
||||
public DefaultLocale defaultLocale = new DefaultLocale();
|
||||
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaDefaultLocale() {
|
||||
testTrailingComma();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaFrFr() {
|
||||
defaultLocale.set(Locale.FRANCE);
|
||||
testTrailingComma();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaRootLocale() {
|
||||
defaultLocale.set(Locale.ROOT);
|
||||
testTrailingComma();
|
||||
}
|
||||
|
||||
public void testTrailingComma() {
|
||||
ASTAstRoot node = js.parse("x = {a : 1, };\n");
|
||||
ASTObjectLiteral fn = node.getFirstDescendantOfType(ASTObjectLiteral.class);
|
||||
Assert.assertTrue(fn.isTrailingComma());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user