Compare commits
206
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
59b360a60a | ||
|
|
a9dfd6e218 | ||
|
|
3bcecddbb0 | ||
|
|
7ef2168eae | ||
|
|
a895d9d3d9 | ||
|
|
9d9fa22c31 | ||
|
|
ea700d84ec | ||
|
|
3f1c441a5c | ||
|
|
dbcaf663f4 | ||
|
|
14d474f333 | ||
|
|
8dfef6c165 | ||
|
|
ee85254bd0 | ||
|
|
a193af1d4a | ||
|
|
f0ed81751a | ||
|
|
f86ca456a0 | ||
|
|
7616f8b7a8 | ||
|
|
e654c265a9 | ||
|
|
6888806e12 | ||
|
|
cec32a8508 | ||
|
|
579914fb7e | ||
|
|
f9ef2c8c4b | ||
|
|
f335e83043 | ||
|
|
6cd084b7ce | ||
|
|
f00a085087 | ||
|
|
5ebde0a0e9 | ||
|
|
d4c5bd011c | ||
|
|
89db6fe71d | ||
|
|
d699c277ea | ||
|
|
b969974653 | ||
|
|
dba594353f | ||
|
|
f2c8b5e2e8 | ||
|
|
08f1fea25b | ||
|
|
d865fb4627 | ||
|
|
e6e07d22b4 | ||
|
|
da8969ecb7 | ||
|
|
6c9c229516 | ||
|
|
3e24180da1 | ||
|
|
482cb01d7c | ||
|
|
b52bd878f6 | ||
|
|
8f54d451d9 | ||
|
|
87aafcc8ef | ||
|
|
e04f7c2d4f | ||
|
|
d3aa3df15e | ||
|
|
603a306370 | ||
|
|
67acede81f | ||
|
|
b4b52e037b | ||
|
|
1ae8b1c8e6 | ||
|
|
2711d88e3c | ||
|
|
ac3e59a4b7 | ||
|
|
e27dad1862 | ||
|
|
55c34feb97 | ||
|
|
045308948a | ||
|
|
73f6b2f6cf | ||
|
|
9ff4636194 | ||
|
|
0ebd2ba35c | ||
|
|
0f61f2576d | ||
|
|
26e97032ef | ||
|
|
4154a5931e | ||
|
|
ccc1443373 | ||
|
|
eb8908796c | ||
|
|
1f1637bafd | ||
|
|
3c8fcfa6c2 | ||
|
|
0bba8a2249 | ||
|
|
134d529442 | ||
|
|
06e38128c4 | ||
|
|
ba3611f241 | ||
|
|
36ac7ddd4c | ||
|
|
4254fb3f15 | ||
|
|
1301a3821b | ||
|
|
5d2ed89dc1 | ||
|
|
acd365ad98 | ||
|
|
2a6a3c5832 | ||
|
|
0f63ac9131 | ||
|
|
1bd44a3b52 | ||
|
|
844ab0e6d4 | ||
|
|
313da24a71 | ||
|
|
28f292f736 | ||
|
|
c967e63e6a | ||
|
|
58f76f054e | ||
|
|
92da9faee4 | ||
|
|
b6c84e2ba3 | ||
|
|
9eb79af16b | ||
|
|
e643da230d | ||
|
|
f25e35f42d | ||
|
|
d27273581f | ||
|
|
f4441ce938 | ||
|
|
96446f384b | ||
|
|
4514e6fb19 | ||
|
|
451815bf0a | ||
|
|
1577931fe3 | ||
|
|
5ead2eda16 | ||
|
|
53e11481dc | ||
|
|
75b74afe8d | ||
|
|
136d147210 | ||
|
|
309a2a4924 | ||
|
|
8f5b2a04b8 | ||
|
|
6943803ccb | ||
|
|
df2677457c | ||
|
|
161d7be37e | ||
|
|
05ab784d0b | ||
|
|
20cddf5079 | ||
|
|
185fd15953 | ||
|
|
d6ccc58f20 | ||
|
|
5ba5082ae2 | ||
|
|
7a0a31b149 | ||
|
|
9766e632a9 | ||
|
|
2fd5d7c41b | ||
|
|
110c8db6e0 | ||
|
|
c88641fa5c | ||
|
|
87f2403ec3 | ||
|
|
6e2b75e245 | ||
|
|
219b80a13b | ||
|
|
e592d4baf2 | ||
|
|
75ecf7b66f | ||
|
|
4053e548bf | ||
|
|
8bd1e3b486 | ||
|
|
d0ba8998e7 | ||
|
|
d94ff95db8 | ||
|
|
9938a4491c | ||
|
|
4c76a7f695 | ||
|
|
5b93b14373 | ||
|
|
264403b354 | ||
|
|
c85abd258a | ||
|
|
9fb3206d9e | ||
|
|
cf88117820 | ||
|
|
b8a34eda97 | ||
|
|
f452adbf6a | ||
|
|
5972c32ecf | ||
|
|
fb4d564e8b | ||
|
|
f3a358c419 | ||
|
|
7aaa9966c2 | ||
|
|
4ace14899c | ||
|
|
e9abdf7a92 | ||
|
|
ca4500b40b | ||
|
|
9fcf146241 | ||
|
|
d489698157 | ||
|
|
f60a64adb8 | ||
|
|
3d5a0aa4c6 | ||
|
|
f8864e9060 | ||
|
|
f74a6b3887 | ||
|
|
5d590a259e | ||
|
|
07a9859ce3 | ||
|
|
ff1c90d753 | ||
|
|
0967d50275 | ||
|
|
e2c6f1e467 | ||
|
|
4e2aee3da3 | ||
|
|
92031b1792 | ||
|
|
30afff46c6 | ||
|
|
dc4f6b180b | ||
|
|
e43e7316a7 | ||
|
|
534d0b62f2 | ||
|
|
c96358506b | ||
|
|
ba8aeaf648 | ||
|
|
c9cfb1f29f | ||
|
|
0ef1955080 | ||
|
|
fdd399393d | ||
|
|
0e4a793dd3 | ||
|
|
a802fafb29 | ||
|
|
1415d283bc | ||
|
|
8b279fac25 | ||
|
|
65a5d3f835 | ||
|
|
5a5977b1ea | ||
|
|
d6508c1b28 | ||
|
|
c94b3790bf | ||
|
|
57e050f8c5 | ||
|
|
e1b954289a | ||
|
|
c8cd8e1fa8 | ||
|
|
502e96e3a3 | ||
|
|
5bf8945f99 | ||
|
|
8947876dab | ||
|
|
67a9f84a9c | ||
|
|
b71857e02b | ||
|
|
098b0dcac0 | ||
|
|
3c280b8ef2 | ||
|
|
d619fd360d | ||
|
|
3257aeae4f | ||
|
|
f2ba4e442c | ||
|
|
4e3f1395e4 | ||
|
|
6440d043c8 | ||
|
|
ab634bf720 | ||
|
|
8884599f8d | ||
|
|
64a7e3780e | ||
|
|
f330007278 | ||
|
|
f1d0d74087 | ||
|
|
4bb707a3bd | ||
|
|
5ddb5a2a29 | ||
|
|
9b93311c53 | ||
|
|
7db3f4a006 | ||
|
|
8cb7573379 | ||
|
|
733c871b96 | ||
|
|
1d9a2f194d | ||
|
|
40a5e3c569 | ||
|
|
a039788dfb | ||
|
|
3ede676e0a | ||
|
|
8d520b6d8d | ||
|
|
b30d64dd4f | ||
|
|
7e2930be3f | ||
|
|
ba10a60a7c | ||
|
|
1f6fc296c5 | ||
|
|
72a901089f | ||
|
|
332dadce2d | ||
|
|
5fcfb0af8f | ||
|
|
ece8c7e84c | ||
|
|
a3c0f7d3ab | ||
|
|
f7636f27f3 | ||
|
|
55d3bbe881 |
No files matched your search
+4
-3
@@ -29,10 +29,11 @@ When filing a bug report, please provide as much information as possible, so tha
|
||||
|
||||
## Documentation
|
||||
|
||||
There is some documentation available under <https://pmd.github.io>. Feel free to create a bug report if
|
||||
documentation is missing, incomplete or outdated.
|
||||
There is some documentation available under <https://pmd.github.io/pmd>. Feel free to create a bug report if
|
||||
documentation is missing, incomplete or outdated. See [Bug reports](#bug-reports).
|
||||
|
||||
The documentation is generated as a maven site, the source is available at: <https://github.com/pmd/pmd/tree/master/src/site>
|
||||
The documentation is generated as a Jekyll site, the source is available at: <https://github.com/pmd/pmd/tree/master/docs>. You can find build instructions there.
|
||||
For more on contributing documentation check <https://pmd.github.io/pmd/pmd_devdocs_writing_documentation.html>
|
||||
|
||||
## Questions
|
||||
|
||||
|
||||
+13
-7
@@ -86,7 +86,7 @@ git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
|
||||
(
|
||||
echo "Committing current changes (pmd.github.io)"
|
||||
cd ../pmd.github.io
|
||||
git add _posts/$(date -u +%d-%m-%Y)-PMD-${RELEASE_VERSION}.md
|
||||
git add _posts/$(date -u +%Y-%m-%d)-PMD-${RELEASE_VERSION}.md
|
||||
git commit -a -m "Prepare pmd release ${RELEASE_VERSION}"
|
||||
git push
|
||||
)
|
||||
@@ -107,19 +107,20 @@ echo
|
||||
cat <<EOF
|
||||
PMD ${RELEASE_VERSION} released
|
||||
|
||||
* minor version with lots of bug fixes
|
||||
* Release Notes: https://pmd.github.io/pmd-${RELEASE_VERSION}/pmd_release_notes.html
|
||||
* Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F${RELEASE_VERSION}
|
||||
* Fixed Bugs: https://sourceforge.net/p/pmd/bugs/milestone/PMD-${RELEASE_VERSION}/
|
||||
* Documentation: https://pmd.github.io/pmd-${RELEASE_VERSION}/
|
||||
|
||||
And Copy-Paste the release notes
|
||||
EOF
|
||||
echo
|
||||
echo "Press enter to continue..."
|
||||
read
|
||||
|
||||
echo
|
||||
echo "Check the milestone on sourceforge:"
|
||||
echo "<https://sourceforge.net/p/pmd/bugs/milestones>"
|
||||
echo "Check the milestone on github:"
|
||||
echo "<https://github.com/pmd/pmd/milestones>"
|
||||
echo " --> move any open issues to the next milestone, close the current milestone"
|
||||
echo " --> Maybe there are some milestones on sourceforge, too: <https://sourceforge.net/p/pmd/bugs/milestones>."
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
@@ -171,7 +172,12 @@ echo
|
||||
echo "Send out an announcement mail to the mailing list:"
|
||||
echo "To: PMD Developers List <pmd-devel@lists.sourceforge.net>"
|
||||
echo "Subject: [ANNOUNCE] PMD ${RELEASE_VERSION} Released"
|
||||
echo "Body: !!Copy Changelog!!"
|
||||
echo
|
||||
echo " * Downloads: https://github.com/pmd/pmd/releases/tag/pmd_releases%2F${RELEASE_VERSION}"
|
||||
echo " * Documentation: https://pmd.github.io/pmd-${RELEASE_VERSION}/"
|
||||
echo
|
||||
echo " And Copy-Paste the release notes"
|
||||
echo
|
||||
echo
|
||||
echo
|
||||
echo "------------------------------------------"
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
repository: pmd/pmd
|
||||
|
||||
pmd:
|
||||
version: 6.1.0
|
||||
date: 2018-02-25
|
||||
version: 6.2.0
|
||||
date: 2018-03-26
|
||||
|
||||
output: web
|
||||
# this property is useful for conditional filtering of content that is separate from the PDF.
|
||||
|
||||
@@ -17,13 +17,48 @@ The pages are in general in [Github Flavored Markdown](https://kramdown.gettalon
|
||||
|
||||
## Structure
|
||||
|
||||
All documentation is stored in the folder `docs/`. This is the folder, that github and the travis-ci scripts
|
||||
use to render the site.
|
||||
The documentation sources can be found in two places based on how they are generated:
|
||||
- the ones that are manually written (like the one you are reading);
|
||||
- and the ones that are generated automatically from the category files. All the rule documentation
|
||||
pages are generated that way.
|
||||
|
||||
New pages are stored in the different subfolders under `pages`. The folder structure resembles the sidebar structure.
|
||||
### Handwritten documentation
|
||||
|
||||
All handwritten documentation is stored in the subfolders under `docs/pages`. The folder structure resembles the sidebar structure.
|
||||
Since all pages use a simple *permalink*, in the rendered html pages, all pages are flattened in one directory.
|
||||
This makes it easy to view the documentation also offline.
|
||||
|
||||
### Rule documentation
|
||||
|
||||
The categories for a language `%lang%` are located in
|
||||
`pmd-%lang%/src/main/resources/category/%lang% `. So for Java the categories
|
||||
can be found under [pmd-java/src/main/resources/category/java](https://github.com/pmd/pmd/tree/master/pmd-java/src/main/resources/category/java).
|
||||
The XML category files in this directory are transformed during build into markdown pages
|
||||
describing the rules they contain. These pages are placed under `docs/` like the handwritten
|
||||
documentation, and are then rendered with Jekyll like the rest of them. The rule documentation
|
||||
generator is the separate submodule `pmd-doc`.
|
||||
|
||||
Modifying the documentation of a rule should thus not be done on the markdown page,
|
||||
but directly on the XML `rule` tag corresponding to the rule, in the relevant
|
||||
category file.
|
||||
|
||||
The XML documentation of rules can contain GitHub flavoured markdown.
|
||||
Just wrap the markdown inside CDATA section in the xml. CDATA sections preserve
|
||||
all formatting inside the delimiters, and allow to write code samples without
|
||||
escaping special xml characters. For example:
|
||||
```
|
||||
<rule ...>
|
||||
<description>
|
||||
<![CDATA[
|
||||
Full description, can contain markup
|
||||
|
||||
And paragraphs
|
||||
]]>
|
||||
</description>
|
||||
...
|
||||
</rule>
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
There are two ways, to execute jekyll:
|
||||
|
||||
@@ -30,6 +30,7 @@ folder: pmd/rules
|
||||
* [JUnitUseExpected](pmd_rules_java_bestpractices.html#junituseexpected): In JUnit4, use the @Test(expected) annotation to denote tests that should throw exceptions.
|
||||
* [LooseCoupling](pmd_rules_java_bestpractices.html#loosecoupling): The use of implementation types (i.e., HashSet) as object references limits your ability to use a...
|
||||
* [MethodReturnsInternalArray](pmd_rules_java_bestpractices.html#methodreturnsinternalarray): Exposing internal arrays to the caller violates object encapsulation since elements can be remove...
|
||||
* [MissingOverride](pmd_rules_java_bestpractices.html#missingoverride): Annotating overridden methods with @Override ensures at compile time that the method r...
|
||||
* [OneDeclarationPerLine](pmd_rules_java_bestpractices.html#onedeclarationperline): Java allows the use of several variables declaration of the same type on one line. However, itcan...
|
||||
* [PositionLiteralsFirstInCaseInsensitiveComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincaseinsensitivecomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
|
||||
* [PositionLiteralsFirstInComparisons](pmd_rules_java_bestpractices.html#positionliteralsfirstincomparisons): Position literals first in comparisons, if the second argument is null then NullPointerExceptions...
|
||||
@@ -68,6 +69,7 @@ folder: pmd/rules
|
||||
* [ClassNamingConventions](pmd_rules_java_codestyle.html#classnamingconventions): Class names should always begin with an upper case character.
|
||||
* [CommentDefaultAccessModifier](pmd_rules_java_codestyle.html#commentdefaultaccessmodifier): To avoid mistakes if we want that a Method, Constructor, Field or Nested class have a default acc...
|
||||
* [ConfusingTernary](pmd_rules_java_codestyle.html#confusingternary): Avoid negation within an "if" expression with an "else" clause. For example, rephrase:'if (x != ...
|
||||
* [ControlStatementBraces](pmd_rules_java_codestyle.html#controlstatementbraces): Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... els...
|
||||
* [DefaultPackage](pmd_rules_java_codestyle.html#defaultpackage): Use explicit scoping instead of accidental usage of default package private level.The rule allows...
|
||||
* [DontImportJavaLang](pmd_rules_java_codestyle.html#dontimportjavalang): Avoid importing anything from the package 'java.lang'. These classes are automatically imported ...
|
||||
* [DuplicateImports](pmd_rules_java_codestyle.html#duplicateimports): Duplicate or overlapping import statements should be avoided.
|
||||
@@ -75,10 +77,10 @@ folder: pmd/rules
|
||||
* [ExtendsObject](pmd_rules_java_codestyle.html#extendsobject): No need to explicitly extend Object.
|
||||
* [FieldDeclarationsShouldBeAtStartOfClass](pmd_rules_java_codestyle.html#fielddeclarationsshouldbeatstartofclass): Fields should be declared at the top of the class, before any method declarations, constructors, ...
|
||||
* [ForLoopShouldBeWhileLoop](pmd_rules_java_codestyle.html#forloopshouldbewhileloop): Some for loops can be simplified to while loops, this makes them more concise.
|
||||
* [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
|
||||
* [ForLoopsMustUseBraces](pmd_rules_java_codestyle.html#forloopsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using 'for' statements without using curly braces. If the code formatting or indentation is...
|
||||
* [GenericsNaming](pmd_rules_java_codestyle.html#genericsnaming): Names for references to generic values should be limited to a single uppercase letter.
|
||||
* [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
|
||||
* [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): Avoid using if statements without using braces to surround the code block. If the code formatting...
|
||||
* [IfElseStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifelsestmtsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using if..else statements without using surrounding braces. If the code formatting or inden...
|
||||
* [IfStmtsMustUseBraces](pmd_rules_java_codestyle.html#ifstmtsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using if statements without using braces to surround the code block. If the code formatting...
|
||||
* [LocalHomeNamingConvention](pmd_rules_java_codestyle.html#localhomenamingconvention): The Local Home interface of a Session EJB should be suffixed by 'LocalHome'.
|
||||
* [LocalInterfaceSessionNamingConvention](pmd_rules_java_codestyle.html#localinterfacesessionnamingconvention): The Local Interface of a Session EJB should be suffixed by 'Local'.
|
||||
* [LocalVariableCouldBeFinal](pmd_rules_java_codestyle.html#localvariablecouldbefinal): A local variable assigned only once can be declared final.
|
||||
@@ -98,6 +100,7 @@ folder: pmd/rules
|
||||
* [ShortVariable](pmd_rules_java_codestyle.html#shortvariable): Fields, local variables, or parameter names that are very short are not helpful to the reader.
|
||||
* [SuspiciousConstantFieldName](pmd_rules_java_codestyle.html#suspiciousconstantfieldname): Field names using all uppercase characters - Sun's Java naming conventions indicating constants -...
|
||||
* [TooManyStaticImports](pmd_rules_java_codestyle.html#toomanystaticimports): If you overuse the static import feature, it can make your program unreadable and unmaintainable,...
|
||||
* [UnnecessaryAnnotationValueElement](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement): Avoid the use of value in annotations when it's the only element.
|
||||
* [UnnecessaryConstructor](pmd_rules_java_codestyle.html#unnecessaryconstructor): This rule detects when a constructor is not necessary; i.e., when there is only one constructor,i...
|
||||
* [UnnecessaryFullyQualifiedName](pmd_rules_java_codestyle.html#unnecessaryfullyqualifiedname): Import statements allow the use of non-fully qualified names. The use of a fully qualified namew...
|
||||
* [UnnecessaryLocalBeforeReturn](pmd_rules_java_codestyle.html#unnecessarylocalbeforereturn): Avoid the creation of unnecessary local variables
|
||||
@@ -106,7 +109,7 @@ folder: pmd/rules
|
||||
* [UselessParentheses](pmd_rules_java_codestyle.html#uselessparentheses): Useless parentheses should be removed.
|
||||
* [UselessQualifiedThis](pmd_rules_java_codestyle.html#uselessqualifiedthis): Look for qualified this usages in the same class.
|
||||
* [VariableNamingConventions](pmd_rules_java_codestyle.html#variablenamingconventions): A variable naming conventions rule - customize this to your liking. Currently, itchecks for fina...
|
||||
* [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): Avoid using 'while' statements without using braces to surround the code block. If the code forma...
|
||||
* [WhileLoopsMustUseBraces](pmd_rules_java_codestyle.html#whileloopsmustusebraces): <span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f; font-size: 75%;">Deprecated</span> Avoid using 'while' statements without using braces to surround the code block. If the code forma...
|
||||
|
||||
## Design
|
||||
|
||||
@@ -117,7 +120,7 @@ folder: pmd/rules
|
||||
* [AvoidDeeplyNestedIfStmts](pmd_rules_java_design.html#avoiddeeplynestedifstmts): Avoid creating deeply nested if-then statements since they are harder to read and error-prone to ...
|
||||
* [AvoidRethrowingException](pmd_rules_java_design.html#avoidrethrowingexception): Catch blocks that merely rethrow a caught exception only add to code size and runtime complexity.
|
||||
* [AvoidThrowingNewInstanceOfSameException](pmd_rules_java_design.html#avoidthrowingnewinstanceofsameexception): Catch blocks that merely rethrow a caught exception wrapped inside a new instance of the same typ...
|
||||
* [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions. These are confusing because most people will assume that th...
|
||||
* [AvoidThrowingNullPointerException](pmd_rules_java_design.html#avoidthrowingnullpointerexception): Avoid throwing NullPointerExceptions manually. These are confusing because most people will assum...
|
||||
* [AvoidThrowingRawExceptionTypes](pmd_rules_java_design.html#avoidthrowingrawexceptiontypes): Avoid throwing certain exception types. Rather than throw a raw RuntimeException, Throwable,Excep...
|
||||
* [ClassWithOnlyPrivateConstructorsShouldBeFinal](pmd_rules_java_design.html#classwithonlyprivateconstructorsshouldbefinal): A class with only private constructors should be final, unless the private constructoris invoked ...
|
||||
* [CollapsibleIfStatements](pmd_rules_java_design.html#collapsibleifstatements): Sometimes two consecutive 'if' statements can be consolidated by separating their conditions with...
|
||||
|
||||
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_bestpractices.html
|
||||
folder: pmd/rules/java
|
||||
sidebaractiveurl: /pmd_rules_java.html
|
||||
editmepath: ../pmd-java/src/main/resources/category/java/bestpractices.xml
|
||||
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
|
||||
keywords: Best Practices, AbstractClassWithoutAbstractMethod, AccessorClassGeneration, AccessorMethodGeneration, ArrayIsStoredDirectly, AvoidPrintStackTrace, AvoidReassigningParameters, AvoidStringBufferField, AvoidUsingHardCodedIP, CheckResultSet, ConstantsInInterface, DefaultLabelNotLastInSwitchStmt, ForLoopCanBeForeach, GuardLogStatement, JUnit4SuitesShouldUseSuiteAnnotation, JUnit4TestShouldUseAfterAnnotation, JUnit4TestShouldUseBeforeAnnotation, JUnit4TestShouldUseTestAnnotation, JUnitAssertionsShouldIncludeMessage, JUnitTestContainsTooManyAsserts, JUnitTestsShouldIncludeAssert, JUnitUseExpected, LooseCoupling, MethodReturnsInternalArray, MissingOverride, OneDeclarationPerLine, PositionLiteralsFirstInCaseInsensitiveComparisons, PositionLiteralsFirstInComparisons, PreserveStackTrace, ReplaceEnumerationWithIterator, ReplaceHashtableWithMap, ReplaceVectorWithList, SwitchStmtsShouldHaveDefault, SystemPrintln, UnusedFormalParameter, UnusedImports, UnusedLocalVariable, UnusedPrivateField, UnusedPrivateMethod, UseAssertEqualsInsteadOfAssertTrue, UseAssertNullInsteadOfAssertTrue, UseAssertSameInsteadOfAssertTrue, UseAssertTrueInsteadOfAssertEquals, UseCollectionIsEmpty, UseVarargs
|
||||
---
|
||||
## AbstractClassWithoutAbstractMethod
|
||||
|
||||
@@ -783,6 +783,35 @@ public class SecureSystem {
|
||||
<rule ref="category/java/bestpractices.xml/MethodReturnsInternalArray" />
|
||||
```
|
||||
|
||||
## MissingOverride
|
||||
|
||||
**Since:** PMD 6.2.0
|
||||
|
||||
**Priority:** Medium (3)
|
||||
|
||||
**Minimum Language Version:** Java 1.5
|
||||
|
||||
Annotating overridden methods with @Override ensures at compile time that
|
||||
the method really overrides one, which helps refactoring and clarifies intent.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.bestpractices.MissingOverrideRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/bestpractices/MissingOverrideRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
``` java
|
||||
public class Foo implements Runnable {
|
||||
// This method is overridden, and should have an @Override annotation
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/bestpractices.xml/MissingOverride" />
|
||||
```
|
||||
|
||||
## OneDeclarationPerLine
|
||||
|
||||
**Since:** PMD 5.0
|
||||
@@ -1198,6 +1227,12 @@ public class Something {
|
||||
}
|
||||
```
|
||||
|
||||
**This rule has the following properties:**
|
||||
|
||||
|Name|Default Value|Description|
|
||||
|----|-------------|-----------|
|
||||
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor, java.lang.Deprecated, javafx.fxml.FXML]|Fully qualified names of the annotation types that should be ignored by this rule|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/bestpractices.xml/UnusedPrivateField" />
|
||||
@@ -1221,6 +1256,12 @@ public class Something {
|
||||
}
|
||||
```
|
||||
|
||||
**This rule has the following properties:**
|
||||
|
||||
|Name|Default Value|Description|
|
||||
|----|-------------|-----------|
|
||||
|ignoredAnnotations|[java.lang.Deprecated]|Fully qualified names of the annotation types that should be ignored by this rule|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/bestpractices.xml/UnusedPrivateMethod" />
|
||||
|
||||
@@ -5,7 +5,7 @@ permalink: pmd_rules_java_codestyle.html
|
||||
folder: pmd/rules/java
|
||||
sidebaractiveurl: /pmd_rules_java.html
|
||||
editmepath: ../pmd-java/src/main/resources/category/java/codestyle.xml
|
||||
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, GenericsNaming, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
|
||||
keywords: Code Style, AbstractNaming, AtLeastOneConstructor, AvoidDollarSigns, AvoidFinalLocalVariable, AvoidPrefixingMethodParameters, AvoidProtectedFieldInFinalClass, AvoidProtectedMethodInFinalClassNotExtending, AvoidUsingNativeCode, BooleanGetMethodName, CallSuperInConstructor, ClassNamingConventions, CommentDefaultAccessModifier, ConfusingTernary, ControlStatementBraces, DefaultPackage, DontImportJavaLang, DuplicateImports, EmptyMethodInAbstractClassShouldBeAbstract, ExtendsObject, FieldDeclarationsShouldBeAtStartOfClass, ForLoopShouldBeWhileLoop, ForLoopsMustUseBraces, GenericsNaming, IfElseStmtsMustUseBraces, IfStmtsMustUseBraces, LocalHomeNamingConvention, LocalInterfaceSessionNamingConvention, LocalVariableCouldBeFinal, LongVariable, MDBAndSessionBeanNamingConvention, MethodArgumentCouldBeFinal, MethodNamingConventions, MIsLeadingVariableName, NoPackage, OnlyOneReturn, PackageCase, PrematureDeclaration, RemoteInterfaceNamingConvention, RemoteSessionInterfaceNamingConvention, ShortClassName, ShortMethodName, ShortVariable, SuspiciousConstantFieldName, TooManyStaticImports, UnnecessaryAnnotationValueElement, UnnecessaryConstructor, UnnecessaryFullyQualifiedName, UnnecessaryLocalBeforeReturn, UnnecessaryModifier, UnnecessaryReturn, UselessParentheses, UselessQualifiedThis, VariableNamingConventions, WhileLoopsMustUseBraces
|
||||
---
|
||||
## AbstractNaming
|
||||
|
||||
@@ -462,6 +462,65 @@ boolean bar(int x, int y) {
|
||||
<rule ref="category/java/codestyle.xml/ConfusingTernary" />
|
||||
```
|
||||
|
||||
## ControlStatementBraces
|
||||
|
||||
**Since:** PMD 6.2.0
|
||||
|
||||
**Priority:** Medium (3)
|
||||
|
||||
Enforce a policy for braces on control statements. It is recommended to use braces on 'if ... else'
|
||||
statements and loop statements, even if they are optional. This usually makes the code clearer, and
|
||||
helps prepare the future when you need to add another statement. That said, this rule lets you control
|
||||
which statements are required to have braces via properties.
|
||||
|
||||
From 6.2.0 on, this rule supersedes WhileLoopMustUseBraces, ForLoopMustUseBraces, IfStmtMustUseBraces,
|
||||
and IfElseStmtMustUseBraces.
|
||||
|
||||
```
|
||||
//WhileStatement[$checkWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
||||
|
|
||||
//ForStatement[$checkForStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
||||
|
|
||||
//DoStatement[$checkDoWhileStmt and not(Statement/Block) and not($allowEmptyLoop and Statement/EmptyStatement)]
|
||||
|
|
||||
(: The violation is reported on the sub statement -- not the if statement :)
|
||||
//Statement[$checkIfElseStmt and parent::IfStatement and not(child::Block or child::IfStatement)]
|
||||
|
|
||||
(: Reports case labels if one of their subordinate statements is not braced :)
|
||||
//SwitchLabel[$checkCaseStmt]
|
||||
[count(following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement) > 1
|
||||
or (some $stmt (: in only the block statements until the next label :)
|
||||
in following-sibling::BlockStatement except following-sibling::SwitchLabel[1]/following-sibling::BlockStatement
|
||||
satisfies not($stmt/Statement/Block))]
|
||||
```
|
||||
|
||||
**Example(s):**
|
||||
|
||||
``` java
|
||||
while (true) // not recommended
|
||||
x++;
|
||||
|
||||
while (true) { // preferred approach
|
||||
x++;
|
||||
}
|
||||
```
|
||||
|
||||
**This rule has the following properties:**
|
||||
|
||||
|Name|Default Value|Description|
|
||||
|----|-------------|-----------|
|
||||
|checkIfElseStmt|true|Require that 'if ... else' statements use braces|
|
||||
|checkWhileStmt|true|Require that 'while' loops use braces|
|
||||
|checkForStmt|true|Require that 'for' loops should use braces|
|
||||
|checkDoWhileStmt|true|Require that 'do ... while' loops use braces|
|
||||
|checkCaseStmt|false|Require that cases of a switch have braces|
|
||||
|allowEmptyLoop|false|Allow loops with an empty statement, e.g. 'while(true);'|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/codestyle.xml/ControlStatementBraces" />
|
||||
```
|
||||
|
||||
## DefaultPackage
|
||||
|
||||
**Since:** PMD 3.4
|
||||
@@ -682,6 +741,8 @@ public class Foo {
|
||||
|
||||
## ForLoopsMustUseBraces
|
||||
|
||||
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
|
||||
|
||||
**Since:** PMD 0.7
|
||||
|
||||
**Priority:** Medium (3)
|
||||
@@ -749,6 +810,8 @@ public interface GenericDao<EF extends BaseModel, K extends Serializable> {
|
||||
|
||||
## IfElseStmtsMustUseBraces
|
||||
|
||||
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
|
||||
|
||||
**Since:** PMD 0.2
|
||||
|
||||
**Priority:** Medium (3)
|
||||
@@ -784,6 +847,8 @@ if (foo)
|
||||
|
||||
## IfStmtsMustUseBraces
|
||||
|
||||
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
|
||||
|
||||
**Since:** PMD 1.0
|
||||
|
||||
**Priority:** Medium (3)
|
||||
@@ -1431,6 +1496,53 @@ import static Yoko; // Too much !
|
||||
<rule ref="category/java/codestyle.xml/TooManyStaticImports" />
|
||||
```
|
||||
|
||||
## UnnecessaryAnnotationValueElement
|
||||
|
||||
**Since:** PMD 6.2.0
|
||||
|
||||
**Priority:** Medium (3)
|
||||
|
||||
Avoid the use of value in annotations when it's the only element.
|
||||
|
||||
**This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.codestyle.UnnecessaryAnnotationValueElementRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/codestyle/UnnecessaryAnnotationValueElementRule.java)
|
||||
|
||||
**Example(s):**
|
||||
|
||||
``` java
|
||||
@TestClassAnnotation(value = "TEST")
|
||||
public class Foo {
|
||||
|
||||
@TestMemberAnnotation(value = "TEST")
|
||||
private String y;
|
||||
|
||||
@TestMethodAnnotation(value = "TEST")
|
||||
public void bar() {
|
||||
int x = 42;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// should be
|
||||
|
||||
@TestClassAnnotation("TEST")
|
||||
public class Foo {
|
||||
|
||||
@TestMemberAnnotation("TEST")
|
||||
private String y;
|
||||
|
||||
@TestMethodAnnotation("TEST")
|
||||
public void bar() {
|
||||
int x = 42;
|
||||
return;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/codestyle.xml/UnnecessaryAnnotationValueElement" />
|
||||
```
|
||||
|
||||
## UnnecessaryConstructor
|
||||
|
||||
**Since:** PMD 1.0
|
||||
@@ -1771,6 +1883,8 @@ public class Foo {
|
||||
|
||||
## WhileLoopsMustUseBraces
|
||||
|
||||
<span style="border-radius: 0.25em; color: #fff; padding: 0.2em 0.6em 0.3em; display: inline; background-color: #d9534f;">Deprecated</span>
|
||||
|
||||
**Since:** PMD 0.7
|
||||
|
||||
**Priority:** Medium (3)
|
||||
|
||||
@@ -193,9 +193,33 @@ public void bar() {
|
||||
|
||||
**Priority:** High (1)
|
||||
|
||||
Avoid throwing NullPointerExceptions. These are confusing because most people will assume that the
|
||||
virtual machine threw it. Consider using an IllegalArgumentException instead; this will be
|
||||
clearly seen as a programmer-initiated exception.
|
||||
Avoid throwing NullPointerExceptions manually. These are confusing because most people will assume that the
|
||||
virtual machine threw it. To avoid a method being called with a null parameter, you may consider
|
||||
using an IllegalArgumentException instead, making it clearly seen as a programmer-initiated exception.
|
||||
However, there are better ways to handle this:
|
||||
|
||||
>*Effective Java, 3rd Edition, Item 72: Favor the use of standard exceptions*
|
||||
>
|
||||
>Arguably, every erroneous method invocation boils down to an illegal argument or state,
|
||||
but other exceptions are standardly used for certain kinds of illegal arguments and states.
|
||||
If a caller passes null in some parameter for which null values are prohibited, convention dictates that
|
||||
NullPointerException be thrown rather than IllegalArgumentException.
|
||||
|
||||
To implement that, you are encouraged to use `java.util.Objects.requireNonNull()`
|
||||
(introduced in Java 1.7). This method is designed primarily for doing parameter
|
||||
validation in methods and constructors with multiple parameters.
|
||||
|
||||
Your parameter validation could thus look like the following:
|
||||
```
|
||||
public class Foo {
|
||||
private String exampleValue;
|
||||
|
||||
void setExampleValue(String exampleValue) {
|
||||
// check, throw and assignment in a single standard call
|
||||
this.exampleValue = Objects.requireNonNull(exampleValue, "exampleValue must not be null!");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
//AllocationExpression/ClassOrInterfaceType[@Image='NullPointerException']
|
||||
@@ -807,6 +831,12 @@ public class Foo {
|
||||
}
|
||||
```
|
||||
|
||||
**This rule has the following properties:**
|
||||
|
||||
|Name|Default Value|Description|
|
||||
|----|-------------|-----------|
|
||||
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor]|Fully qualified names of the annotation types that should be ignored by this rule|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
<rule ref="category/java/design.xml/ImmutableField" />
|
||||
@@ -1525,6 +1555,7 @@ public class Foo {
|
||||
|----|-------------|-----------|
|
||||
|disallowNotAssignment|false|Disallow violations where the first usage is not an assignment|
|
||||
|checkInnerClasses|false|Check inner classes|
|
||||
|ignoredAnnotations|[lombok.Setter, lombok.Getter, lombok.Builder, lombok.Data, lombok.RequiredArgsConstructor, lombok.AllArgsConstructor, lombok.Value, lombok.NoArgsConstructor]|Fully qualified names of the annotation types that should be ignored by this rule|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
|
||||
@@ -29,7 +29,6 @@ A rule for the politically correct... we don't want to offend anyone.
|
||||
|----|-------------|-----------|
|
||||
|disallowedTerms|[idiot, jerk]|Illegal terms or phrases|
|
||||
|caseSensitive|false|Case sensitive|
|
||||
|wordsAreRegex|false|Use regular expressions|
|
||||
|
||||
**Use this rule by referencing it:**
|
||||
``` xml
|
||||
|
||||
@@ -37,6 +37,7 @@ Without further ado, here is the list of available (single-value) properties:
|
||||
|FileProperty|java.io.File
|
||||
|MethodProperty|java.lang.reflect.Method
|
||||
|TypeProperty|java.lang.Class\<?\>
|
||||
|RegexProperty|java.util.regex.Pattern
|
||||
|
||||
Each of these is complemented by a multivalued variant, whose name ends with "MultiProperty", and which returns a list of values, e.g.
|
||||
|
||||
@@ -45,6 +46,7 @@ Each of these is complemented by a multivalued variant, whose name ends with "Mu
|
||||
|LongMultiProperty | List\<Long\>
|
||||
|EnumeratedMultiProperty\<*E*\>| List\<*E*\>
|
||||
|
||||
Note that RegexProperty doesn't have a multivalued variant, since the delimiters could be part of a specific value.
|
||||
|
||||
### For Java rules
|
||||
|
||||
@@ -121,6 +123,7 @@ XPath rules can also define their own properties. To do so, you must add a `prop
|
||||
|Character|CharacterProperty
|
||||
|Boolean|BooleanProperty
|
||||
|Class|TypeProperty
|
||||
|Regex|RegexProperty
|
||||
|
||||
Note that enumerated properties are not available in XPath rules (yet?).
|
||||
|
||||
|
||||
@@ -244,6 +244,13 @@ The tool comes with a rather extensive help text, simply running with `-help`!
|
||||
<td>no</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>-no-cache</td>
|
||||
<td>Explicitly disable incremental analysis. This switch turns off suggestions to use Incremental Analysis,
|
||||
and causes the <i>-cache</i> option to be discarded if it is provided.
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -253,9 +260,9 @@ Please note that if PMD detects any violations, it will exit with status 4 (sinc
|
||||
This behavior has been introduced to ease PMD integration into scripts or hooks, such as SVN hooks.
|
||||
|
||||
<table>
|
||||
<tr><td>0</td><td>Everything is fine, now violations found</td></tr>
|
||||
<tr><td>0</td><td>Everything is fine, no violations found</td></tr>
|
||||
<tr><td>1</td><td>Couldn't understand command line parameters or PMD exited with an exception</td></tr>
|
||||
<tr><td>4</td><td>At least one violation has been detected unless '-failOnViolation false' is set.</td></tr>
|
||||
<tr><td>4</td><td>At least one violation has been detected, unless '-failOnViolation false' is set.</td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ for you:
|
||||
changing the Rule, but you do not need to submit a patch back to the
|
||||
PMD project.
|
||||
|
||||
If you need to modify the Rule, see [How to write a rule](/pmd_devdocs_writing_pmd_rules.html).
|
||||
If you need to modify the Rule, see [How to write a rule](pmd_devdocs_writing_pmd_rules.html).
|
||||
Otherwise, the other suppression methods are explained in the following sections.
|
||||
|
||||
## Annotations
|
||||
@@ -181,6 +181,6 @@ suppress reporting specifically typed parameters which are unused:
|
||||
Note for XPath based suppression to work, you must know how to write
|
||||
an XPath query that matches the AST structure of the nodes of the
|
||||
violations you wish to suppress. XPath queries are explained in
|
||||
[XPath Rule tutorial](/pmd_devdocs_writing_xpath_rules.html).
|
||||
[XPath Rule tutorial](pmd_userdocs_extending_writing_xpath_rules.html).
|
||||
|
||||
Suggestions? Comments? Post them [here](https://github.com/pmd/pmd/issues). Thanks!
|
||||
@@ -77,7 +77,15 @@ Runs a set of static code analysis rules on some source code files and generates
|
||||
<td>
|
||||
The location of the analysis cache file to be used.
|
||||
Setting this property enables Incremental Analysis, which can greatly improve analysis time without loosing analysis quality.
|
||||
<b>It's use is strongly recommended.</b>
|
||||
<b>Its use is strongly recommended.</b>
|
||||
</td>
|
||||
<td>No</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>noCache</td>
|
||||
<td>
|
||||
Setting this property to true disables Incremental Analysis, even if <i>cacheLocation</i> is provided.
|
||||
You can use this to explicitly turn off suggestions to use incremental analysis, or for testing purposes.
|
||||
</td>
|
||||
<td>No</td>
|
||||
</tr>
|
||||
|
||||
+107
-69
@@ -4,98 +4,136 @@ permalink: pmd_release_notes.html
|
||||
keywords: changelog, release notes
|
||||
---
|
||||
|
||||
## 25-February-2018 - 6.1.0
|
||||
## 26-March-2018 - 6.2.0
|
||||
|
||||
The PMD team is pleased to announce PMD 6.1.0.
|
||||
The PMD team is pleased to announce PMD 6.2.0.
|
||||
|
||||
This is a minor release.
|
||||
|
||||
### Table Of Contents
|
||||
|
||||
* [New and noteworthy](#new-and-noteworthy)
|
||||
* [Designer UI](#designer-ui)
|
||||
* [Fixed Issues](#fixed-issues)
|
||||
* [API Changes](#api-changes)
|
||||
* [Changes to the Node interface](#changes-to-the-node-interface)
|
||||
* [Changes to CPD renderers](#changes-to-cpd-renderers)
|
||||
* [External Contributions](#external-contributions)
|
||||
* [Ecmascript (JavaScript)](#ecmascript-javascript)
|
||||
* [Disable Incremental Analysis](#disable-incremental-analysis)
|
||||
* [New Rules](#new-rules)
|
||||
* [Modified Rules](#modified-rules)
|
||||
* [Fixed Issues](#fixed-issues)
|
||||
* [API Changes](#api-changes)
|
||||
* [External Contributions](#external-contributions)
|
||||
|
||||
### New and noteworthy
|
||||
|
||||
#### Designer UI
|
||||
#### Ecmascript (JavaScript)
|
||||
|
||||
The Designer now supports configuring properties for XPath based rule development.
|
||||
The Designer is still under development and any feedback is welcome.
|
||||
The [Rhino Library](https://github.com/mozilla/rhino) has been upgraded from version 1.7.7 to version 1.7.7.2.
|
||||
|
||||
You can start the designer via `run.sh designer` or `designer.bat`.
|
||||
Detailed changes for changed in Rhino can be found:
|
||||
* [For 1.7.7.2](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1772)
|
||||
* [For 1.7.7.1](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md#rhino-1771)
|
||||
|
||||
Both are bugfixing releases.
|
||||
|
||||
#### Disable Incremental Analysis
|
||||
|
||||
Some time ago, we added support for [Incremental Analysis](pmd_userdocs_getting_started.html). On PMD 6.0.0, we
|
||||
started to add warns when not using it, as we strongly believe it's a great improvement to our user's experience as
|
||||
analysis time is greatly reduced; and in the future we plan to have it enabled by default. However, we realize some
|
||||
scenarios don't benefit from it (ie: CI jobs), and having the warning logged can be noisy and cause confusion.
|
||||
|
||||
To this end, we have added a new flag to allow you to explicitly disable incremental analysis. On CLI, this is
|
||||
the new `-no-cache` flag. On Ant, there is a `noCache` attribute for the `<pmd>` task.
|
||||
|
||||
On both scenarios, disabling the cache takes precedence over setting a cache location.
|
||||
|
||||
#### New Rules
|
||||
|
||||
* The new Java rule [`MissingOverride`](pmd_rules_java_bestpractices.html#missingoverride)
|
||||
(category `bestpractices`) detects overridden and implemented methods, which are not marked with the
|
||||
`@Override` annotation. Annotating overridden methods with `@Override` ensures at compile time that
|
||||
the method really overrides one, which helps refactoring and clarifies intent.
|
||||
|
||||
* The new Java rule [`UnnecessaryAnnotationValueElement`](pmd_rules_java_codestyle.html#unnecessaryannotationvalueelement)
|
||||
(category `codestyle`) detects annotations with a single element (`value`) that explicitely names it.
|
||||
That is, doing `@SuppressWarnings(value = "unchecked")` would be flagged in favor of
|
||||
`@SuppressWarnings("unchecked")`.
|
||||
|
||||
* The new Java rule [`ControlStatementBraces`](pmd_rules_java_codestyle.html#controlstatementbraces)
|
||||
(category `codestyle`) enforces the presence of braces on control statements where they are optional.
|
||||
Properties allow to customize which statements are required to have braces. This rule replaces the now
|
||||
deprecated rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and
|
||||
`IfElseStmtMustUseBraces`. More than covering the use cases of those rules, this rule also supports
|
||||
`do ... while` statements and `case` labels of `switch` statements (disabled by default).
|
||||
|
||||
#### Modified Rules
|
||||
|
||||
* The Java rule `CommentContentRule` (`java-documentation`) previously had the property `wordsAreRegex`. But this
|
||||
property never had been implemented and is removed now.
|
||||
|
||||
* The Java rule `UnusedPrivateField` (`java-bestpractices`) now has a new `ignoredAnnotations` property
|
||||
that allows to configure annotations that imply the field should be ignored. By default `@java.lang.Deprecated`
|
||||
and `@javafx.fxml.FXML` are ignored.
|
||||
|
||||
* The Java rule `UnusedPrivateMethod` (`java-bestpractices`) now has a new `ignoredAnnotations` property
|
||||
that allows to configure annotations that imply the method should be ignored. By default `@java.lang.Deprecated`
|
||||
is ignored.
|
||||
|
||||
* The Java rule `ImmutableField` (`java-design`) now has a new `ignoredAnnotations` property
|
||||
that allows to configure annotations that imply the method should be ignored. By default several `lombok`
|
||||
annotations are ignored
|
||||
|
||||
* The Java rule `SingularField` (`java-design`) now has a new `ignoredAnnotations` property
|
||||
that allows to configure annotations that imply the method should be ignored. By default several `lombok`
|
||||
annotations are ignored
|
||||
|
||||
#### Deprecated Rules
|
||||
|
||||
* The Java rules `WhileLoopMustUseBraces`, `ForLoopMustUseBraces`, `IfStmtMustUseBraces`, and `IfElseStmtMustUseBraces`
|
||||
are deprecated. They will be replaced by the new rule `ControlStatementBraces`, in the category `codestyle`.
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* all
|
||||
* [#569](https://github.com/pmd/pmd/issues/569): \[core] XPath support requires specific toString implementations
|
||||
* [#795](https://github.com/pmd/pmd/issues/795): \[cpd] java.lang.OutOfMemoryError
|
||||
* [#848](https://github.com/pmd/pmd/issues/848): \[doc] Test failures when building pmd-doc under Windows
|
||||
* [#872](https://github.com/pmd/pmd/issues/872): \[core] NullPointerException at FileDataSource.glomName()
|
||||
* [#854](https://github.com/pmd/pmd/issues/854): \[ci] Use Java9 for building PMD
|
||||
* doc
|
||||
* [#791](https://github.com/pmd/pmd/issues/791): \[doc] Documentation site reorganisation
|
||||
* [#891](https://github.com/pmd/pmd/issues/891): \[doc] Apex @SuppressWarnings should use single quotes instead of double quotes
|
||||
* [#909](https://github.com/pmd/pmd/issues/909): \[doc] Please add new PMD Eclipse Plugin to tool integration section
|
||||
* java
|
||||
* [#825](https://github.com/pmd/pmd/issues/825): \[java] Excessive\*Length ignores too much
|
||||
* [#888](https://github.com/pmd/pmd/issues/888): \[java] ParseException occurs with valid '<>' in Java 1.8 mode
|
||||
* [#920](https://github.com/pmd/pmd/pull/920): \[java] Update valid identifiers in grammar
|
||||
* java-bestpractices
|
||||
* [#784](https://github.com/pmd/pmd/issues/784): \[java] ForLoopCanBeForeach false-positive
|
||||
* [#925](https://github.com/pmd/pmd/issues/925): \[java] UnusedImports false positive for static import
|
||||
* [#928](https://github.com/pmd/pmd/issues/928): \[core] PMD build failure on Windows
|
||||
* java-bestpracrtices
|
||||
* [#907](https://github.com/pmd/pmd/issues/907): \[java] UnusedPrivateField false-positive with @FXML
|
||||
* [#963](https://github.com/pmd/pmd/issues/965): \[java] ArrayIsStoredDirectly not triggered from variadic functions
|
||||
* java-codestyle
|
||||
* [#974](https://github.com/pmd/pmd/issues/974): \[java] Merge \*StmtMustUseBraces rules
|
||||
* [#983](https://github.com/pmd/pmd/issues/983): \[java] Detect annotations with single value element
|
||||
* java-design
|
||||
* [#855](https://github.com/pmd/pmd/issues/855): \[java] ImmutableField false-positive with lambdas
|
||||
* java-documentation
|
||||
* [#877](https://github.com/pmd/pmd/issues/877): \[java] CommentRequired valid rule configuration causes PMD error
|
||||
* java-errorprone
|
||||
* [#885](https://github.com/pmd/pmd/issues/885): \[java] CompareObjectsWithEqualsRule trigger by enum1 != enum2
|
||||
* java-performance
|
||||
* [#541](https://github.com/pmd/pmd/issues/541): \[java] ConsecutiveLiteralAppends with types other than string
|
||||
* scala
|
||||
* [#853](https://github.com/pmd/pmd/issues/853): \[scala] Upgrade scala version to support Java 9
|
||||
* xml
|
||||
* [#739](https://github.com/pmd/pmd/issues/739): \[xml] IllegalAccessException when accessing attribute using Saxon on JRE 9
|
||||
|
||||
* [#832](https://github.com/pmd/pmd/issues/832): \[java] AvoidThrowingNullPointerException documentation suggestion
|
||||
* [#837](https://github.com/pmd/pmd/issues/837): \[java] CFGs of declared but not called lambdas are treated as parts of an enclosing method's CFG
|
||||
* [#839](https://github.com/pmd/pmd/issues/839): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors
|
||||
* [#968](https://github.com/pmd/pmd/issues/968): \[java] UseUtilityClassRule reports false positive with lombok NoArgsConstructor
|
||||
* documentation
|
||||
* [#978](https://github.com/pmd/pmd/issues/978): \[core] Broken link in CONTRIBUTING.md
|
||||
* [#992](https://github.com/pmd/pmd/issues/992): \[core] Include info about rule doc generation in "Writing Documentation" md page
|
||||
|
||||
### API Changes
|
||||
|
||||
#### Changes to the Node interface
|
||||
* A new CLI switch, `-no-cache`, disables incremental analysis and the related suggestion. This overrides the
|
||||
`-cache` option. The corresponding Ant task parameter is `noCache`.
|
||||
|
||||
The method `getXPathNodeName` is added to the `Node` interface, which removes the
|
||||
use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
|
||||
A default implementation is provided in `AbstractNode`, to stay compatible
|
||||
with existing implementors.
|
||||
* The static method `PMDParameters.transformParametersIntoConfiguration(PMDParameters)` is now deprecated,
|
||||
for removal in 7.0.0. The new instance method `PMDParameters.toConfiguration()` replaces it.
|
||||
|
||||
The `toString` method of a Node is not changed for the time being, and still produces
|
||||
the name of the XPath node. That behaviour may however change in future major releases,
|
||||
e.g. to produce a more useful message for debugging.
|
||||
|
||||
#### Changes to CPD renderers
|
||||
|
||||
The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface `net.sourceforge.pmd.cpd.renderer.CPDRenderer`
|
||||
has been introduced to replace it. The main difference is that the new interface is meant to render directly to a `java.io.Writer`
|
||||
rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications,
|
||||
it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
|
||||
|
||||
`net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
|
||||
* The method `ASTConstructorDeclaration.getParameters()` has been deprecated in favor of the new method
|
||||
`getFormalParameters()`. This method is available for both `ASTConstructorDeclaration` and
|
||||
`ASTMethodDeclaration`.
|
||||
|
||||
### External Contributions
|
||||
|
||||
* [#790](https://github.com/pmd/pmd/pull/790): \[java] Added some comments for JDK 9 - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#803](https://github.com/pmd/pmd/pull/803): \[doc] Added SpotBugs as successor of FindBugs - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#828](https://github.com/pmd/pmd/pull/828): \[core] Add operations to manipulate a document - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
|
||||
* [#830](https://github.com/pmd/pmd/pull/830): \[java] UseArraysAsList: Description added - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#845](https://github.com/pmd/pmd/pull/845): \[java] Fix false negative PreserveStackTrace on string concatenation - [Alberto Fernández](https://github.com/albfernandez)
|
||||
* [#868](https://github.com/pmd/pmd/pull/868): \[core] Improve XPath documentation && make small refactors - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
|
||||
* [#875](https://github.com/pmd/pmd/pull/875): \[core] Support shortnames when using filelist - [John Zhang](https://github.com/johnjiabinzhang)
|
||||
* [#886](https://github.com/pmd/pmd/pull/886): \[java] Fix #885 - [Matias Comercio](https://github.com/MatiasComercio)
|
||||
* [#900](https://github.com/pmd/pmd/pull/900): \[core] Use the isEmpty method instead of comparing the value of size() to 0 - [reudismam](https://github.com/reudismam)
|
||||
* [#914](https://github.com/pmd/pmd/pull/914): \[doc] Apex @SuppressWarnings documentation updated - [Akshat Bahety](https://github.com/akshatbahety)
|
||||
* [#918](https://github.com/pmd/pmd/pull/918): \[doc] Add qa-eclipse as new tool - [Akshat Bahety](https://github.com/akshatbahety)
|
||||
* [#927](https://github.com/pmd/pmd/pull/927): \[java]\[doc] Fix example of AbstractClassWithoutAnyMethod - [Kazuma Watanabe](https://github.com/wata727)
|
||||
* [#941](https://github.com/pmd/pmd/pull/941): \[java] Use char notation to represent a character to improve performance - [reudismam](https://github.com/reudismam)
|
||||
* [#943](https://github.com/pmd/pmd/pull/943): \[java] UnusedPrivateField false-positive with @FXML - [BBG](https://github.com/djydewang)
|
||||
* [#951](https://github.com/pmd/pmd/pull/951): \[java] Add ignoredAnnotations property to unusedPrivateMethod rule - [BBG](https://github.com/djydewang)
|
||||
* [#952](https://github.com/pmd/pmd/pull/952): \[java] SignatureDeclareThrowsException's IgnoreJUnitCompletely property not honored for constructors - [BBG](https://github.com/djydewang)
|
||||
* [#958](https://github.com/pmd/pmd/pull/958): \[java] Refactor how we ignore annotated elements in rules - [BBG](https://github.com/djydewang)
|
||||
* [#965](https://github.com/pmd/pmd/pull/965): \[java] Make Varargs trigger ArrayIsStoredDirectly - [Stephen](https://github.com/pmd/pmd/issues/907)
|
||||
* [#967](https://github.com/pmd/pmd/pull/967): \[doc] Issue 959: fixed broken link to XPath Rule Tutorial - [Andrey Mochalov](https://github.com/epidemia)
|
||||
* [#969](https://github.com/pmd/pmd/pull/969): \[java] Issue 968 Add logic to handle lombok private constructors with utility classes - [Kirk Clemens](https://github.com/clem0110)
|
||||
* [#970](https://github.com/pmd/pmd/pull/970): \[java] Fixed inefficient use of keySet iterator instead of entrySet iterator - [Andrey Mochalov](https://github.com/epidemia)
|
||||
* [#984](https://github.com/pmd/pmd/pull/984): \[java] issue983 Add new UnnecessaryAnnotationValueElement rule - [Kirk Clemens](https://github.com/clem0110)
|
||||
* [#989](https://github.com/pmd/pmd/pull/989): \[core] Update Contribute.md to close Issue #978 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
|
||||
* [#990](https://github.com/pmd/pmd/pull/990): \[java] Updated Doc on AvoidThrowingNullPointerException to close Issue #832 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
|
||||
* [#993](https://github.com/pmd/pmd/pull/993): \[core] Update writing_documentation.md to fix Issue #992 - [Bolarinwa Saheed Olayemi](https://github.com/refactormyself)
|
||||
|
||||
@@ -6,6 +6,102 @@ permalink: pmd_release_notes_old.html
|
||||
Previous versions of PMD can be downloaded here:
|
||||
http://sourceforge.net/projects/pmd/files/pmd/
|
||||
|
||||
## 25-February-2018 - 6.1.0
|
||||
|
||||
The PMD team is pleased to announce PMD 6.1.0.
|
||||
|
||||
This is a minor release.
|
||||
|
||||
### Table Of Contents
|
||||
|
||||
* [New and noteworthy](#new-and-noteworthy)
|
||||
* [Designer UI](#designer-ui)
|
||||
* [Fixed Issues](#fixed-issues)
|
||||
* [API Changes](#api-changes)
|
||||
* [Changes to the Node interface](#changes-to-the-node-interface)
|
||||
* [Changes to CPD renderers](#changes-to-cpd-renderers)
|
||||
* [External Contributions](#external-contributions)
|
||||
|
||||
### New and noteworthy
|
||||
|
||||
#### Designer UI
|
||||
|
||||
The Designer now supports configuring properties for XPath based rule development.
|
||||
The Designer is still under development and any feedback is welcome.
|
||||
|
||||
You can start the designer via `run.sh designer` or `designer.bat`.
|
||||
|
||||
### Fixed Issues
|
||||
|
||||
* all
|
||||
* [#569](https://github.com/pmd/pmd/issues/569): \[core] XPath support requires specific toString implementations
|
||||
* [#795](https://github.com/pmd/pmd/issues/795): \[cpd] java.lang.OutOfMemoryError
|
||||
* [#848](https://github.com/pmd/pmd/issues/848): \[doc] Test failures when building pmd-doc under Windows
|
||||
* [#872](https://github.com/pmd/pmd/issues/872): \[core] NullPointerException at FileDataSource.glomName()
|
||||
* [#854](https://github.com/pmd/pmd/issues/854): \[ci] Use Java9 for building PMD
|
||||
* doc
|
||||
* [#791](https://github.com/pmd/pmd/issues/791): \[doc] Documentation site reorganisation
|
||||
* [#891](https://github.com/pmd/pmd/issues/891): \[doc] Apex @SuppressWarnings should use single quotes instead of double quotes
|
||||
* [#909](https://github.com/pmd/pmd/issues/909): \[doc] Please add new PMD Eclipse Plugin to tool integration section
|
||||
* java
|
||||
* [#825](https://github.com/pmd/pmd/issues/825): \[java] Excessive\*Length ignores too much
|
||||
* [#888](https://github.com/pmd/pmd/issues/888): \[java] ParseException occurs with valid '<>' in Java 1.8 mode
|
||||
* [#920](https://github.com/pmd/pmd/pull/920): \[java] Update valid identifiers in grammar
|
||||
* java-bestpractices
|
||||
* [#784](https://github.com/pmd/pmd/issues/784): \[java] ForLoopCanBeForeach false-positive
|
||||
* [#925](https://github.com/pmd/pmd/issues/925): \[java] UnusedImports false positive for static import
|
||||
* java-design
|
||||
* [#855](https://github.com/pmd/pmd/issues/855): \[java] ImmutableField false-positive with lambdas
|
||||
* java-documentation
|
||||
* [#877](https://github.com/pmd/pmd/issues/877): \[java] CommentRequired valid rule configuration causes PMD error
|
||||
* java-errorprone
|
||||
* [#885](https://github.com/pmd/pmd/issues/885): \[java] CompareObjectsWithEqualsRule trigger by enum1 != enum2
|
||||
* java-performance
|
||||
* [#541](https://github.com/pmd/pmd/issues/541): \[java] ConsecutiveLiteralAppends with types other than string
|
||||
* scala
|
||||
* [#853](https://github.com/pmd/pmd/issues/853): \[scala] Upgrade scala version to support Java 9
|
||||
* xml
|
||||
* [#739](https://github.com/pmd/pmd/issues/739): \[xml] IllegalAccessException when accessing attribute using Saxon on JRE 9
|
||||
|
||||
|
||||
### API Changes
|
||||
|
||||
#### Changes to the Node interface
|
||||
|
||||
The method `getXPathNodeName` is added to the `Node` interface, which removes the
|
||||
use of the `toString` of a node to get its XPath element name (see [#569](https://github.com/pmd/pmd/issues/569)).
|
||||
A default implementation is provided in `AbstractNode`, to stay compatible
|
||||
with existing implementors.
|
||||
|
||||
The `toString` method of a Node is not changed for the time being, and still produces
|
||||
the name of the XPath node. That behaviour may however change in future major releases,
|
||||
e.g. to produce a more useful message for debugging.
|
||||
|
||||
#### Changes to CPD renderers
|
||||
|
||||
The interface `net.sourceforge.pmd.cpd.Renderer` has been deprecated. A new interface `net.sourceforge.pmd.cpd.renderer.CPDRenderer`
|
||||
has been introduced to replace it. The main difference is that the new interface is meant to render directly to a `java.io.Writer`
|
||||
rather than to a String. This allows to greatly reduce the memory footprint of CPD, as on large projects, with many duplications,
|
||||
it was causing `OutOfMemoryError`s (see [#795](https://github.com/pmd/pmd/issues/795)).
|
||||
|
||||
`net.sourceforge.pmd.cpd.FileReporter` has also been deprecated as part of this change, as it's no longer needed.
|
||||
|
||||
### External Contributions
|
||||
|
||||
* [#790](https://github.com/pmd/pmd/pull/790): \[java] Added some comments for JDK 9 - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#803](https://github.com/pmd/pmd/pull/803): \[doc] Added SpotBugs as successor of FindBugs - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#828](https://github.com/pmd/pmd/pull/828): \[core] Add operations to manipulate a document - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
|
||||
* [#830](https://github.com/pmd/pmd/pull/830): \[java] UseArraysAsList: Description added - [Tobias Weimer](https://github.com/tweimer)
|
||||
* [#845](https://github.com/pmd/pmd/pull/845): \[java] Fix false negative PreserveStackTrace on string concatenation - [Alberto Fernández](https://github.com/albfernandez)
|
||||
* [#868](https://github.com/pmd/pmd/pull/868): \[core] Improve XPath documentation && make small refactors - [Gonzalo Ibars Ingman](https://github.com/gibarsin)
|
||||
* [#875](https://github.com/pmd/pmd/pull/875): \[core] Support shortnames when using filelist - [John Zhang](https://github.com/johnjiabinzhang)
|
||||
* [#886](https://github.com/pmd/pmd/pull/886): \[java] Fix #885 - [Matias Comercio](https://github.com/MatiasComercio)
|
||||
* [#900](https://github.com/pmd/pmd/pull/900): \[core] Use the isEmpty method instead of comparing the value of size() to 0 - [reudismam](https://github.com/reudismam)
|
||||
* [#914](https://github.com/pmd/pmd/pull/914): \[doc] Apex @SuppressWarnings documentation updated - [Akshat Bahety](https://github.com/akshatbahety)
|
||||
* [#918](https://github.com/pmd/pmd/pull/918): \[doc] Add qa-eclipse as new tool - [Akshat Bahety](https://github.com/akshatbahety)
|
||||
* [#927](https://github.com/pmd/pmd/pull/927): \[java]\[doc] Fix example of AbstractClassWithoutAnyMethod - [Kazuma Watanabe](https://github.com/wata727)
|
||||
|
||||
|
||||
## 21-January-2018 - 6.0.1
|
||||
|
||||
The PMD team is pleased to announce PMD 6.0.1.
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
<parent>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd</artifactId>
|
||||
<version>6.1.0</version>
|
||||
<version>6.2.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<config.basedir>${basedir}/../pmd-core</config.basedir>
|
||||
<java.version>8</java.version>
|
||||
<!-- Workaround for https://youtrack.jetbrains.com/issue/IDEA-188690 -->
|
||||
<maven.compiler.source>1.${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>1.${java.version}</maven.compiler.target>
|
||||
<apex.jorje.version>2017-11-17</apex.jorje.version>
|
||||
</properties>
|
||||
|
||||
|
||||
+4
-3
@@ -7,13 +7,14 @@
|
||||
<parent>
|
||||
<groupId>net.sourceforge.pmd</groupId>
|
||||
<artifactId>pmd</artifactId>
|
||||
<version>6.1.0</version>
|
||||
<version>6.2.0</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<config.basedir>${basedir}/../pmd-core</config.basedir>
|
||||
|
||||
<java.version>8</java.version>
|
||||
<!-- Workaround for https://youtrack.jetbrains.com/issue/IDEA-188690 -->
|
||||
<maven.compiler.source>1.${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>1.${java.version}</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -15,11 +15,9 @@ import net.sourceforge.pmd.lang.apex.ast.ApexNode;
|
||||
import net.sourceforge.pmd.lang.apex.ast.DumpFacade;
|
||||
import net.sourceforge.pmd.lang.apex.multifile.ApexMultifileVisitorFacade;
|
||||
import net.sourceforge.pmd.lang.apex.rule.ApexRuleViolationFactory;
|
||||
import net.sourceforge.pmd.lang.ast.xpath.AbstractASTXPathHandler;
|
||||
import net.sourceforge.pmd.lang.ast.xpath.DefaultASTXPathHandler;
|
||||
import net.sourceforge.pmd.lang.rule.RuleViolationFactory;
|
||||
|
||||
import net.sf.saxon.sxpath.IndependentContext;
|
||||
|
||||
public class ApexHandler extends AbstractLanguageVersionHandler {
|
||||
|
||||
@Override
|
||||
@@ -30,13 +28,7 @@ public class ApexHandler extends AbstractLanguageVersionHandler {
|
||||
|
||||
@Override
|
||||
public XPathHandler getXPathHandler() {
|
||||
return new AbstractASTXPathHandler() {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
public void initialize(IndependentContext context) {
|
||||
}
|
||||
};
|
||||
return new DefaultASTXPathHandler();
|
||||
}
|
||||
|
||||
public RuleViolationFactory getRuleViolationFactory() {
|
||||
|
||||
@@ -5,29 +5,10 @@
|
||||
package net.sourceforge.pmd.lang.apex;
|
||||
|
||||
import net.sourceforge.pmd.lang.ParserOptions;
|
||||
import net.sourceforge.pmd.util.StringUtil;
|
||||
|
||||
public class ApexParserOptions extends ParserOptions {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (1237);
|
||||
result = prime * result + (1237);
|
||||
result = prime * result;
|
||||
return result;
|
||||
}
|
||||
// empty class for now, since we don't have extra options for Apex
|
||||
// Once you add something here, make sure to override hashCode and equals
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final ApexParserOptions that = (ApexParserOptions) obj;
|
||||
return StringUtil.isSame(this.suppressMarker, that.suppressMarker, false, false, false);
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,10 @@ public class ApexParser {
|
||||
protected final ApexParserOptions parserOptions;
|
||||
|
||||
private Map<Integer, String> suppressMap;
|
||||
private String suppressMarker = "NOPMD";
|
||||
|
||||
public ApexParser(ApexParserOptions parserOptions) {
|
||||
ApexJorjeLogging.disableLogging();
|
||||
this.parserOptions = parserOptions;
|
||||
|
||||
if (parserOptions.getSuppressMarker() != null) {
|
||||
suppressMarker = parserOptions.getSuppressMarker();
|
||||
}
|
||||
}
|
||||
|
||||
public Compilation parseApex(final String sourceCode) throws ParseException {
|
||||
@@ -45,8 +40,7 @@ public class ApexParser {
|
||||
Locations.useIndexFactory();
|
||||
CompilerService.INSTANCE.visitAstFromString(sourceCode, visitor);
|
||||
|
||||
Compilation astRoot = visitor.getTopLevel();
|
||||
return astRoot;
|
||||
return visitor.getTopLevel();
|
||||
}
|
||||
|
||||
public ApexNode<Compilation> parse(final Reader reader) {
|
||||
@@ -60,8 +54,7 @@ public class ApexParser {
|
||||
throw new ParseException("Couldn't parse the source - there is not root node - Syntax Error??");
|
||||
}
|
||||
|
||||
ApexNode<Compilation> tree = treeBuilder.build(astRoot);
|
||||
return tree;
|
||||
return treeBuilder.build(astRoot);
|
||||
} catch (IOException e) {
|
||||
throw new ParseException(e);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import apex.jorje.semantic.symbol.type.TypeInfo;
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
public class ApexQualifiedName implements QualifiedName {
|
||||
public final class ApexQualifiedName implements QualifiedName {
|
||||
|
||||
|
||||
private final String nameSpace;
|
||||
@@ -155,7 +155,7 @@ public class ApexQualifiedName implements QualifiedName {
|
||||
|
||||
List<TypeInfo> paramTypes = node.getNode().getMethodInfo().getParameterTypes();
|
||||
|
||||
if (paramTypes.size() > 0) {
|
||||
if (!paramTypes.isEmpty()) {
|
||||
sb.append(paramTypes.get(0).getApexName());
|
||||
|
||||
for (int i = 1; i < paramTypes.size(); i++) {
|
||||
|
||||
@@ -84,11 +84,10 @@ public class CompilerService {
|
||||
List<SourceFile> sourceFiles = sources.stream().map(s -> SourceFile.builder().setBody(s).build())
|
||||
.collect(Collectors.toList());
|
||||
CompilationInput compilationUnit = createCompilationInput(sourceFiles, visitor);
|
||||
return compile(compilationUnit, visitor, compilerStage);
|
||||
return compile(compilationUnit, compilerStage);
|
||||
}
|
||||
|
||||
private ApexCompiler compile(CompilationInput compilationInput, AstVisitor<AdditionalPassScope> visitor,
|
||||
CompilerStage compilerStage) {
|
||||
private ApexCompiler compile(CompilationInput compilationInput, CompilerStage compilerStage) {
|
||||
ApexCompiler compiler = ApexCompiler.builder().setInput(compilationInput).build();
|
||||
compiler.compile(compilerStage);
|
||||
callAdditionalPassVisitor(compiler);
|
||||
|
||||
@@ -29,11 +29,11 @@ import apex.jorje.semantic.symbol.type.TypeInfo;
|
||||
/**
|
||||
* @author jspagnola
|
||||
*/
|
||||
public class EmptySymbolProvider implements SymbolProvider {
|
||||
public final class EmptySymbolProvider implements SymbolProvider {
|
||||
|
||||
private static final EmptySymbolProvider INSTANCE = new EmptySymbolProvider();
|
||||
|
||||
EmptySymbolProvider() {
|
||||
private EmptySymbolProvider() {
|
||||
}
|
||||
|
||||
public static EmptySymbolProvider get() {
|
||||
|
||||
@@ -34,6 +34,7 @@ import apex.jorje.semantic.symbol.resolver.SymbolResolver;
|
||||
*
|
||||
* @author jspagnola
|
||||
*/
|
||||
@SuppressWarnings("PMD.MissingStaticMethodInNonInstantiatableClass") // this class provides utility classes
|
||||
public final class TestQueryValidators {
|
||||
|
||||
private TestQueryValidators() {
|
||||
|
||||
-4
@@ -18,10 +18,6 @@ public class ApexOperationSigMask {
|
||||
private Set<Visibility> visMask = EnumSet.allOf(Visibility.class);
|
||||
|
||||
|
||||
public ApexOperationSigMask() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the mask to cover all visibilities.
|
||||
*/
|
||||
|
||||
+2
-3
@@ -16,14 +16,13 @@ import net.sourceforge.pmd.lang.apex.metrics.signature.ApexOperationSigMask;
|
||||
*
|
||||
* @author Clément Fournier
|
||||
*/
|
||||
class ApexProjectMirror implements ApexSignatureMatcher {
|
||||
final class ApexProjectMirror implements ApexSignatureMatcher {
|
||||
|
||||
static final ApexProjectMirror INSTANCE = new ApexProjectMirror();
|
||||
|
||||
private final Map<ApexQualifiedName, ApexClassStats> classes = new HashMap<>();
|
||||
|
||||
ApexProjectMirror() {
|
||||
|
||||
private ApexProjectMirror() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public abstract class AbstractStatisticalApexRule extends AbstractApexRule imple
|
||||
}
|
||||
|
||||
public Object[] getViolationParameters(DataPoint point) {
|
||||
return null;
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,6 +22,7 @@ import net.sourceforge.pmd.lang.rule.ParametricRuleViolation;
|
||||
* </ul>
|
||||
* @param <T>
|
||||
*/
|
||||
@SuppressWarnings("PMD.UseUtilityClass") // we inherit non-static methods...
|
||||
public class ApexRuleViolation<T> extends ParametricRuleViolation<Node> {
|
||||
|
||||
public ApexRuleViolation(Rule rule, RuleContext ctx, Node node, String message, int beginLine, int endLine) {
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ package net.sourceforge.pmd.lang.apex.rule.bestpractices;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTBlockStatement;
|
||||
@@ -51,7 +52,7 @@ public class ApexUnitTestClassShouldHaveAssertsRule extends AbstractApexUnitTest
|
||||
boolean isAssertFound = false;
|
||||
|
||||
for (final ASTMethodCallExpression methodCallExpression : methodCalls) {
|
||||
if (ASSERT_METHODS.contains(methodCallExpression.getFullMethodName().toLowerCase())) {
|
||||
if (ASSERT_METHODS.contains(methodCallExpression.getFullMethodName().toLowerCase(Locale.ROOT))) {
|
||||
isAssertFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
+2
-2
@@ -45,10 +45,10 @@ public class MethodNamingConventionsRule extends AbstractApexRule {
|
||||
}
|
||||
|
||||
private boolean isPropertyAccessor(ASTMethod node) {
|
||||
return (node.getParentsOfType(ASTProperty.class).size() > 0);
|
||||
return !node.getParentsOfType(ASTProperty.class).isEmpty();
|
||||
}
|
||||
|
||||
private boolean isConstructor(ASTMethod node) {
|
||||
return (node.getNode().getMethodInfo().isConstructor());
|
||||
return node.getNode().getMethodInfo().isConstructor();
|
||||
}
|
||||
}
|
||||
Loaded 30 of 412 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user