Merge branch 'master' into filecollector-language

This commit is contained in:
Andreas Dangel committed 2022-08-30 19:21:30 +02:00
commit b232ea46d1
96 files changed
+1382 -408

No files matched your search

+40 -2
View File
@@ -1053,7 +1053,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/86377278?v=4",
"profile": "https://github.com/aaronhurst-google",
"contributions": [
"bug"
"bug",
"code"
]
},
{
@@ -5917,7 +5918,8 @@
"avatar_url": "https://avatars.githubusercontent.com/u/35368290?v=4",
"profile": "https://github.com/tprouvot",
"contributions": [
"bug"
"bug",
"code"
]
},
{
@@ -6768,6 +6770,42 @@
"code",
"financial"
]
},
{
"login": "abyss638",
"name": "Simon Abykov",
"avatar_url": "https://avatars.githubusercontent.com/u/90252673?v=4",
"profile": "https://github.com/abyss638",
"contributions": [
"code"
]
},
{
"login": "eklimo",
"name": "Edward Klimoshenko",
"avatar_url": "https://avatars.githubusercontent.com/u/39220927?v=4",
"profile": "https://github.com/eklimo",
"contributions": [
"bug",
"code"
]
},
{
"login": "nvuillam",
"name": "Nicolas Vuillamy",
"avatar_url": "https://avatars.githubusercontent.com/u/17500430?v=4",
"profile": "https://github.com/nvuillam",
"contributions": [
"doc"
]
},{
"login": "pacvz",
"name": "pacvz",
"avatar_url": "https://avatars.githubusercontent.com/u/35453365?v=4",
"profile": "https://github.com/pacvz",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
+9
View File
@@ -27,6 +27,15 @@ function build() {
pmd_ci_utils_determine_build_env pmd/pmd
echo
if ! pmd_ci_utils_is_fork_or_pull_request; then
if [ "${PMD_CI_BRANCH}" = "experimental-apex-parser" ]; then
pmd_ci_log_group_start "Build with mvnw"
./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
pmd_ci_log_group_end
exit 0
fi
fi
if pmd_ci_utils_is_fork_or_pull_request; then
pmd_ci_log_group_start "Build with mvnw"
./mvnw clean install --show-version --errors --batch-mode --no-transfer-progress "${PMD_MAVEN_EXTRA_OPTS[@]}"
+1
View File
@@ -5,6 +5,7 @@ on:
branches:
- main
- master
- experimental-apex-parser
tags:
- '**'
pull_request:
+10
View File
@@ -0,0 +1,10 @@
# PMD's sponsors
Many thanks to all our sponsors:
* [Matt Hargett](https://github.com/matthargett) (@matthargett)
If you also want to sponsor PMD, you have two options:
* [Sponsor @pmd on GitHub Sponsors](https://github.com/sponsors/pmd)
* [PMD - Open Collective](https://opencollective.com/pmd)
+3 -3
View File
@@ -1,9 +1,9 @@
repository: pmd/pmd
pmd:
version: 6.48.0-SNAPSHOT
previous_version: 6.47.0
date: 30-July-2022
version: 6.49.0-SNAPSHOT
previous_version: 6.48.0
date: 31-August-2022
release_type: minor
# release types: major, minor, bugfix
+53
View File
@@ -125,6 +125,59 @@ the breaking API changes will be performed in 7.0.0.
an API is tagged as `@Deprecated` or not in the latest minor release. During the development of 7.0.0,
we may decide to remove some APIs that were not tagged as deprecated, though we'll try to avoid it." %}
#### 6.48.0
##### CPD CLI
* CPD has a new CLI option `--debug`. This option has the same behavior as in PMD. It enables more verbose
logging output.
##### Rule Test Framework
* The module "pmd-test", which contains support classes to write rule tests, now **requires Java 8**. If you depend on
this module for testing your own custom rules, you'll need to make sure to use at least Java 8.
* The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins.
* Test schema changes:
* The attribute `isRegressionTest` of `test-code` is deprecated. The new
attribute `disabled` should be used instead for defining whether a rule test should be skipped or not.
* The attributes `reinitializeRule` and `useAuxClasspath` of `test-code` are deprecated and assumed true.
They will not be replaced.
* The new attribute `focused` of `test-code` allows disabling all tests except the focused one temporarily.
* More information about the rule test framework can be found in the documentation:
[Testing your rules](pmd_userdocs_extending_testing.html)
##### Deprecated API
* The experimental Java AST class {% jdoc java::lang.java.ast.ASTGuardedPattern %} has been deprecated and
will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch,
but it is no longer supported with Java 19 Preview.
* The interface {% jdoc core::cpd.renderer.CPDRenderer %} is deprecated. For custom CPD renderers
the new interface {% jdoc core::cpd.renderer.CPDReportRenderer %} should be used.
* The class {% jdoc test::testframework.TestDescriptor %} is deprecated, replaced with {% jdoc test-schema::test.schema.RuleTestDescriptor %}.
* Many methods of {% jdoc test::testframework.RuleTst %} have been deprecated as internal API.
##### Experimental APIs
* To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following
AST nodes have been introduced as experimental:
* {% jdoc java::lang.java.ast.ASTSwitchGuard %}
* {% jdoc java::lang.java.ast.ASTRecordPattern %}
* {% jdoc java::lang.java.ast.ASTComponentPatternList %}
##### Internal API
Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning.
* {%jdoc !!core::cpd.CPDConfiguration#setRenderer(net.sourceforge.pmd.cpd.Renderer) %}
* {%jdoc !!core::cpd.CPDConfiguration#setCPDRenderer(net.sourceforge.pmd.cpd.renderer.CPDRenderer) %}
* {%jdoc !!core::cpd.CPDConfiguration#getRenderer() %}
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRenderer() %}
* {%jdoc !!core::cpd.CPDConfiguration#getRendererFromString(java.lang.String,java.lang.String) %}
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRendererFromString(java.lang.String,java.lang.String) %}
* {%jdoc core::cpd.renderer.CPDRendererAdapter %}
#### 6.47.0
No changes.
File diff suppressed because it is too large. Load diff
+3
View File
@@ -73,6 +73,9 @@ Novice as much as advanced readers may want to [read on on Refactoring Guru](htt
description="Sources code language."
default="java"
%}
{% include custom/cli_option_row.html options="--debug,--verbose"
description="Debug mode. Prints more log output."
%}
{% include custom/cli_option_row.html options="--encoding"
description="Character encoding to use when processing files. If not specified, CPD uses the system default encoding."
%}
@@ -104,9 +104,9 @@ Example:
<file path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java" totalNumberOfTokens="523"/>
<file path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQueryTest.java" totalNumberOfTokens="120"/>
<duplication lines="33" tokens="239">
<file column="29" endcolumn="75" endline="64" line="32"
<file column="29" endcolumn="75" endline="64" line="32" begintoken="2356" endtoken="2594"
path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java"/>
<file column="37" endcolumn="75" endline="100" line="68"
<file column="37" endcolumn="75" endline="100" line="68" begintoken="5700" endtoken="5938"
path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/RuleReferenceTest.java"/>
<codefragment><![CDATA[ public void testOverride() {
final StringProperty PROPERTY1_DESCRIPTOR = new StringProperty("property1", "Test property", null, 0f);
@@ -143,11 +143,11 @@ Example:
validateOverriddenValues(PROPERTY1_DESCRIPTOR, PROPERTY2_DESCRIPTOR, ruleReference);]]></codefragment>
</duplication>
<duplication lines="16" tokens="110">
<file column="9" endcolumn="28" endline="81" line="66"
<file column="9" endcolumn="28" endline="81" line="66" begintoken="3000" endtoken="3109"
path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQueryTest.java"/>
<file column="9" endcolumn="28" endline="103" line="88"
<file column="9" endcolumn="28" endline="103" line="88" begintoken="3200" endtoken="3309"
path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQueryTest.java"/>
<file column="9" endcolumn="28" endline="125" line="110"
<file column="9" endcolumn="28" endline="125" line="110" begintoken="3400" endtoken="3509"
path="/home/pmd/source/pmd-core/src/test/java/net/sourceforge/pmd/lang/rule/xpath/JaxenXPathRuleQueryTest.java"/>
<codefragment><![CDATA[ JaxenXPathRuleQuery query = createQuery(xpath);
List<String> ruleChainVisits = query.getRuleChainVisits();
+6
View File
@@ -28,4 +28,10 @@ result of the PMD maven plugin.
See [Other Tools / Integrations](pmd_userdocs_tools.html#github-actions)
## MegaLinter
[🦙 Mega-Linter](https://oxsecurity.github.io/megalinter/latest/) analyzes 50 languages, 22 formats, 21 tooling formats, excessive copy-pastes, spelling mistakes and security issues in your repository sources with a GitHub Action, other CI tools or locally.
It [natively embeds PMD](https://oxsecurity.github.io/megalinter/latest/descriptors/java_pmd/).
<!-- TODO: Find out about other plugins ? -->
+22 -96
View File
@@ -14,114 +14,40 @@ This is a {{ site.pmd.release_type }} release.
### New and noteworthy
#### Java 19 Support
This release of PMD brings support for Java 19. There are no new standard language features.
PMD supports [JEP 427: Pattern Matching for switch (Third Preview)](https://openjdk.org/jeps/427) and
[JEP 405: Record Patterns (Preview)](https://openjdk.org/jeps/405) as preview language features.
In order to analyze a project with PMD that uses these language features,
you'll need to enable it via the environment variable `PMD_JAVA_OPTS` and select the new language
version `19-preview`:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 19-preview ...
Note: Support for Java 17 preview language features have been removed. The version "17-preview" is no longer available.
#### Gherkin support
Thanks to the contribution from [Anne Brouwers](https://github.com/ASBrouwers) PMD now has CPD support
for the [Gherkin](https://cucumber.io/docs/gherkin/) language. It is used to defined test cases for the
[Cucumber](https://cucumber.io/) testing tool for behavior-driven development.
Being based on a proper Antlr grammar, CPD can:
* ignore comments
* honor [comment-based suppressions](pmd_userdocs_cpd.html#suppression)
### Fixed Issues
* apex
* [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query
* [#4096](https://github.com/pmd/pmd/issues/4096): \[apex] ApexAssertionsShouldIncludeMessage and ApexUnitTestClassShouldHaveAsserts: support new Assert class (introduced with Apex v56.0)
* core
* [#3970](https://github.com/pmd/pmd/issues/3970): \[core] FileCollector.addFile ignores language parameter
* [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports
* [#4031](https://github.com/pmd/pmd/issues/4031): \[core] If report is written to stdout, stdout should not be closed
* [#4051](https://github.com/pmd/pmd/issues/4051): \[doc] Additional rulesets are not listed in documentation
* [#4053](https://github.com/pmd/pmd/pull/4053): \[core] Allow building PMD under Java 18+
* java
* [#4015](https://github.com/pmd/pmd/issues/4015): \[java] Support JDK 19
* java-bestpractices
* [#3455](https://github.com/pmd/pmd/issues/3455): \[java] WhileLoopWithLiteralBoolean - false negative with complex expressions
* java-design
* [#3729](https://github.com/pmd/pmd/issues/3729): \[java] TooManyMethods ignores "real" methods which are named like getters or setters
* [#3949](https://github.com/pmd/pmd/issues/3949): \[java] FinalFieldCouldBeStatic - false negative with unnecessary parenthesis
* java-performance
* [#3625](https://github.com/pmd/pmd/issues/3625): \[java] AddEmptyString - false negative with empty var
* lua
* [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD
* test
* [#3302](https://github.com/pmd/pmd/pull/3302): \[test] Improve xml test schema
* [#3758](https://github.com/pmd/pmd/issues/3758): \[test] Move pmd-test to java 8
* [#3976](https://github.com/pmd/pmd/pull/3976): \[test] Extract xml schema module
* java-codestyle
* [#4082](https://github.com/pmd/pmd/issues/4082): \[java] UnnecessaryImport false positive for on-demand imports of nested classes
### API Changes
#### Rule Test Framework
* The module "pmd-test", which contains support classes to write rule tests, now **requires Java 8**. If you depend on
this module for testing your own custom rules, you'll need to make sure to use at least Java 8.
* The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins.
* Test schema changes:
* The attribute `isRegressionTest` of `test-code` is deprecated. The new
attribute `disabled` should be used instead for defining whether a rule test should be skipped or not.
* The attributes `reinitializeRule` and `useAuxClasspath` of `test-code` are deprecated and assumed true.
They will not be replaced.
* The new attribute `focused` of `test-code` allows disabling all tests except the focused one temporarily.
* More information about the rule test framework can be found in the documentation:
[Testing your rules](pmd_userdocs_extending_testing.html)
#### Deprecated API
* The experimental Java AST class {% jdoc java::lang.java.ast.ASTGuardedPattern %} has been deprecated and
will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch,
but it is no longer supported with Java 19 Preview.
* The interface {% jdoc core::cpd.renderer.CPDRenderer %} is deprecated. For custom CPD renderers
the new interface {% jdoc core::cpd.renderer.CPDReportRenderer %} should be used.
* The class {% jdoc test::testframework.TestDescriptor %} is deprecated, replaced with {% jdoc test-schema::test.schema.RuleTestDescriptor %}.
* Many methods of {% jdoc test::testframework.RuleTst %} have been deprecated as internal API.
* In order to reduce the dependency on Apex Jorje classes, the following methods have been deprecated.
These methods all leaked internal Jorje enums. These enums have been replaced now by enums the
PMD's AST package.
* {% jdoc !!apex::lang.apex.ast.ASTAssignmentExpression#getOperator() %}
* {% jdoc !!apex::lang.apex.ast.ASTBinaryExpression#getOperator() %}
* {% jdoc !!apex::lang.apex.ast.ASTBooleanExpression#getOperator() %}
* {% jdoc !!apex::lang.apex.ast.ASTPostfixExpression#getOperator() %}
* {% jdoc !!apex::lang.apex.ast.ASTPrefixExpression#getOperator() %}
#### Experimental APIs
* To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following
AST nodes have been introduced as experimental:
* {% jdoc java::lang.java.ast.ASTSwitchGuard %}
* {% jdoc java::lang.java.ast.ASTRecordPattern %}
* {% jdoc java::lang.java.ast.ASTComponentPatternList %}
#### Internal API
Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning.
* {%jdoc !!core::cpd.CPDConfiguration#setRenderer(net.sourceforge.pmd.cpd.Renderer) %}
* {%jdoc !!core::cpd.CPDConfiguration#setCPDRenderer(net.sourceforge.pmd.cpd.renderer.CPDRenderer) %}
* {%jdoc !!core::cpd.CPDConfiguration#getRenderer() %}
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRenderer() %}
* {%jdoc !!core::cpd.CPDConfiguration#getRendererFromString(java.lang.String,java.lang.String) %}
* {%jdoc !!core::cpd.CPDConfiguration#getCPDRendererFromString(java.lang.String,java.lang.String) %}
* {%jdoc core::cpd.renderer.CPDRendererAdapter %}
All these classes have now a new `getOp()` method. Existing code should be refactored to use this method instead.
It returns the new enums, like {% jdoc apex::lang.apex.ast.AssignmentOperator %}, and avoids
the dependency to Jorje.
### External Contributions
* [#3984](https://github.com/pmd/pmd/pull/3984): \[java] Fix AddEmptyString false-negative issue - [@LiGaOg](https://github.com/LiGaOg)
* [#3988](https://github.com/pmd/pmd/pull/3988): \[java] Modify WhileLoopWithLiteralBoolean to meet the missing case #3455 - [@VoidxHoshi](https://github.com/VoidxHoshi)
* [#3992](https://github.com/pmd/pmd/pull/3992): \[java] FinalFieldCouldBeStatic - fix false negative with unnecessary parenthesis - [@dalizi007](https://github.com/dalizi007)
* [#3994](https://github.com/pmd/pmd/pull/3994): \[java] TooManyMethods - improve getter/setter detection (#3729) - [@341816041](https://github.com/341816041)
* [#4017](https://github.com/pmd/pmd/pull/4017): Add Gherkin support to CPD - [@ASBrouwers](https://github.com/ASBrouwers)
* [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports - [@maikelsteneker](https://github.com/maikelsteneker)
* [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query - [@gwilymatgearset](https://github.com/gwilymatgearset)
* [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD - [@matthargett](https://github.com/matthargett)
* [#4081](https://github.com/pmd/pmd/pull/4081): \[apex] Remove Jorje leaks outside `ast` package - [@eklimo](https://github.com/eklimo)
* [#4083](https://github.com/pmd/pmd/pull/4083): \[java] UnnecessaryImport false positive for on-demand imports of nested classes (fix for #4082) - [@abyss638](https://github.com/abyss638)
* [#4092](https://github.com/pmd/pmd/pull/4092): \[apex] Implement ApexQualifiableNode for ASTUserEnum - [@aaronhurst-google](https://github.com/aaronhurst-google)
* [#4095](https://github.com/pmd/pmd/pull/4095): \[core] CPD: Added begin and end token to XML reports - [@pacvz](https://github.com/pacvz)
* [#4097](https://github.com/pmd/pmd/pull/4097): \[apex] ApexUnitTestClassShouldHaveAssertsRule: Support new Assert class (Apex v56.0) - [@tprouvot](https://github.com/tprouvot)
* [#4104](https://github.com/pmd/pmd/pull/4104): \[doc] Add MegaLinter in the list of integrations - [@nvuillam](https://github.com/nvuillam)
{% endtocmaker %}
+149
View File
@@ -5,6 +5,155 @@ permalink: pmd_release_notes_old.html
Previous versions of PMD can be downloaded here: https://github.com/pmd/pmd/releases
## 30-July-2022 - 6.48.0
The PMD team is pleased to announce PMD 6.48.0.
This is a minor release.
### Table Of Contents
* [New and noteworthy](#new-and-noteworthy)
* [Java 19 Support](#java-19-support)
* [Gherkin support](#gherkin-support)
* [Fixed Issues](#fixed-issues)
* [API Changes](#api-changes)
* [CPD CLI](#cpd-cli)
* [Rule Test Framework](#rule-test-framework)
* [Deprecated API](#deprecated-api)
* [Experimental APIs](#experimental-apis)
* [Internal API](#internal-api)
* [Financial Contributions](#financial-contributions)
* [External Contributions](#external-contributions)
* [Stats](#stats)
### New and noteworthy
#### Java 19 Support
This release of PMD brings support for Java 19. There are no new standard language features.
PMD supports [JEP 427: Pattern Matching for switch (Third Preview)](https://openjdk.org/jeps/427) and
[JEP 405: Record Patterns (Preview)](https://openjdk.org/jeps/405) as preview language features.
In order to analyze a project with PMD that uses these language features,
you'll need to enable it via the environment variable `PMD_JAVA_OPTS` and select the new language
version `19-preview`:
export PMD_JAVA_OPTS=--enable-preview
./run.sh pmd -language java -version 19-preview ...
Note: Support for Java 17 preview language features have been removed. The version "17-preview" is no longer available.
#### Gherkin support
Thanks to the contribution from [Anne Brouwers](https://github.com/ASBrouwers) PMD now has CPD support
for the [Gherkin](https://cucumber.io/docs/gherkin/) language. It is used to defined test cases for the
[Cucumber](https://cucumber.io/) testing tool for behavior-driven development.
Being based on a proper Antlr grammar, CPD can:
* ignore comments
* honor [comment-based suppressions](pmd_userdocs_cpd.html#suppression)
### Fixed Issues
* apex
* [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query
* core
* [#3796](https://github.com/pmd/pmd/issues/3796): \[core] CPD should also provide a `--debug` flag
* [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports
* [#4031](https://github.com/pmd/pmd/issues/4031): \[core] If report is written to stdout, stdout should not be closed
* [#4051](https://github.com/pmd/pmd/issues/4051): \[doc] Additional rulesets are not listed in documentation
* [#4053](https://github.com/pmd/pmd/pull/4053): \[core] Allow building PMD under Java 18+
* java
* [#4015](https://github.com/pmd/pmd/issues/4015): \[java] Support JDK 19
* java-bestpractices
* [#3455](https://github.com/pmd/pmd/issues/3455): \[java] WhileLoopWithLiteralBoolean - false negative with complex expressions
* java-design
* [#3729](https://github.com/pmd/pmd/issues/3729): \[java] TooManyMethods ignores "real" methods which are named like getters or setters
* [#3949](https://github.com/pmd/pmd/issues/3949): \[java] FinalFieldCouldBeStatic - false negative with unnecessary parenthesis
* java-performance
* [#3625](https://github.com/pmd/pmd/issues/3625): \[java] AddEmptyString - false negative with empty var
* lua
* [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD
* test
* [#3302](https://github.com/pmd/pmd/pull/3302): \[test] Improve xml test schema
* [#3758](https://github.com/pmd/pmd/issues/3758): \[test] Move pmd-test to java 8
* [#3976](https://github.com/pmd/pmd/pull/3976): \[test] Extract xml schema module
### API Changes
#### CPD CLI
* CPD has a new CLI option `--debug`. This option has the same behavior as in PMD. It enables more verbose
logging output.
#### Rule Test Framework
* The module "pmd-test", which contains support classes to write rule tests, now **requires Java 8**. If you depend on
this module for testing your own custom rules, you'll need to make sure to use at least Java 8.
* The new module "pmd-test-schema" contains now the XSD schema and the code to parse the rule test XML files. The
schema has been extracted in order to easily share it with other tools like the Rule Designer or IDE plugins.
* Test schema changes:
* The attribute `isRegressionTest` of `test-code` is deprecated. The new
attribute `disabled` should be used instead for defining whether a rule test should be skipped or not.
* The attributes `reinitializeRule` and `useAuxClasspath` of `test-code` are deprecated and assumed true.
They will not be replaced.
* The new attribute `focused` of `test-code` allows disabling all tests except the focused one temporarily.
* More information about the rule test framework can be found in the documentation:
[Testing your rules](pmd_userdocs_extending_testing.html)
#### Deprecated API
* The experimental Java AST class <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.48.0/net/sourceforge/pmd/lang/java/ast/ASTGuardedPattern.html#"><code>ASTGuardedPattern</code></a> has been deprecated and
will be removed. It was introduced for Java 17 and Java 18 Preview as part of pattern matching for switch,
but it is no longer supported with Java 19 Preview.
* The interface <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/renderer/CPDRenderer.html#"><code>CPDRenderer</code></a> is deprecated. For custom CPD renderers
the new interface <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/renderer/CPDReportRenderer.html#"><code>CPDReportRenderer</code></a> should be used.
* The class <a href="https://docs.pmd-code.org/apidocs/pmd-test/6.48.0/net/sourceforge/pmd/testframework/TestDescriptor.html#"><code>TestDescriptor</code></a> is deprecated, replaced with <a href="https://docs.pmd-code.org/apidocs/pmd-test-schema/6.48.0/net/sourceforge/pmd/test/schema/RuleTestDescriptor.html#"><code>RuleTestDescriptor</code></a>.
* Many methods of <a href="https://docs.pmd-code.org/apidocs/pmd-test/6.48.0/net/sourceforge/pmd/testframework/RuleTst.html#"><code>RuleTst</code></a> have been deprecated as internal API.
#### Experimental APIs
* To support the Java preview language features "Pattern Matching for Switch" and "Record Patterns", the following
AST nodes have been introduced as experimental:
* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.48.0/net/sourceforge/pmd/lang/java/ast/ASTSwitchGuard.html#"><code>ASTSwitchGuard</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.48.0/net/sourceforge/pmd/lang/java/ast/ASTRecordPattern.html#"><code>ASTRecordPattern</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-java/6.48.0/net/sourceforge/pmd/lang/java/ast/ASTComponentPatternList.html#"><code>ASTComponentPatternList</code></a>
#### Internal API
Those APIs are not intended to be used by clients, and will be hidden or removed with PMD 7.0.0.
You can identify them with the `@InternalApi` annotation. You'll also get a deprecation warning.
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#setRenderer(net.sourceforge.pmd.cpd.Renderer)"><code>CPDConfiguration#setRenderer</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#setCPDRenderer(net.sourceforge.pmd.cpd.renderer.CPDRenderer)"><code>CPDConfiguration#setCPDRenderer</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#getRenderer()"><code>CPDConfiguration#getRenderer</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#getCPDRenderer()"><code>CPDConfiguration#getCPDRenderer</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#getRendererFromString(java.lang.String,java.lang.String)"><code>CPDConfiguration#getRendererFromString</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/CPDConfiguration.html#getCPDRendererFromString(java.lang.String,java.lang.String)"><code>CPDConfiguration#getCPDRendererFromString</code></a>
* <a href="https://docs.pmd-code.org/apidocs/pmd-core/6.48.0/net/sourceforge/pmd/cpd/renderer/CPDRendererAdapter.html#"><code>CPDRendererAdapter</code></a>
### Financial Contributions
Many thanks to our sponsors:
* [Matt Hargett](https://github.com/matthargett) (@matthargett)
### External Contributions
* [#3984](https://github.com/pmd/pmd/pull/3984): \[java] Fix AddEmptyString false-negative issue - [@LiGaOg](https://github.com/LiGaOg)
* [#3988](https://github.com/pmd/pmd/pull/3988): \[java] Modify WhileLoopWithLiteralBoolean to meet the missing case #3455 - [@VoidxHoshi](https://github.com/VoidxHoshi)
* [#3992](https://github.com/pmd/pmd/pull/3992): \[java] FinalFieldCouldBeStatic - fix false negative with unnecessary parenthesis - [@dalizi007](https://github.com/dalizi007)
* [#3994](https://github.com/pmd/pmd/pull/3994): \[java] TooManyMethods - improve getter/setter detection (#3729) - [@341816041](https://github.com/341816041)
* [#4017](https://github.com/pmd/pmd/pull/4017): Add Gherkin support to CPD - [@ASBrouwers](https://github.com/ASBrouwers)
* [#4021](https://github.com/pmd/pmd/pull/4021): \[core] CPD: Add total number of tokens to XML reports - [@maikelsteneker](https://github.com/maikelsteneker)
* [#4056](https://github.com/pmd/pmd/pull/4056): \[apex] ApexSOQLInjection: Add support count query - [@gwilymatgearset](https://github.com/gwilymatgearset)
* [#4061](https://github.com/pmd/pmd/pull/4061): \[lua] Fix several related Lua parsing issues found when using CPD - [@matthargett](https://github.com/matthargett)
### Stats
* 102 commits
* 26 closed tickets & PRs
* Days since last release: 35
## 25-June-2022 - 6.47.0
The PMD team is pleased to announce PMD 6.47.0.
+1 -1
View File
@@ -8,7 +8,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>6.48.0-SNAPSHOT</version>
<version>6.49.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
+1 -1
View File
@@ -7,7 +7,7 @@
<parent>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd</artifactId>
<version>6.48.0-SNAPSHOT</version>
<version>6.49.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -22,7 +22,15 @@ public class ASTAssignmentExpression extends AbstractApexNode<AssignmentExpressi
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public AssignmentOp getOperator() {
return node.getOp();
}
public AssignmentOperator getOp() {
return AssignmentOperator.valueOf(node.getOp());
}
}
@@ -22,7 +22,15 @@ public class ASTBinaryExpression extends AbstractApexNode<BinaryExpression> {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public BinaryOp getOperator() {
return node.getOp();
}
public BinaryOperator getOp() {
return BinaryOperator.valueOf(node.getOp());
}
}
@@ -24,9 +24,15 @@ public class ASTBooleanExpression extends AbstractApexNode<BooleanExpression> {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public BooleanOp getOperator() {
return this.node.getOp();
}
public BooleanOperator getOp() {
return BooleanOperator.valueOf(this.node.getOp());
}
}
@@ -24,8 +24,15 @@ public class ASTPostfixExpression extends AbstractApexNode<PostfixExpression> {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public PostfixOp getOperator() {
return node.getOp();
}
public PostfixOperator getOp() {
return PostfixOperator.valueOf(node.getOp());
}
}
@@ -22,8 +22,15 @@ public class ASTPrefixExpression extends AbstractApexNode<PrefixExpression> {
return visitor.visit(this, data);
}
/**
* @deprecated Use {@link #getOp()} instead.
*/
@Deprecated
public PrefixOp getOperator() {
return node.getOp();
}
public PrefixOperator getOp() {
return PrefixOperator.valueOf(node.getOp());
}
}
@@ -8,7 +8,9 @@ import net.sourceforge.pmd.annotation.InternalApi;
import apex.jorje.semantic.ast.compilation.UserEnum;
public class ASTUserEnum extends ApexRootNode<UserEnum> {
public class ASTUserEnum extends ApexRootNode<UserEnum> implements ApexQualifiableNode {
private ApexQualifiedName qname;
@Deprecated
@InternalApi
@@ -30,4 +32,20 @@ public class ASTUserEnum extends ApexRootNode<UserEnum> {
public ASTModifierNode getModifiers() {
return getFirstChildOfType(ASTModifierNode.class);
}
@Override
public ApexQualifiedName getQualifiedName() {
if (qname == null) {
ASTUserClass parent = this.getFirstParentOfType(ASTUserClass.class);
if (parent != null) {
qname = ApexQualifiedName.ofNestedEnum(parent.getQualifiedName(), this);
} else {
qname = ApexQualifiedName.ofOuterEnum(this);
}
}
return qname;
}
}
@@ -148,6 +148,20 @@ public final class ApexQualifiedName implements QualifiedName {
}
static ApexQualifiedName ofOuterEnum(ASTUserEnum astUserEnum) {
String ns = astUserEnum.getNamespace();
String[] classes = {astUserEnum.getImage()};
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, classes, null);
}
static ApexQualifiedName ofNestedEnum(ApexQualifiedName parent, ASTUserEnum astUserEnum) {
String[] classes = Arrays.copyOf(parent.classes, parent.classes.length + 1);
classes[classes.length - 1] = astUserEnum.getImage();
return new ApexQualifiedName(parent.nameSpace, classes, null);
}
private static String getOperationString(ASTMethod node) {
StringBuilder sb = new StringBuilder();
sb.append(node.getImage()).append('(');
@@ -171,18 +185,28 @@ public final class ApexQualifiedName implements QualifiedName {
static ApexQualifiedName ofMethod(ASTMethod node) {
ASTUserClassOrInterface<?> parent = node.getFirstParentOfType(ASTUserClassOrInterface.class);
if (parent == null) {
ASTUserTrigger trigger = node.getFirstParentOfType(ASTUserTrigger.class);
String ns = trigger.getNamespace();
String targetObj = trigger.getTargetName();
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, new String[]{"trigger", targetObj}, trigger.getImage()); // uses a reserved word as a class name to prevent clashes
} else {
ApexQualifiedName baseName = parent.getQualifiedName();
// Check first, as enum must be innermost potential parent
ASTUserEnum enumParent = node.getFirstParentOfType(ASTUserEnum.class);
if (enumParent != null) {
ApexQualifiedName baseName = enumParent.getQualifiedName();
return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node));
}
ASTUserClassOrInterface<?> classParent = node.getFirstParentOfType(ASTUserClassOrInterface.class);
if (classParent != null) {
ApexQualifiedName baseName = classParent.getQualifiedName();
return new ApexQualifiedName(baseName.nameSpace, baseName.classes, getOperationString(node));
}
ASTUserTrigger triggerParent = node.getFirstParentOfType(ASTUserTrigger.class);
if (triggerParent != null) {
String ns = triggerParent.getNamespace();
String targetObj = triggerParent.getTargetName();
return new ApexQualifiedName(StringUtils.isEmpty(ns) ? "c" : ns, new String[]{"trigger", targetObj}, triggerParent.getImage()); // uses a reserved word as a class name to prevent clashes
}
throw new UnsupportedOperationException();
}
}
@@ -8,12 +8,12 @@ import net.sourceforge.pmd.annotation.InternalApi;
import net.sourceforge.pmd.lang.ast.RootNode;
import net.sourceforge.pmd.lang.ast.SourceCodePositioner;
import apex.jorje.semantic.ast.AstNode;
import apex.jorje.semantic.ast.compilation.Compilation;
import apex.jorje.services.Version;
@Deprecated
@InternalApi
public abstract class ApexRootNode<T extends AstNode> extends AbstractApexNode<T> implements RootNode {
public abstract class ApexRootNode<T extends Compilation> extends AbstractApexNode<T> implements RootNode {
@Deprecated
@InternalApi
public ApexRootNode(T node) {
@@ -0,0 +1,67 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.AssignmentOp;
/**
* Apex assignment operator
*/
public enum AssignmentOperator {
EQUALS("="),
ADDITION_EQUALS("+="),
SUBTRACTION_EQUALS("-="),
MULTIPLICATION_EQUALS("*="),
DIVISION_EQUALS("/="),
LEFT_SHIFT_EQUALS("<<="),
RIGHT_SHIFT_SIGNED_EQUALS(">>="),
RIGHT_SHIFT_UNSIGNED_EQUALS(">>>="),
BITWISE_AND_EQUALS("&="),
BITWISE_OR_EQUALS("|="),
BITWISE_XOR_EQUALS("^=");
private final String symbol;
AssignmentOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link AssignmentOperator} corresponding to the given {@link AssignmentOp}.
*/
public static AssignmentOperator valueOf(AssignmentOp op) {
switch (op) {
case EQUALS:
return EQUALS;
case ADDITION_EQUALS:
return ADDITION_EQUALS;
case SUBTRACTION_EQUALS:
return SUBTRACTION_EQUALS;
case MULTIPLICATION_EQUALS:
return MULTIPLICATION_EQUALS;
case DIVISION_EQUALS:
return DIVISION_EQUALS;
case LEFT_SHIFT_EQUALS:
return LEFT_SHIFT_EQUALS;
case RIGHT_SHIFT_EQUALS:
return RIGHT_SHIFT_SIGNED_EQUALS;
case UNSIGNED_RIGHT_SHIFT_EQUALS:
return RIGHT_SHIFT_UNSIGNED_EQUALS;
case AND_EQUALS:
return BITWISE_AND_EQUALS;
case OR_EQUALS:
return BITWISE_OR_EQUALS;
case XOR_EQUALS:
return BITWISE_XOR_EQUALS;
default:
throw new IllegalArgumentException("Invalid assignment operator " + op);
}
}
}
@@ -0,0 +1,64 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BinaryOp;
/**
* Apex binary operator
*/
public enum BinaryOperator {
ADDITION("+"),
SUBTRACTION("-"),
MULTIPLICATION("*"),
DIVISION("/"),
LEFT_SHIFT("<<"),
RIGHT_SHIFT_SIGNED(">>"),
RIGHT_SHIFT_UNSIGNED(">>>"),
BITWISE_AND("&"),
BITWISE_OR("|"),
BITWISE_XOR("^");
private final String symbol;
BinaryOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link BinaryOperator} corresponding to the given {@link BinaryOp}.
*/
public static BinaryOperator valueOf(BinaryOp op) {
switch (op) {
case ADDITION:
return ADDITION;
case SUBTRACTION:
return SUBTRACTION;
case MULTIPLICATION:
return MULTIPLICATION;
case DIVISION:
return DIVISION;
case LEFT_SHIFT:
return LEFT_SHIFT;
case RIGHT_SHIFT:
return RIGHT_SHIFT_SIGNED;
case UNSIGNED_RIGHT_SHIFT:
return RIGHT_SHIFT_UNSIGNED;
case AND:
return BITWISE_AND;
case OR:
return BITWISE_OR;
case XOR:
return BITWISE_XOR;
default:
throw new IllegalArgumentException("Invalid binary operator " + op);
}
}
}
@@ -0,0 +1,67 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.BooleanOp;
/**
* Apex boolean operator
*/
public enum BooleanOperator {
EQUAL("=="),
NOT_EQUAL("!="),
ALT_NOT_EQUAL("<>"),
EXACTLY_EQUAL("==="),
EXACTLY_NOT_EQUAL("!=="),
LESS_THAN("<"),
GREATER_THAN(">"),
LESS_THAN_OR_EQUAL("<="),
GREATER_THAN_OR_EQUAL(">="),
LOGICAL_AND("&&"),
LOGICAL_OR("||");
private final String symbol;
BooleanOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link BooleanOperator} corresponding to the given {@link BooleanOp}.
*/
public static BooleanOperator valueOf(BooleanOp op) {
switch (op) {
case DOUBLE_EQUAL:
return EQUAL;
case NOT_EQUAL:
return NOT_EQUAL;
case ALT_NOT_EQUAL:
return ALT_NOT_EQUAL;
case TRIPLE_EQUAL:
return EXACTLY_EQUAL;
case NOT_TRIPLE_EQUAL:
return EXACTLY_NOT_EQUAL;
case LESS_THAN:
return LESS_THAN;
case GREATER_THAN:
return GREATER_THAN;
case LESS_THAN_EQUAL:
return LESS_THAN_OR_EQUAL;
case GREATER_THAN_EQUAL:
return GREATER_THAN_OR_EQUAL;
case AND:
return LOGICAL_AND;
case OR:
return LOGICAL_OR;
default:
throw new IllegalArgumentException("Invalid boolean operator " + op);
}
}
}
@@ -0,0 +1,40 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.PostfixOp;
/**
* Apex postfix operator
*/
public enum PostfixOperator {
INCREMENT("++"),
DECREMENT("--");
private final String symbol;
PostfixOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link PostfixOperator} corresponding to the given {@link PostfixOp}.
*/
public static PostfixOperator valueOf(PostfixOp op) {
switch (op) {
case INC:
return INCREMENT;
case DEC:
return DECREMENT;
default:
throw new IllegalArgumentException("Invalid postfix operator " + op);
}
}
}
@@ -0,0 +1,52 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.apex.ast;
import apex.jorje.data.ast.PrefixOp;
/**
* Apex prefix operator
*/
public enum PrefixOperator {
POSITIVE("+"),
NEGATIVE("-"),
LOGICAL_NOT("!"),
BITWISE_NOT("~"),
INCREMENT("++"),
DECREMENT("--");
private final String symbol;
PrefixOperator(String symbol) {
this.symbol = symbol;
}
@Override
public String toString() {
return this.symbol;
}
/**
* Returns a {@link PrefixOperator} corresponding to the given {@link PrefixOp}.
*/
public static PrefixOperator valueOf(PrefixOp op) {
switch (op) {
case POSITIVE:
return POSITIVE;
case NEGATIVE:
return NEGATIVE;
case NOT:
return LOGICAL_NOT;
case BITWISE_COMPLEMENT:
return BITWISE_NOT;
case INC:
return INCREMENT;
case DEC:
return DECREMENT;
default:
throw new IllegalArgumentException("Invalid prefix operator " + op);
}
}
}
@@ -12,11 +12,10 @@ import org.apache.commons.lang3.mutable.MutableInt;
import net.sourceforge.pmd.lang.apex.ast.ASTBooleanExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTMethod;
import net.sourceforge.pmd.lang.apex.ast.ASTStandardCondition;
import net.sourceforge.pmd.lang.apex.ast.BooleanOperator;
import net.sourceforge.pmd.lang.apex.metrics.impl.visitors.StandardCycloVisitor;
import net.sourceforge.pmd.lang.metrics.MetricOptions;
import apex.jorje.data.ast.BooleanOp;
/**
* See the doc for the Java metric.
*
@@ -44,8 +43,8 @@ public class CycloMetric extends AbstractApexOperationMetric {
int complexity = 0;
for (ASTBooleanExpression sub : subs) {
BooleanOp op = sub.getOperator();
if (op != null && (op == BooleanOp.AND || op == BooleanOp.OR)) {
BooleanOperator op = sub.getOp();
if (op == BooleanOperator.LOGICAL_AND || op == BooleanOperator.LOGICAL_OR) {
complexity++;
}
}
@@ -19,9 +19,8 @@ import net.sourceforge.pmd.lang.apex.ast.ASTTernaryExpression;
import net.sourceforge.pmd.lang.apex.ast.ASTWhileLoopStatement;
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter;
import apex.jorje.data.ast.BooleanOp;
import apex.jorje.data.ast.PrefixOp;
import net.sourceforge.pmd.lang.apex.ast.BooleanOperator;
import net.sourceforge.pmd.lang.apex.ast.PrefixOperator;
/**
* @author Gwilym Kuiper
@@ -31,7 +30,7 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter {
private int complexity = 0;
private int nestingLevel = 0;
private BooleanOp currentBooleanOperation = null;
private BooleanOperator currentBooleanOperation = null;
private String methodName = null;
public double getComplexity() {
@@ -53,7 +52,7 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter {
complexity++;
}
void booleanOperation(BooleanOp op) {
void booleanOperation(BooleanOperator op) {
if (currentBooleanOperation != op) {
if (op != null) {
fundamentalComplexity();
@@ -177,8 +176,8 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter {
public Object visit(ASTBooleanExpression node, Object data) {
State state = (State) data;
BooleanOp op = node.getOperator();
if (op == BooleanOp.AND || op == BooleanOp.OR) {
BooleanOperator op = node.getOp();
if (op == BooleanOperator.LOGICAL_AND || op == BooleanOperator.LOGICAL_OR) {
state.booleanOperation(op);
}
@@ -189,8 +188,8 @@ public class CognitiveComplexityVisitor extends ApexParserVisitorAdapter {
public Object visit(ASTPrefixExpression node, Object data) {
State state = (State) data;
PrefixOp op = node.getOperator();
if (op == PrefixOp.NOT) {
PrefixOperator op = node.getOp();
if (op == PrefixOperator.LOGICAL_NOT) {
state.booleanOperation(null);
}
@@ -12,17 +12,39 @@ public class ApexAssertionsShouldIncludeMessageRule extends AbstractApexUnitTest
private static final String ASSERT = "System.assert";
private static final String ASSERT_EQUALS = "System.assertEquals";
private static final String ASSERT_NOT_EQUALS = "System.assertNotEquals";
private static final String ARE_EQUAL = "Assert.areEqual";
private static final String ARE_NOT_EQUAL = "Assert.areNotEqual";
private static final String IS_FALSE = "Assert.isFalse";
private static final String FAIL = "Assert.fail";
private static final String IS_INSTANCE_OF_TYPE = "Assert.isInstanceOfType";
private static final String IS_NOT_INSTANCE_OF_TYPE = "Assert.isNotInstanceOfType";
private static final String IS_NOT_NULL = "Assert.isNotNull";
private static final String IS_NULL = "Assert.isNull";
private static final String IS_TRUE = "Assert.isTrue";
@Override
public Object visit(ASTMethodCallExpression node, Object data) {
String methodName = node.getFullMethodName();
if (ASSERT.equalsIgnoreCase(methodName) && node.getNumChildren() == 2) {
if (FAIL.equalsIgnoreCase(methodName) && node.getNumChildren() == 1) {
addViolationWithMessage(data, node,
"''{0}'' should have 1 parameters.",
new Object[] { FAIL });
} else if ((ASSERT.equalsIgnoreCase(methodName)
|| IS_FALSE.equalsIgnoreCase(methodName)
|| IS_NOT_NULL.equalsIgnoreCase(methodName)
|| IS_NULL.equalsIgnoreCase(methodName)
|| IS_TRUE.equalsIgnoreCase(methodName))
&& node.getNumChildren() == 2) {
addViolationWithMessage(data, node,
"''{0}'' should have 2 parameters.",
new Object[] { ASSERT });
new Object[] { methodName });
} else if ((ASSERT_EQUALS.equalsIgnoreCase(methodName)
|| ASSERT_NOT_EQUALS.equalsIgnoreCase(methodName))
|| ASSERT_NOT_EQUALS.equalsIgnoreCase(methodName)
|| ARE_EQUAL.equalsIgnoreCase(methodName)
|| ARE_NOT_EQUAL.equalsIgnoreCase(methodName)
|| IS_INSTANCE_OF_TYPE.equalsIgnoreCase(methodName)
|| IS_NOT_INSTANCE_OF_TYPE.equalsIgnoreCase(methodName))
&& node.getNumChildren() == 3) {
addViolationWithMessage(data, node,
"''{0}'' should have 3 parameters.",
Loaded 30 of 96 files, more files were not shown because too many files have changed in this diff. Show more