Merge branch 'master' into cpd_dart_escaped_dollar

This commit is contained in:
Clément Fournier
2020-08-30 16:52:55 +02:00
106 changed files with 229 additions and 202 deletions

View File

@ -23,7 +23,7 @@ folder: pmd/devdocs
* The name of the AST class should be “AST” + “whatever is the name of the node in JJT file”.
* For example, if JJT contains a node called “IfStatement”, there should be a class called “ASTIfStatement”
* Each AST class should have two constructors: one that takes an int id; and one that takes an instance of the parser, and an int id
* Its a good idea to create a parent AST class for all AST classes of the language. This simplies rule creation later. *(see SimpleNode for Velocity and AbstractJavaNode for Java for example)*
* Its a good idea to create a parent AST class for all AST classes of the language. This simplifies rule creation later. *(see SimpleNode for Velocity and AbstractJavaNode for Java for example)*
* Note: These AST node classes are generated usually once by javacc/jjtree and can then be modified as needed.
## 4. Compile your parser (if using JJT)
@ -43,7 +43,7 @@ folder: pmd/devdocs
## 7. Create a rule violation factory
* Extend `AbstractRuleViolationFactory` *(see VmRuleViolationFactory for example)*
* The purpose of this class is to createa rule violation instance specific to your language
* The purpose of this class is to create a rule violation instance specific to your language
## 8. Create a version handler
* Extend `AbstractLanguageVersionHandler` *(see VmHandler for example)*

View File

@ -66,7 +66,7 @@ Starting at line 68 of /home/pmd/source/pmd-core/src/test/java/net/sourceforge/p
ruleReference.setExternalInfoUrl("externalInfoUrl2");
ruleReference.setPriority(RulePriority.MEDIUM_HIGH);
validateOverridenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);
validateOverriddenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);
=====================================================================
Found a 16 line (110 tokens) duplication in the following files:
Starting at line 66 of /home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQueryTest.java
@ -138,7 +138,7 @@ Example:
ruleReference.setExternalInfoUrl("externalInfoUrl2");
ruleReference.setPriority(RulePriority.MEDIUM_HIGH);
validateOverridenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);]]></codefragment>
validateOverriddenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);]]></codefragment>
</duplication>
<duplication lines="16" tokens="110">
<file column="9" endcolumn="28" endline="81" line="66"

View File

@ -246,7 +246,7 @@ the Java framework but it's symmetrical in the Apex framework.
value. That's especially good to implement metrics that count some kind of node,
e.g. [NPath complexity](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/impl/NpathMetric.java)
or [NCSS](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/metrics/impl/NcssMetric.java).
Additionnally, it makes your metric more easily generalisable to other node types.
Additionally, it makes your metric more easily generalisable to other node types.
* *Signature matching metrics:* That's even more straightforward when you want
to count the number of methods or fields that match a specific signature, e.g.

View File

@ -19,7 +19,7 @@ Please check the plugin homepage for more info.
## Continuum
Continous does not have a plugin for PMD per see, but can failed the build according to the
Continuum does not have a plugin for PMD per see, but can failed the build according to the
result of the PMD maven plugin.

View File

@ -190,6 +190,8 @@ are deprecated as internal API.
* [#2732](https://github.com/pmd/pmd/pull/2732): Cleanup: use StandardCharsets instead of Charset.forName - [XenoAmess](https://github.com/XenoAmess)
* [#2733](https://github.com/pmd/pmd/pull/2733): Cleanup: Collection::addAll issues - [XenoAmess](https://github.com/XenoAmess)
* [#2734](https://github.com/pmd/pmd/pull/2734): Cleanup: use try with resources - [XenoAmess](https://github.com/XenoAmess)
* [#2744](https://github.com/pmd/pmd/pull/2744): Cleanup: fix typos - [XenoAmess](https://github.com/XenoAmess)
* [#2749](https://github.com/pmd/pmd/pull/2749): \[dart] \[cpd] Improvements for Dart interpolated strings - [Maikel Steneker](https://github.com/maikelsteneker)
{% endtocmaker %}

View File

@ -53,6 +53,7 @@ public class ApexRuleViolation<T> extends ParametricRuleViolation<Node> {
*
* @deprecated Is internal API, not useful, there's a typo. See <a href="https://github.com/pmd/pmd/pull/1927">#1927</a>
*/
// should be isSuppressed, but as it is already Deprecated, we will not port it.
@Deprecated
public static boolean isSupressed(Node node, Rule rule) {
boolean result = suppresses(node, rule);

View File

@ -52,7 +52,7 @@ program. As such, they include all control flow statements, such as 'if', 'while
Generally, numbers ranging from 1-4 denote low complexity, 5-7 denote moderate complexity, 8-10 denote
high complexity, and 11+ is very high complexity. By default, this rule reports methods with a complexity >= 10.
Additionnally, classes with many methods of moderate complexity get reported as well once the total of their
Additionally, classes with many methods of moderate complexity get reported as well once the total of their
methods' complexities reaches 40, even if none of the methods was directly reported.
Reported methods should be broken down into several smaller methods. Reported classes should probably be broken down

View File

@ -49,13 +49,13 @@ public class ApexParserTest extends ApexParserTestBase {
+ "}\n"; // line 6
@Test
public void verifyLineColumNumbers() {
public void verifyLineColumnNumbers() {
ApexNode<Compilation> rootNode = parse(testCodeForLineNumbers);
assertLineNumbersForTestCode(rootNode);
}
@Test
public void verifyLineColumNumbersWithWindowsLineEndings() {
public void verifyLineColumnNumbersWithWindowsLineEndings() {
String windowsLineEndings = testCodeForLineNumbers.replaceAll(" \n", "\r\n");
ApexNode<Compilation> rootNode = parse(windowsLineEndings);
assertLineNumbersForTestCode(rootNode);

View File

@ -35,7 +35,7 @@ public class Foo {
</test-code>
<test-code>
<description>#1343 MethodNamingConventions for overriden methods</description>
<description>#1343 MethodNamingConventions for overridden methods</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
public class MethodNamingConventions implements SomeInterface {

View File

@ -591,7 +591,7 @@ public class RuleSetFactory {
if (LOG.isLoggable(Level.WARNING)) {
LOG.warning(
"Unable to exclude rules " + excludedRulesCheck + " from ruleset reference " + ref
+ "; perhaps the rule name is mispelled or the rule doesn't exist anymore?");
+ "; perhaps the rule name is misspelled or the rule doesn't exist anymore?");
}
}
@ -684,7 +684,7 @@ public class RuleSetFactory {
if (referencedRule == null) {
throw new IllegalArgumentException("Unable to find referenced rule " + otherRuleSetReferenceId.getRuleName()
+ "; perhaps the rule name is mispelled?");
+ "; perhaps the rule name is misspelled?");
}
if (warnDeprecated && referencedRule.isDeprecated()) {

View File

@ -42,7 +42,7 @@ public final class RulesetsFactoryUtils {
ruleSets = factory.createRuleSets(rulesets);
printRuleNamesInDebug(ruleSets);
if (ruleSets.ruleCount() == 0) {
String msg = "No rules found. Maybe you mispelled a rule name? (" + rulesets + ')';
String msg = "No rules found. Maybe you misspelled a rule name? (" + rulesets + ')';
LOG.log(Level.SEVERE, msg);
throw new IllegalArgumentException(msg);
}

View File

@ -179,7 +179,7 @@ public class TokenEntry implements Comparable<TokenEntry> {
return e.getKey();
}
}
return "--unkown--";
return "--unknown--";
}
final void setImage(String image) {

View File

@ -147,7 +147,12 @@ public final class ClassLoaderUtil {
return parameterTypes;
}
@Deprecated
public static boolean isOverridenMethod(Class<?> clazz, Method method, boolean checkThisClass) {
return isOverriddenMethod(clazz, method, checkThisClass);
}
public static boolean isOverriddenMethod(Class<?> clazz, Method method, boolean checkThisClass) {
try {
if (checkThisClass) {
clazz.getDeclaredMethod(method.getName(), method.getParameterTypes());
@ -158,13 +163,13 @@ public final class ClassLoaderUtil {
}
// Check super class
if (clazz.getSuperclass() != null) {
if (isOverridenMethod(clazz.getSuperclass(), method, true)) {
if (isOverriddenMethod(clazz.getSuperclass(), method, true)) {
return true;
}
}
// Check interfaces
for (Class<?> anInterface : clazz.getInterfaces()) {
if (isOverridenMethod(anInterface, method, true)) {
if (isOverriddenMethod(anInterface, method, true)) {
return true;
}
}

View File

@ -201,13 +201,13 @@ public class UsageNodeVisitor extends NodeVisitorAdapter {
if (methodNode.getUsers().isEmpty()) {
boolean log = true;
if (options.isIgnoreMethodAllOverride()) {
if (ClassLoaderUtil.isOverridenMethod(methodNode.getClassNode().getClass(), methodNode.getMember(),
if (ClassLoaderUtil.isOverriddenMethod(methodNode.getClassNode().getClass(), methodNode.getMember(),
false)) {
ignore("method all override", methodNode);
log = false;
}
} else if (options.isIgnoreMethodJavaLangObjectOverride()) {
if (ClassLoaderUtil.isOverridenMethod(java.lang.Object.class, methodNode.getMember(), true)) {
if (ClassLoaderUtil.isOverriddenMethod(java.lang.Object.class, methodNode.getMember(), true)) {
ignore("method java.lang.Object override", methodNode);
log = false;
}

View File

@ -8,7 +8,7 @@ import java.util.List;
/**
* Interface each Language implementation has to implement. It is used by the
* LanguageRregistry to access constants and implementation classes in order to
* LanguageRegistry to access constants and implementation classes in order to
* provide support for the language.
* <p>
* The following are key components of a Language in PMD:

View File

@ -672,7 +672,7 @@ public abstract class AbstractNode implements Node {
@Override
// @Deprecated // FUTURE 7.0.0 make abstract
public String getXPathNodeName() {
LOG.warning("getXPathNodeName should be overriden in classes derived from AbstractNode. "
LOG.warning("getXPathNodeName should be overridden in classes derived from AbstractNode. "
+ "The implementation is provided for compatibility with existing implementors,"
+ "but could be declared abstract as soon as release " + PMDVersion.getNextMajorRelease()
+ ".");

View File

@ -109,7 +109,7 @@ public abstract class DeprecatedAttrLogger {
if (!replacement.isEmpty()) {
msg += ", please use " + replacement + " instead";
}
// log with execption stack trace to help figure out where exactly the xpath is used.
// log with exception stack trace to help figure out where exactly the xpath is used.
LOG.log(Level.WARNING, msg, new RuntimeException(msg));
}
}

View File

@ -14,7 +14,7 @@ public class LinkerException extends Exception {
public LinkerException() {
// TODO redefinition | accurate?
super("An error occured by computing the data flow paths");
super("An error occurred by computing the data flow paths");
}
public LinkerException(String message) {

View File

@ -80,7 +80,7 @@ public interface XPathRuleQuery {
/**
* Indicates which AST Nodes (if any) should be used with the RuleChain. Use
* of the RuleChain will allow the query execute on a targed sub-tree of the
* of the RuleChain will allow the query execute on a targeted sub-tree of the
* AST, instead of the entire AST from the root. This can result in great
* performance benefits.
*/

View File

@ -75,7 +75,7 @@ import net.sourceforge.pmd.Rule;
}
/* This is the one overriden in PropertyDescriptor */
/* This is the one overridden in PropertyDescriptor */
@Override
public String propertyErrorFor(Rule rule) {
List<V> realValues = rule.getProperty(this);

View File

@ -53,14 +53,14 @@ public class IDEAJRenderer extends AbstractIncrementingRenderer {
if (".method".equals(classAndMethodName)) {
// working on a directory tree
renderDirectoy(writer, violations);
renderDirectory(writer, violations);
} else {
// working on one file
renderFile(writer, violations);
}
}
private void renderDirectoy(Writer writer, Iterator<RuleViolation> violations) throws IOException {
private void renderDirectory(Writer writer, Iterator<RuleViolation> violations) throws IOException {
SourcePath sourcePath = new SourcePath(getProperty(SOURCE_PATH));
StringBuilder buf = new StringBuilder();
while (violations.hasNext()) {

View File

@ -291,14 +291,14 @@ public class TextColorRenderer extends AbstractAccumulatingRenderer {
if (fileName.indexOf(this.pwd) == 0) {
relativePath = "." + fileName.substring(this.pwd.length());
// remove current dir occuring twice - occurs if . was supplied as
// remove current dir occurring twice - occurs if . was supplied as
// path
if (relativePath.startsWith("." + File.separator + "." + File.separator)) {
relativePath = relativePath.substring(2);
}
} else {
// this happens when pmd's supplied argument deviates from the pwd
// 'branch' (god knows this terminolgy - i hope i make some sense).
// 'branch' (god knows this terminology - i hope i make some sense).
// for instance, if supplied=/usr/lots/of/src and
// pwd=/usr/lots/of/shared/source
// TODO: a fix to get relative path?

View File

@ -239,17 +239,17 @@ public class RuleFactory {
* @return A map of property names to their value
*/
private Map<String, String> getPropertyValuesFrom(Element propertiesNode) {
Map<String, String> overridenProperties = new HashMap<>();
Map<String, String> overriddenProperties = new HashMap<>();
for (int i = 0; i < propertiesNode.getChildNodes().getLength(); i++) {
Node node = propertiesNode.getChildNodes().item(i);
if (node.getNodeType() == Node.ELEMENT_NODE && PROPERTY.equals(node.getNodeName())) {
Entry<String, String> overridden = getPropertyValue((Element) node);
overridenProperties.put(overridden.getKey(), overridden.getValue());
overriddenProperties.put(overridden.getKey(), overridden.getValue());
}
}
return overridenProperties;
return overriddenProperties;
}
/**

View File

@ -12,7 +12,7 @@ public interface SearchFunction<E> {
/**
* Applies the search function over a single element.
* @param o The element to analyze.
* @return True if the search should continue, false otherwhise.
* @return True if the search should continue, false otherwise.
*/
boolean applyTo(E o);
}

View File

@ -179,11 +179,11 @@ public class Designer implements ClipboardOwner {
frame.setSize(screenWidth * 3 / 4, screenHeight * 3 / 4);
frame.setLocation((screenWidth - frame.getWidth()) / 2, (screenHeight - frame.getHeight()) / 2);
frame.setVisible(true);
int horozontalMiddleLocation = controlSplitPane.getMaximumDividerLocation() * 3 / 5;
controlSplitPane.setDividerLocation(horozontalMiddleLocation);
int horizontalMiddleLocation = controlSplitPane.getMaximumDividerLocation() * 3 / 5;
controlSplitPane.setDividerLocation(horizontalMiddleLocation);
containerSplitPane.setDividerLocation(containerSplitPane.getMaximumDividerLocation() / 2);
astAndSymbolTablePane.setDividerLocation(astAndSymbolTablePane.getMaximumDividerLocation() / 3);
resultsSplitPane.setDividerLocation(horozontalMiddleLocation);
resultsSplitPane.setDividerLocation(horizontalMiddleLocation);
loadSettings();
}
@ -660,9 +660,9 @@ public class Designer implements ClipboardOwner {
entry.getKey().getClass().getSimpleName() + ": " + entry.getKey());
scopeTreeNode.add(nameDeclarationTreeNode);
for (NameOccurrence nameOccurrence : entry.getValue()) {
DefaultMutableTreeNode nameOccurranceTreeNode = new DefaultMutableTreeNode(
DefaultMutableTreeNode nameOccurrenceTreeNode = new DefaultMutableTreeNode(
"Name occurrence: " + nameOccurrence);
nameDeclarationTreeNode.add(nameOccurranceTreeNode);
nameDeclarationTreeNode.add(nameOccurrenceTreeNode);
}
}
}
@ -890,16 +890,16 @@ public class Designer implements ClipboardOwner {
return b;
}
private static void makeTextComponentUndoable(JTextComponent textConponent) {
private static void makeTextComponentUndoable(JTextComponent textComponent) {
final UndoManager undoManager = new UndoManager();
textConponent.getDocument().addUndoableEditListener(new UndoableEditListener() {
textComponent.getDocument().addUndoableEditListener(new UndoableEditListener() {
@Override
public void undoableEditHappened(UndoableEditEvent evt) {
undoManager.addEdit(evt.getEdit());
}
});
ActionMap actionMap = textConponent.getActionMap();
InputMap inputMap = textConponent.getInputMap();
ActionMap actionMap = textComponent.getActionMap();
InputMap inputMap = textComponent.getInputMap();
actionMap.put("Undo", new AbstractAction("Undo") {
@Override
public void actionPerformed(ActionEvent evt) {

View File

@ -14,7 +14,7 @@ import java.util.logging.LogRecord;
* Log to the console using a basic formatter.
*
* @author Wouter Zelle
* @deprecated This class will be complety removed in 7.0.0
* @deprecated This class will be completely removed in 7.0.0
*/
@Deprecated
public class ConsoleLogHandler extends Handler {

View File

@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.ast.Node;
import net.sourceforge.pmd.util.viewer.model.ViewerModel;
/**
* context sensetive menu for the AST Panel
* context sensitive menu for the AST Panel
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$

View File

@ -7,7 +7,7 @@ package net.sourceforge.pmd.util.viewer.model;
import net.sourceforge.pmd.lang.ast.xpath.Attribute;
/**
* A toolkit for vaious attribute translations
* A toolkit for various attribute translations
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$
@ -21,8 +21,8 @@ public final class AttributeToolkit {
* formats a value for its usage in XPath expressions
*
* @param attribute
* atribute which value should be formatted
* @return formmated value
* attribute which value should be formatted
* @return formatted value
*/
public static String formatValueForXPath(Attribute attribute) {
return '\'' + attribute.getStringValue() + '\'';

View File

@ -108,7 +108,7 @@ public class SimpleNodeTreeNodeAdapter implements TreeNode {
}
/**
* checks the children and creates them if neccessary
* checks the children and creates them if necessary
*/
private void checkChildren() {
if (children == null) {

View File

@ -5,7 +5,7 @@
package net.sourceforge.pmd.util.viewer.model;
/**
* identiefie a listener of the ViewerModel
* identify a listener of the ViewerModel
*
* @author Boris Gruschko ( boris at gruschko.org )
* @version $Id$

Some files were not shown because too many files have changed in this diff Show More