Change rule name to UnusedMethod, correct logging and add FIXME
This commit is contained in:
1 parent
1187b9e4e1
commit
8bc57f349a
5 files changed
+27
-15
No files matched your search
@@ -74,7 +74,7 @@ The default version is always ES6.
|
||||
|
||||
#### New Rules
|
||||
|
||||
* The Apex rule {% rule "apex/design/AvoidUnusedMethod" %} finds unused methods in your code.
|
||||
* The Apex rule {% rule "apex/design/UnusedMethod" %} finds unused methods in your code.
|
||||
|
||||
#### Changed Rules
|
||||
|
||||
|
||||
+5
-2
@@ -67,6 +67,9 @@ public final class ApexMultifileAnalysis {
|
||||
// Load the package into the org, this can take some time!
|
||||
org.newSFDXPackage(multiFileAnalysisDirectory); // this may fail if the config is wrong
|
||||
org.flush();
|
||||
|
||||
// FIXME: Syntax & Semantic errors found during Org loading are not currently being reported. These
|
||||
// should be routed to the new SemanticErrorReporter but that is not available for use just yet.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +119,7 @@ public final class ApexMultifileAnalysis {
|
||||
} catch (Exception e) {
|
||||
LOG.severe("Exception while initializing Apexlink (" + e.getMessage() + ")");
|
||||
LOG.severe(ExceptionUtils.getStackTrace(e));
|
||||
LOG.severe("PMD will not attempt to initialize Apexlink further, this can cause rules like AvoidUnusedMethod to be dysfunctional");
|
||||
LOG.severe("PMD will not attempt to initialize Apexlink further, this can cause rules like UnusedMethod to be dysfunctional");
|
||||
return FAILED_INSTANCE;
|
||||
}
|
||||
});
|
||||
@@ -129,7 +132,7 @@ public final class ApexMultifileAnalysis {
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
LOG.fine(message);
|
||||
LOG.severe(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ import net.sourceforge.pmd.lang.apex.rule.AbstractApexRule;
|
||||
|
||||
import com.nawforce.common.api.UNUSED_CATEGORY$;
|
||||
|
||||
public class AvoidUnusedMethodRule extends AbstractApexRule {
|
||||
public class UnusedMethodRule extends AbstractApexRule {
|
||||
|
||||
@Override
|
||||
public Object visit(ASTMethod node, Object data) {
|
||||
@@ -36,12 +36,12 @@ public class Foo {
|
||||
</example>
|
||||
</rule>
|
||||
|
||||
<rule name="AvoidUnusedMethod"
|
||||
<rule name="UnusedMethod"
|
||||
language="apex"
|
||||
since="7.0.0"
|
||||
message="Unused methods make understanding code harder"
|
||||
class="net.sourceforge.pmd.lang.apex.rule.design.AvoidUnusedMethodRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_design.html#avoidunusedmethod">
|
||||
class="net.sourceforge.pmd.lang.apex.rule.design.UnusedMethodRule"
|
||||
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_apex_design.html#unusedmethod">
|
||||
<description>
|
||||
Avoid having unused methods since they make understanding and maintaining code harder.
|
||||
|
||||
@@ -59,15 +59,24 @@ may be referenced from the Apex source code, such as Custom Objects, Visualforce
|
||||
or the older MDAPI format. The 'packageDirectories' entries in 'sfdx-project.json' are used to determine which
|
||||
directories to search for metadata, if a .forceignore file is present it will be honoured.
|
||||
|
||||
To check for errors in your configuration turn on debug logging with the '-debug' flag.
|
||||
|
||||
If the Apex code references external packages via namespace(s) you should declare these in your 'sfdx-project.json'
|
||||
file using the syntax below to avoid errors:
|
||||
file using the 'plugins' syntax below to avoid errors:
|
||||
<![CDATA[
|
||||
"plugins": {
|
||||
"dependencies": [
|
||||
{"namespace": "aa"}
|
||||
]
|
||||
{
|
||||
"packageDirectories": [
|
||||
{
|
||||
"path": "src",
|
||||
"default": true
|
||||
}
|
||||
],
|
||||
"namespace": "my_namespace",
|
||||
"sfdcLoginUrl": "https://login.salesforce.com",
|
||||
"sourceApiVersion": "52.0",
|
||||
"plugins": {
|
||||
"dependencies": [
|
||||
{"namespace": "aa"}
|
||||
]
|
||||
}
|
||||
}
|
||||
]]>
|
||||
</description>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
This ruleset contains links to rules that are new in PMD v7.0.0
|
||||
</description>
|
||||
|
||||
<rule ref="category/apex/design.xml/AvoidUnusedMethod"/>
|
||||
<rule ref="category/apex/design.xml/UnusedMethod"/>
|
||||
|
||||
</ruleset>
|
||||
|
||||
Reference in new issue
Block a user