forked from phoedos/pmd
Merge pull request #4811 from adangel:issue-4349-cleanup-deprecations
Cleanup remaining experimental and deprecated API #4811
This commit is contained in:
@ -1,15 +1,13 @@
|
||||
---
|
||||
title: HTML support
|
||||
permalink: pmd_languages_html.html
|
||||
last_updated: September 2023 (7.0.0)
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
|
||||
last_updated: February 2024 (7.0.0)
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
|
||||
summary: "HTML-specific features and guidance"
|
||||
---
|
||||
|
||||
{% include language_info.html name='HTML' id='html' implementation='html::lang.html.HtmlLanguageModule' supports_pmd=true supports_cpd=true since='6.45.0' %}
|
||||
|
||||
{% include warning.html content="This language module is experimental and may change any time." %}
|
||||
|
||||
The HTML language module uses [jsoup](https://jsoup.org/) for parsing.
|
||||
|
||||
XPath rules are supported, but the DOM is not always a typical XML/XPath DOM.
|
||||
|
@ -1,17 +1,13 @@
|
||||
---
|
||||
title: Kotlin Support
|
||||
permalink: pmd_languages_kotlin.html
|
||||
last_updated: September 2023 (7.0.0)
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
|
||||
last_updated: February 2024 (7.0.0)
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
|
||||
summary: "Kotlin-specific features and guidance"
|
||||
---
|
||||
|
||||
[Kotlin](https://kotlinlang.org/) support in PMD is based on the official grammar from <https://github.com/Kotlin/kotlin-spec>.
|
||||
|
||||
{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.JspLanguageModule' supports_pmd=true supports_cpd=true %}
|
||||
{% include language_info.html name='Kotlin' id='kotlin' implementation='kotlin::lang.kotlin.JspLanguageModule' supports_pmd=true supports_cpd=true since=7.0.0 %}
|
||||
|
||||
Java-based rules and XPath-based rules are supported.
|
||||
|
||||
{% include note.html content="Kotlin support has **experimental** stability level, meaning no compatibility should
|
||||
be expected between even incremental releases. Any functionality can be added, removed or changed without
|
||||
warning." %}
|
||||
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
title: Visualforce Support
|
||||
permalink: pmd_languages_visualforce.html
|
||||
last_updated: September 2023
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage, experimental]
|
||||
last_updated: February 2024 (7.0.0)
|
||||
tags: [languages, PmdCapableLanguage, CpdCapableLanguage]
|
||||
author: Andreas Dangel
|
||||
summary: "Visualforce-specific features and guidance"
|
||||
---
|
||||
@ -40,9 +40,6 @@ These env vars have changed from PMD 6 to PMD 7:
|
||||
* `PMD_VF_OBJECTSDIRECTORIES` ➡️ `PMD_VF_OBJECTS_DIRECTORIES`
|
||||
"%}
|
||||
|
||||
This feature is experimental, in particular, expect changes to the way the configuration is specified.
|
||||
We'll probably extend the CLI instead of relying on environment variables in a future version.
|
||||
|
||||
### Sample usage
|
||||
|
||||
```
|
||||
|
@ -57,6 +57,25 @@ There are a couple of deprecated things in PMD 6, you might encounter:
|
||||
and the old rulesets like `basic.xml` have been deprecated and have been removed with PMD 7.
|
||||
It is about time to create a [custom ruleset](pmd_userdocs_making_rulesets.html).
|
||||
|
||||
## Approaching 7.0.0
|
||||
|
||||
After that, migrate to the release candidates, and fix any problems you encounter. Start with 7.0.0-rc1 via
|
||||
7.0.0-rc2, 7.0.0-rc3 and 7.0.0-rc4 until you finally use 7.0.0.
|
||||
|
||||
You might encounter additionally the following types of problems:
|
||||
|
||||
* If you use any programmatic API of PMD, first avoid any usage of deprecated or internal classes/methods. These
|
||||
are marked with one of these annotations: `@Deprecated`, `@DeprecatedUtil700`, `@InternalApi`.
|
||||
* Some of these classes are available until 7.0.0-rc4 but are finally removed with 7.0.0.
|
||||
* See [API changes](pmd_release_notes_pmd7.html#api-changes) for details.
|
||||
* Some rules have been removed, because they have been deprecated. See [Removed Rules](pmd_release_notes_pmd7.html#removed-rules).
|
||||
* Some rule properties have been removed or changed. See [Changed Rules](pmd_release_notes_pmd7.html#changed-rules).
|
||||
* The filenames of the assets of a release (the "binary distribution zip file") have changed,
|
||||
see [Release downloads](#release-downloads).
|
||||
* Some CLI options have been removed, because they have been deprecated. See [CLI Changes](#cli-changes) for details.
|
||||
* If you call CPD programmatically, the API has changed, see [New Programmatic API for CPD](pmd_release_notes_pmd7.html#new-programmatic-api-for-cpd).
|
||||
|
||||
The following topics describe well known migration challenges in more detail.
|
||||
|
||||
## Use cases
|
||||
|
||||
@ -205,7 +224,8 @@ Most notable changes:
|
||||
an error message such as `[main] ERROR net.sourceforge.pmd.cli.commands.internal.PmdCommand - No such file false`.
|
||||
* PMD tries to display a progress bar. If you don't want this (e.g. on a CI build server), you can disable this
|
||||
with `--no-progress`.
|
||||
* `--no-ruleset-compatibility` has been removed
|
||||
* `--no-ruleset-compatibility` has been removed without replacement.
|
||||
* `--stress` (or `-stress`) has been removed without replacement.
|
||||
|
||||
### Custom distribution packages
|
||||
|
||||
@ -443,14 +463,15 @@ Some nodes have already the image attribute (and others) deprecated. These depre
|
||||
|
||||
* {% jdoc java::lang.java.ast.ASTAnnotationTypeDeclaration %}: `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTAnonymousClassDeclaration %}: `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTClassOrInterfaceDeclaration %}: `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTClassDeclaration %} (previously "ASTClassOrInterfaceDeclaration"): `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTEnumDeclaration %}: `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTFieldDeclaration %}: `@VariableName` ➡️ `VariableDeclaratorId/@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTFieldDeclaration %}: `@VariableName` ➡️ `VariableId/@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTMethodDeclaration %}: `@Image` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTMethodDeclaration %}: `@MethodName` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTRecordDeclaration %}: `@Image` ➡️ `@SimpleName`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@Image` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@VariableName` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableDeclaratorId %}: `@Array` ➡️ `@ArrayType`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@Image` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@VariableName` ➡️ `@Name`
|
||||
* {% jdoc java::lang.java.ast.ASTVariableId %} (previously "ASTVariableDeclaratorId"): `@Array` ➡️ `@ArrayType`
|
||||
|
||||
#### JavaScript
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -176,15 +176,11 @@ Contributors: [Lucas Soncini](https://github.com/lsoncini) (@lsoncini),
|
||||
[Matías Fraga](https://github.com/matifraga) (@matifraga),
|
||||
[Tomás De Lucca](https://github.com/tomidelucca) (@tomidelucca)
|
||||
|
||||
### New: Kotlin support (experimental)
|
||||
### New: Kotlin support
|
||||
|
||||
PMD now supports Kotlin as an additional language for analyzing source code. It is based on
|
||||
the official kotlin Antlr grammar. Java-based rules and XPath-based rules are supported.
|
||||
|
||||
Kotlin support has **experimental** stability level, meaning no compatibility should
|
||||
be expected between even incremental releases. Any functionality can be added, removed or changed without
|
||||
warning.
|
||||
|
||||
We are shipping the following rules:
|
||||
|
||||
* {% rule kotlin/bestpractices/FunctionNameTooShort %} (`kotlin-bestpractices`) finds functions with a too
|
||||
@ -247,6 +243,11 @@ PMD supports Apache Velocity for a very long time, but the CPD integration never
|
||||
This is now done and CPD supports Apache Velocity Template language for detecting copy and paste.
|
||||
It is shipped in the module `pmd-vm`.
|
||||
|
||||
### Changed: HTML support
|
||||
|
||||
Support for HTML was introduced in PMD 6.55.0 as an experimental feature. With PMD 7.0.0 this
|
||||
is now considered stable.
|
||||
|
||||
### Changed: JavaScript support
|
||||
|
||||
The JS specific parser options have been removed. The parser now always retains comments and uses version ES6.
|
||||
@ -445,78 +446,72 @@ The following previously deprecated rules have been finally removed:
|
||||
**Java**
|
||||
|
||||
* {% deleted_rule java/codestyle/AbstractNaming %} ➡️ use {% rule java/codestyle/ClassNamingConventions %}
|
||||
* AvoidFinalLocalVariable (java-codestyle) ➡️ not replaced
|
||||
* AvoidPrefixingMethodParameters (java-codestyle) ➡️ use {% rule "java/codestyle/FormalParameterNamingConventions" %}
|
||||
* AvoidUsingShortType (java-performance) ➡️ not replaced
|
||||
* BadComparison (java-errorprone) ➡️ use {% rule "java/errorprone/ComparisonWithNaN" %}
|
||||
* BeanMembersShouldSerialize (java-errorprone) ➡️ use {% rule java/errorprone/NonSerializableClass %}
|
||||
* BooleanInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* {% deleted_rule java/codestyle/AvoidFinalLocalVariable %} ➡️ not replaced
|
||||
* {% deleted_rule java/codestyle/AvoidPrefixingMethodParameters %} ➡️ use {% rule "java/codestyle/FormalParameterNamingConventions" %}
|
||||
* {% deleted_rule java/performance/AvoidUsingShortType %} ➡️ not replaced
|
||||
* {% deleted_rule java/errorprone/BadComparison %} ➡️ use {% rule "java/errorprone/ComparisonWithNaN" %}
|
||||
* {% deleted_rule java/errorprone/BeanMembersShouldSerialize %} ➡️ use {% rule java/errorprone/NonSerializableClass %}
|
||||
* {% deleted_rule java/performance/BooleanInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
|
||||
* ByteInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* {% deleted_rule java/performance/ByteInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
|
||||
* CloneThrowsCloneNotSupportedException (java-errorprone) ➡️ not replaced
|
||||
* DataflowAnomalyAnalysis (java-errorprone) ➡️ use {% rule java/bestpractices/UnusedAssignment %}
|
||||
* DefaultPackage (java-codestyle) ➡️ use {% rule "java/codestyle/CommentDefaultAccessModifier" %}
|
||||
* DoNotCallSystemExit (java-errorprone) ➡️ use {% rule "java/errorprone/DoNotTerminateVM" %}
|
||||
* DontImportJavaLang (java-codestyle) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* DuplicateImports (java-codestyle) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* EmptyFinallyBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyIfStmt (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyInitializer (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyStatementBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyStatementNotInLoop (java-errorprone) ➡️ use {% rule java/codestyle/UnnecessarySemicolon %}
|
||||
* EmptySwitchStatements (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptySynchronizedBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyTryBlock (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* EmptyWhileStmt (java-errorprone) ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* ExcessiveClassLength (java-design) ➡️ use {% rule java/design/NcssCount %}
|
||||
* ExcessiveMethodLength (java-design) ➡️ use {% rule java/design/NcssCount %}
|
||||
* ForLoopsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* IfElseStmtsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* IfStmtsMustUseBraces (java-codestyle) ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* ImportFromSamePackage (java-errorprone) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* IntegerInstantiation (java-performance) ➡️ use {% rule java/codestyle/UnnecessaryBoxing %}
|
||||
* {% deleted_rule java/errorprone/CloneThrowsCloneNotSupportedException %} ➡️ not replaced
|
||||
* {% deleted_rule java/errorprone/DataflowAnomalyAnalysis %} ➡️ use {% rule java/bestpractices/UnusedAssignment %}
|
||||
* {% deleted_rule java/codestyle/DefaultPackage %} ➡️ use {% rule "java/codestyle/CommentDefaultAccessModifier" %}
|
||||
* {% deleted_rule java/errorprone/DoNotCallSystemExit %} ➡️ use {% rule "java/errorprone/DoNotTerminateVM" %}
|
||||
* {% deleted_rule java/codestyle/DontImportJavaLang %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* {% deleted_rule java/codestyle/DuplicateImports %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* {% deleted_rule java/errorprone/EmptyFinallyBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyIfStmt %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyInitializer %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyStatementBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyStatementNotInLoop %} ➡️ use {% rule java/codestyle/UnnecessarySemicolon %}
|
||||
* {% deleted_rule java/errorprone/EmptySwitchStatements %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptySynchronizedBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyTryBlock %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/errorprone/EmptyWhileStmt %} ➡️ use {% rule java/codestyle/EmptyControlStatement %}
|
||||
* {% deleted_rule java/design/ExcessiveClassLength %} ➡️ use {% rule java/design/NcssCount %}
|
||||
* {% deleted_rule java/design/ExcessiveMethodLength %} ➡️ use {% rule java/design/NcssCount %}
|
||||
* {% deleted_rule java/codestyle/ForLoopsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* {% deleted_rule java/codestyle/IfElseStmtsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* {% deleted_rule java/codestyle/IfStmtsMustUseBraces %} ➡️ use {% rule java/codestyle/ControlStatementBraces %}
|
||||
* {% deleted_rule java/errorprone/ImportFromSamePackage %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* {% deleted_rule java/performance/IntegerInstantiation %} ➡️ use {% rule java/codestyle/UnnecessaryBoxing %}
|
||||
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
|
||||
* InvalidSlf4jMessageFormat (java-errorprone) ➡️ use {% rule "java/errorprone/InvalidLogMessageFormat" %}
|
||||
* LoggerIsNotStaticFinal (java-errorprone) ➡️ use {% rule java/errorprone/ProperLogger %}
|
||||
* LongInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* {% deleted_rule java/errorprone/InvalidSlf4jMessageFormat %} ➡️ use {% rule "java/errorprone/InvalidLogMessageFormat" %}
|
||||
* {% deleted_rule java/errorprone/LoggerIsNotStaticFinal %} ➡️ use {% rule java/errorprone/ProperLogger %}
|
||||
* {% deleted_rule java/performance/LongInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
|
||||
* MIsLeadingVariableName (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %},
|
||||
* {% deleted_rule java/codestyle/MIsLeadingVariableName %} ➡️ use {% rule java/codestyle/FieldNamingConventions %},
|
||||
{% rule java/codestyle/FormalParameterNamingConventions %},
|
||||
or {% rule java/codestyle/LocalVariableNamingConventions %}
|
||||
* MissingBreakInSwitch (java-errorprone) ➡️ use {% rule "java/errorprone/ImplicitSwitchFallThrough" %}
|
||||
* ModifiedCyclomaticComplexity (java-design) ➡️ use {% rule "java/design/CyclomaticComplexity" %}
|
||||
* NcssConstructorCount (java-design) ➡️ use {% rule java/design/NcssCount %}
|
||||
* NcssMethodCount (java-design) ➡️ use {% rule java/design/NcssCount %}
|
||||
* NcssTypeCount (java-design) ➡️ use {% rule java/design/NcssCount %}
|
||||
* PositionLiteralsFirstInCaseInsensitiveComparisons (java-bestpractices) ➡️
|
||||
* {% deleted_rule java/errorprone/MissingBreakInSwitch %} ➡️ use {% rule "java/errorprone/ImplicitSwitchFallThrough" %}
|
||||
* {% deleted_rule java/design/ModifiedCyclomaticComplexity %} ➡️ use {% rule "java/design/CyclomaticComplexity" %}
|
||||
* {% deleted_rule java/design/NcssConstructorCount %} ➡️ use {% rule java/design/NcssCount %}
|
||||
* {% deleted_rule java/design/NcssMethodCount %} ➡️ use {% rule java/design/NcssCount %}
|
||||
* {% deleted_rule java/design/NcssTypeCount %} ➡️ use {% rule java/design/NcssCount %}
|
||||
* {% deleted_rule java/bestpractices/PositionLiteralsFirstInCaseInsensitiveComparisons %} ➡️
|
||||
use {% rule "java/bestpractices/LiteralsFirstInComparisons" %}
|
||||
* PositionLiteralsFirstInComparisons (java-bestpractices) ➡️
|
||||
* {% deleted_rule java/bestpractices/PositionLiteralsFirstInComparisons %} ➡️
|
||||
use {% rule "java/bestpractices/LiteralsFirstInComparisons" %}
|
||||
* ReturnEmptyArrayRatherThanNull (java-errorprone) ➡️
|
||||
* {% deleted_rule java/errorprone/ReturnEmptyArrayRatherThanNull %} ➡️
|
||||
use {% rule "java/errorprone/ReturnEmptyCollectionRatherThanNull" %}
|
||||
* ShortInstantiation (java-performance) ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* {% deleted_rule java/performance/ShortInstantiation %} ➡️ use {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
and {% rule "java/bestpractices/PrimitiveWrapperInstantiation" %}
|
||||
* SimplifyBooleanAssertion (java-design) ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* SimplifyStartsWith (java-performance) ➡️ not replaced
|
||||
* StdCyclomaticComplexity (java-design) ➡️ use {% rule "java/design/CyclomaticComplexity" %}
|
||||
* SuspiciousConstantFieldName (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %}
|
||||
* UnnecessaryWrapperObjectCreation (java-performance) ➡️ use the new rule {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* UnsynchronizedStaticDateFormatter (java-multithreading) ➡️
|
||||
use {% rule java/multithreading/UnsynchronizedStaticFormatter %}
|
||||
* UnusedImports (java-bestpractices) ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* UseAssertEqualsInsteadOfAssertTrue (java-bestpractices) ➡️
|
||||
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* UseAssertNullInsteadOfAssertEquals (java-bestpractices) ➡️
|
||||
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* UseAssertSameInsteadOfAssertEquals (java-bestpractices) ➡️
|
||||
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* UseAssertTrueInsteadOfAssertEquals (java-bestpractices) ➡️
|
||||
use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* VariableNamingConventions (java-codestyle) ➡️ use {% rule java/codestyle/FieldNamingConventions %},
|
||||
{% rule java/codestyle/FormalParameterNamingConventions %},
|
||||
or {% rule java/codestyle/LocalVariableNamingConventions %}
|
||||
* WhileLoopsMustUseBraces (java-codestyle) ➡️ use {% rule "java/codestyle/ControlStatementBraces" %}
|
||||
* {% deleted_rule java/design/SimplifyBooleanAssertion %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* {% deleted_rule java/performance/SimplifyStartsWith %} ➡️ not replaced
|
||||
* {% deleted_rule java/design/StdCyclomaticComplexity %} ➡️ use {% rule "java/design/CyclomaticComplexity" %}
|
||||
* {% deleted_rule java/codestyle/SuspiciousConstantFieldName %} ➡️ use {% rule java/codestyle/FieldNamingConventions %}
|
||||
* {% deleted_rule java/performance/UnnecessaryWrapperObjectCreation %} ➡️ use the new rule {% rule "java/codestyle/UnnecessaryBoxing" %}
|
||||
* {% deleted_rule java/multithreading/UnsynchronizedStaticDateFormatter %} ➡️ use {% rule java/multithreading/UnsynchronizedStaticFormatter %}
|
||||
* {% deleted_rule java/bestpractices/UnusedImports %} ➡️ use {% rule java/codestyle/UnnecessaryImport %}
|
||||
* {% deleted_rule java/bestpractices/UseAssertEqualsInsteadOfAssertTrue %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* {% deleted_rule java/bestpractices/UseAssertNullInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* {% deleted_rule java/bestpractices/UseAssertSameInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* {% deleted_rule java/bestpractices/UseAssertTrueInsteadOfAssertEquals %} ➡️ use {% rule "java/bestpractices/SimplifiableTestAssertion" %}
|
||||
* {% deleted_rule java/codestyle/VariableNamingConventions %} ➡️ use {% rule java/codestyle/FieldNamingConventions %},
|
||||
{% rule java/codestyle/FormalParameterNamingConventions %}, or {% rule java/codestyle/LocalVariableNamingConventions %}
|
||||
* {% deleted_rule java/codestyle/WhileLoopsMustUseBraces %} ➡️ use {% rule "java/codestyle/ControlStatementBraces" %}
|
||||
|
||||
## 💥 Compatibility and Migration Notes
|
||||
|
||||
@ -606,7 +601,7 @@ See [ADR 3 - API evolution principles](pmd_projectdocs_decisions_adr_3.html) and
|
||||
|
||||
### XPath 3.1 support
|
||||
|
||||
Support for XPath versions 1.0, 1.0-compatibility was removed, support for XPath 2.0 is deprecated. The default
|
||||
Support for XPath versions 1.0, 1.0-compatibility, 2.0 was removed. The default
|
||||
(and only) supported XPath version is now XPath 3.1. This version of the XPath language is mostly identical to
|
||||
XPath 2.0.
|
||||
|
||||
|
@ -203,11 +203,11 @@
|
||||
<fileset dir="${target-package-dir}" />
|
||||
</replaceregexp>
|
||||
|
||||
<replace token=".beginLine" value=".getBeginLine()">
|
||||
<replace token=".beginLine" value=".getReportLocation().getStartLine()">
|
||||
<fileset dir="${target-package-dir}" />
|
||||
</replace>
|
||||
|
||||
<replace token=".beginColumn" value=".getBeginColumn()">
|
||||
<replace token=".beginColumn" value=".getReportLocation().getStartColumn()">
|
||||
<fileset dir="${target-package-dir}" />
|
||||
</replace>
|
||||
|
||||
|
@ -28,7 +28,6 @@ import net.sourceforge.pmd.cpd.CPDReport;
|
||||
import net.sourceforge.pmd.cpd.CPDReportRenderer;
|
||||
import net.sourceforge.pmd.cpd.CSVRenderer;
|
||||
import net.sourceforge.pmd.cpd.CpdAnalysis;
|
||||
import net.sourceforge.pmd.cpd.CpdLanguageProperties;
|
||||
import net.sourceforge.pmd.cpd.SimpleRenderer;
|
||||
import net.sourceforge.pmd.cpd.XMLRenderer;
|
||||
import net.sourceforge.pmd.lang.Language;
|
||||
@ -79,7 +78,7 @@ public class CPDTask extends Task {
|
||||
private boolean skipLexicalErrors;
|
||||
private boolean skipDuplicateFiles;
|
||||
private boolean skipBlocks = true;
|
||||
private String skipBlocksPattern = CpdLanguageProperties.DEFAULT_SKIP_BLOCKS_PATTERN;
|
||||
private String skipBlocksPattern;
|
||||
private File outputFile;
|
||||
private String encoding = System.getProperty("file.encoding");
|
||||
private List<FileSet> filesets = new ArrayList<>();
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import apex.jorje.data.ast.AssignmentOp;
|
||||
import apex.jorje.semantic.ast.expression.AssignmentExpression;
|
||||
|
||||
public final class ASTAssignmentExpression extends AbstractApexNode<AssignmentExpression> {
|
||||
@ -19,14 +18,6 @@ public final class ASTAssignmentExpression extends AbstractApexNode<AssignmentEx
|
||||
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());
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import apex.jorje.data.ast.BinaryOp;
|
||||
import apex.jorje.semantic.ast.expression.BinaryExpression;
|
||||
|
||||
public final class ASTBinaryExpression extends AbstractApexNode<BinaryExpression> {
|
||||
@ -19,13 +18,6 @@ public final 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());
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import apex.jorje.data.ast.BooleanOp;
|
||||
import apex.jorje.semantic.ast.expression.BooleanExpression;
|
||||
|
||||
|
||||
@ -14,21 +13,11 @@ public final class ASTBooleanExpression extends AbstractApexNode<BooleanExpressi
|
||||
super(booleanExpression);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
|
||||
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());
|
||||
}
|
||||
|
@ -4,16 +4,16 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import net.sourceforge.pmd.annotation.Experimental;
|
||||
|
||||
import apex.jorje.semantic.ast.AstNode;
|
||||
|
||||
/**
|
||||
* Interface for nodes that can contain comments. Because comments are for the most part lost, the tree builder only
|
||||
* captures whether the node did contain comments of any sort in the source code and not the actual contents of those
|
||||
* comments. This is useful for rules which need to know whether a node did contain comments.
|
||||
*
|
||||
* <p>This information is used for the rule "EmptyCatchBlock", which can ignore empty catch blocks, if they
|
||||
* contain comments.
|
||||
*/
|
||||
@Experimental
|
||||
public interface ASTCommentContainer<T extends AstNode> extends ApexNode<T> {
|
||||
|
||||
boolean getContainsComment();
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import apex.jorje.data.ast.PostfixOp;
|
||||
import apex.jorje.semantic.ast.expression.PostfixExpression;
|
||||
|
||||
|
||||
@ -14,21 +13,11 @@ public final class ASTPostfixExpression extends AbstractApexNode<PostfixExpressi
|
||||
super(postfixExpression);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
|
||||
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());
|
||||
}
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import apex.jorje.data.ast.PrefixOp;
|
||||
import apex.jorje.semantic.ast.expression.PrefixExpression;
|
||||
|
||||
public final class ASTPrefixExpression extends AbstractApexNode<PrefixExpression> {
|
||||
@ -13,20 +12,11 @@ public final class ASTPrefixExpression extends AbstractApexNode<PrefixExpression
|
||||
super(prefixExpression);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected <P, R> R acceptApexVisitor(ApexVisitor<? super P, ? extends R> visitor, P data) {
|
||||
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());
|
||||
}
|
||||
|
@ -6,8 +6,6 @@ package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.ast.AstVisitor;
|
||||
import net.sourceforge.pmd.lang.ast.impl.GenericNode;
|
||||
|
||||
import apex.jorje.semantic.ast.AstNode;
|
||||
@ -19,19 +17,6 @@ import apex.jorje.semantic.ast.AstNode;
|
||||
* @param <T> Type of the underlying Jorje node
|
||||
*/
|
||||
public interface ApexNode<T extends AstNode> extends GenericNode<ApexNode<?>> {
|
||||
|
||||
/**
|
||||
* Accept the visitor.
|
||||
*
|
||||
* @deprecated Use {@link #acceptVisitor(AstVisitor, Object)}
|
||||
*/
|
||||
@Deprecated
|
||||
@DeprecatedUntil700
|
||||
default Object jjtAccept(ApexParserVisitor visitor, Object data) {
|
||||
return acceptVisitor(visitor, data);
|
||||
}
|
||||
|
||||
|
||||
boolean hasRealLoc();
|
||||
|
||||
|
||||
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
|
||||
@DeprecatedUntil700
|
||||
@Deprecated
|
||||
public interface ApexParserVisitor extends ApexVisitor<Object, Object> {
|
||||
|
||||
@Override
|
||||
default Object visitNode(Node node, Object param) {
|
||||
for (Node child : node.children()) {
|
||||
child.acceptVisitor(this, param);
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
default Object visit(ApexNode<?> node, Object data) {
|
||||
return visitNode(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Object visitApexNode(ApexNode<?> node, Object data) {
|
||||
return visit(node, data); // calls the overload above for compatibility
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.ast;
|
||||
|
||||
import net.sourceforge.pmd.annotation.DeprecatedUntil700;
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedUntil700
|
||||
public class ApexParserVisitorAdapter extends ApexVisitorBase<Object, Object> implements ApexParserVisitor {
|
||||
|
||||
}
|
@ -328,8 +328,8 @@ final class ApexTreeBuilder extends AstVisitor<AdditionalPassScope> {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean containsComments(AbstractApexCommentContainerNode<?> commentContainer) {
|
||||
Location loc = commentContainer.getNode().getLoc();
|
||||
private boolean containsComments(ASTCommentContainer<?> commentContainer) {
|
||||
Location loc = ((AbstractApexCommentContainerNode<?>) commentContainer).getNode().getLoc();
|
||||
if (!Locations.isReal(loc)) {
|
||||
// Synthetic nodes don't have a location and can't have comments
|
||||
return false;
|
||||
|
@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexVisitorBase;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.xpath.Attribute;
|
||||
import net.sourceforge.pmd.util.designerbindings.DesignerBindings.DefaultDesignerBindings;
|
||||
@ -46,12 +46,12 @@ public class ApexDesignerBindings extends DefaultDesignerBindings {
|
||||
}
|
||||
|
||||
|
||||
private static final class MainAttrVisitor extends ApexParserVisitorAdapter {
|
||||
private static final class MainAttrVisitor extends ApexVisitorBase<Object, Object> {
|
||||
|
||||
private static final MainAttrVisitor INSTANCE = new MainAttrVisitor();
|
||||
|
||||
@Override
|
||||
public Object visit(ApexNode<?> node, Object data) {
|
||||
public Object visitApexNode(ApexNode<?> node, Object data) {
|
||||
return null; // don't recurse
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,6 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sourceforge.pmd.annotation.Experimental;
|
||||
import net.sourceforge.pmd.lang.apex.ApexLanguageProcessor;
|
||||
import net.sourceforge.pmd.lang.apex.ApexLanguageProperties;
|
||||
|
||||
@ -31,9 +30,10 @@ import com.nawforce.pkgforce.diagnostics.LoggerOps;
|
||||
* issues after packages are loaded and throw away the 'Org'. That would be a better model if all you wanted was the
|
||||
* issues but more complex rules will need the ability to traverse the internal graph of the 'Org'.
|
||||
*
|
||||
* <p>Note: This is used by {@link net.sourceforge.pmd.lang.apex.rule.design.UnusedMethodRule}.
|
||||
*
|
||||
* @author Kevin Jones
|
||||
*/
|
||||
@Experimental
|
||||
public final class ApexMultifileAnalysis {
|
||||
|
||||
// test only
|
||||
|
@ -4,16 +4,21 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexParserVisitor;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexVisitor;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.rule.AbstractRule;
|
||||
import net.sourceforge.pmd.reporting.RuleContext;
|
||||
|
||||
public abstract class AbstractApexRule extends AbstractRule
|
||||
implements ApexParserVisitor {
|
||||
public abstract class AbstractApexRule extends AbstractRule implements ApexVisitor<Object, Object> {
|
||||
|
||||
@Override
|
||||
public void apply(Node target, RuleContext ctx) {
|
||||
target.acceptVisitor(this, ctx);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visitNode(Node node, Object param) {
|
||||
node.children().forEach(n -> n.acceptVisitor(this, param));
|
||||
return param;
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ abstract class AbstractApexUnitTestRule extends AbstractApexRule {
|
||||
}
|
||||
|
||||
protected boolean isTestMethodOrClass(final ApexNode<?> node) {
|
||||
final ASTModifierNode modifierNode = node.getFirstChildOfType(ASTModifierNode.class);
|
||||
final ASTModifierNode modifierNode = node.firstChild(ASTModifierNode.class);
|
||||
return modifierNode != null && modifierNode.isTest();
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ public abstract class AbstractCounterCheckRule<T extends ApexNode<?>> extends Ab
|
||||
|
||||
|
||||
@Override
|
||||
public Object visit(ApexNode<?> node, Object data) {
|
||||
public Object visitApexNode(ApexNode<?> node, Object data) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T t = (T) node;
|
||||
// since we only visit this node, it's ok
|
||||
|
@ -1,51 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.performance;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlDeleteStatement;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlInsertStatement;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlMergeStatement;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlUndeleteStatement;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlUpdateStatement;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTDmlUpsertStatement;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link OperationWithLimitsInLoopRule}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AvoidDmlStatementsInLoopsRule extends AbstractAvoidNodeInLoopsRule {
|
||||
|
||||
// CPD-OFF - the same visits are in the replacement rule OperationWithLimitsInLoopRule
|
||||
@Override
|
||||
public Object visit(ASTDmlDeleteStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTDmlInsertStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTDmlMergeStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTDmlUndeleteStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTDmlUpdateStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object visit(ASTDmlUpsertStatement node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
// CPD-ON
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/*
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.performance;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTSoqlExpression;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link OperationWithLimitsInLoopRule}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AvoidSoqlInLoopsRule extends AbstractAvoidNodeInLoopsRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTSoqlExpression node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.performance;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTSoslExpression;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link OperationWithLimitsInLoopRule}
|
||||
*/
|
||||
@Deprecated
|
||||
public class AvoidSoslInLoopsRule extends AbstractAvoidNodeInLoopsRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTSoslExpression node, Object data) {
|
||||
return checkForViolation(node, data);
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.security;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTField;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTFieldDeclaration;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTMethodCallExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTNewKeyValueObjectExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTParameter;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTReferenceExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTSoqlExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTSoslExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTUserClass;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTVariableDeclaration;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ASTVariableExpression;
|
||||
import net.sourceforge.pmd.lang.apex.ast.ApexNode;
|
||||
|
||||
import apex.jorje.semantic.ast.member.Parameter;
|
||||
|
||||
/**
|
||||
* Helper methods
|
||||
*
|
||||
* @author sergey.gorbaty
|
||||
*
|
||||
* @deprecated Use {@link net.sourceforge.pmd.lang.apex.rule.internal.Helper} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public final class Helper {
|
||||
static final String ANY_METHOD = "*";
|
||||
|
||||
private Helper() {
|
||||
throw new AssertionError("Can't instantiate helper classes");
|
||||
}
|
||||
|
||||
static boolean isTestMethodOrClass(final ApexNode<?> node) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.isTestMethodOrClass(node);
|
||||
}
|
||||
|
||||
static boolean foundAnySOQLorSOSL(final ApexNode<?> node) {
|
||||
final List<ASTSoqlExpression> dmlSoqlExpression = node.findDescendantsOfType(ASTSoqlExpression.class);
|
||||
final List<ASTSoslExpression> dmlSoslExpression = node.findDescendantsOfType(ASTSoslExpression.class);
|
||||
|
||||
return !dmlSoqlExpression.isEmpty() || !dmlSoslExpression.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds DML operations in a given node descendants' path
|
||||
*
|
||||
* @param node
|
||||
*
|
||||
* @return true if found DML operations in node descendants
|
||||
*/
|
||||
static boolean foundAnyDML(final ApexNode<?> node) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.foundAnyDML(node);
|
||||
}
|
||||
|
||||
static boolean isMethodName(final ASTMethodCallExpression methodNode, final String className,
|
||||
final String methodName) {
|
||||
final ASTReferenceExpression reference = methodNode.getFirstChildOfType(ASTReferenceExpression.class);
|
||||
|
||||
return reference != null && reference.getNames().size() == 1
|
||||
&& reference.getNames().get(0).equalsIgnoreCase(className)
|
||||
&& (ANY_METHOD.equals(methodName) || isMethodName(methodNode, methodName));
|
||||
}
|
||||
|
||||
static boolean isMethodName(final ASTMethodCallExpression m, final String methodName) {
|
||||
return m.getMethodName().equalsIgnoreCase(methodName);
|
||||
}
|
||||
|
||||
static boolean isMethodCallChain(final ASTMethodCallExpression methodNode, final String... methodNames) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.isMethodCallChain(methodNode, methodNames);
|
||||
}
|
||||
|
||||
static String getFQVariableName(final ASTVariableExpression variable) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(variable);
|
||||
}
|
||||
|
||||
static String getFQVariableName(final ASTVariableDeclaration variable) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(variable);
|
||||
}
|
||||
|
||||
static String getFQVariableName(final ASTField variable) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(variable);
|
||||
}
|
||||
|
||||
static String getVariableType(final ASTField variable) {
|
||||
StringBuilder sb = new StringBuilder().append(variable.getDefiningType()).append(":")
|
||||
.append(variable.getName());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static String getFQVariableName(final ASTFieldDeclaration variable) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(variable);
|
||||
}
|
||||
|
||||
static String getFQVariableName(final ASTNewKeyValueObjectExpression variable) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(variable);
|
||||
}
|
||||
|
||||
static boolean isSystemLevelClass(ASTUserClass node) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.isSystemLevelClass(node);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String getFQVariableName(Parameter p) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(p.getDefiningType()).append(":").append(p.getName().getValue());
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static String getFQVariableName(ASTParameter p) {
|
||||
return net.sourceforge.pmd.lang.apex.rule.internal.Helper.getFQVariableName(p);
|
||||
}
|
||||
|
||||
}
|
@ -53,89 +53,6 @@ public class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidDmlStatementsInLoops"
|
||||
language="apex"
|
||||
since="5.5.0"
|
||||
deprecated="true"
|
||||
message="Avoid DML statements inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidDmlStatementsInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoiddmlstatementsinloops">
|
||||
<description>
|
||||
Avoid DML statements inside loops to avoid hitting the DML governor limit. Instead, try to batch up the data into a list and invoke your DML once on that list of data outside the loop.
|
||||
|
||||
_Note:_ This rule is deprecated since PMD 6.29.0 and will be removed with PMD 7.0.0. The rule is replaced
|
||||
by the more general rule {% rule "apex/performance/OperationWithLimitsInLoop" %}.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Something {
|
||||
public void foo() {
|
||||
for (Integer i = 0; i < 151; i++) {
|
||||
Account account;
|
||||
// ...
|
||||
insert account;
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidSoqlInLoops"
|
||||
language="apex"
|
||||
since="5.5.0"
|
||||
deprecated="true"
|
||||
message="Avoid Soql queries inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoqlInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoidsoqlinloops">
|
||||
<description>
|
||||
New objects created within loops should be checked to see if they can created outside them and reused.
|
||||
|
||||
_Note:_ This rule is deprecated since PMD 6.29.0 and will be removed with PMD 7.0.0. The rule is replaced
|
||||
by the more general rule {% rule "apex/performance/OperationWithLimitsInLoop" %}.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Something {
|
||||
public static void main( String as[] ) {
|
||||
for (Integer i = 0; i < 10; i++) {
|
||||
List<Account> accounts = [SELECT Id FROM Account];
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidSoslInLoops"
|
||||
language="apex"
|
||||
since="6.0.0"
|
||||
deprecated="true"
|
||||
message="Avoid Sosl queries inside loops"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.performance.AvoidSoslInLoopsRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_performance.html#avoidsoslinloops">
|
||||
<description>
|
||||
Sosl calls within loops can cause governor limit exceptions.
|
||||
|
||||
_Note:_ This rule is deprecated since PMD 6.29.0 and will be removed with PMD 7.0.0. The rule is replaced
|
||||
by the more general rule {% rule "apex/performance/OperationWithLimitsInLoop" %}.
|
||||
</description>
|
||||
<priority>3</priority>
|
||||
<example>
|
||||
<![CDATA[
|
||||
public class Something {
|
||||
public static void main( String as[] ) {
|
||||
for (Integer i = 0; i < 10; i++) {
|
||||
List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS RETURNING Account (Id, Name), Contact, Opportunity, Lead];
|
||||
}
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="EagerlyLoadedDescribeSObjectResult"
|
||||
language="apex"
|
||||
since="6.40.0"
|
||||
|
@ -34,7 +34,7 @@ class ApexXPathRuleTest extends ApexParserTestBase {
|
||||
|
||||
@Test
|
||||
void testBooleanExpressions() {
|
||||
Report report = apex.executeRuleOnResource(makeXPath("//BooleanExpression[@Operator='&&']"),
|
||||
Report report = apex.executeRuleOnResource(makeXPath("//BooleanExpression[@Op='&&']"),
|
||||
"BooleanExpressions.cls");
|
||||
assertSize(report, 1);
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
|
||||
*/
|
||||
|
||||
package net.sourceforge.pmd.lang.apex.rule.performance;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
class AvoidDmlStatementsInLoopsTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user