Questions tagged [pmd]

PMD is an open-source code analyser that scans source code and looks for potential problems like possible bugs, ugly or overcomplicated code and finds security flaws. It was recently ported from Java to Apex.

Filter by
Sorted by
Tagged with
0
votes
0answers
58 views

ApexCRUDviolation Fix

How to fix ApexCRUDViolation for inner query. Below is the query. proposal = [select Id, Name,(Select Id From PQConfig__Configurations__r) From Proposal__Proposal__c Where Proposal__Opportunity__c =:...
5
votes
0answers
115 views

How to create custom rules for PMD Apex static code analyzer?

How can I create custom rules for PMD? For example, if I want to create a rule to say 'all code should be in allman style and therefore, any line with { should be the only character on the line', how ...
4
votes
2answers
263 views

Apex PMD: Avoid empty block statements

Perhaps this isn't the place for this -- but it looks like a good place to start. I'm using Apex PMD code analysis (within Visual Studio Code) and it's throwing off the following for an interface ...
5
votes
1answer
1k views

Apex classes should escape/sanitize Strings obtained from URL parameters: How?

I have the following line of code in my visualforce controller. caseId = ApexPages.currentPage().getParameters().get('caseId'); I am using PMD, which is a static code analyzer. It complains me of ...
1
vote
1answer
606 views

Batchable & Schedulable class has cyclomatic complexity of 48

Background I have a class which implements Database.Batchable<Sobject> and Schedulable and when I run PMD I get this problem: The class 'MyClassBatchJob' has a total cyclomatic complexity of ...
7
votes
2answers
2k views

Apex PMD: Problem: Validate CRUD permission before SOQL/DML operation

Background I am using the Apex PMD plugin for VS Code and it's giving me this problem: Validate CRUD permission before SOQL/DML operation For this line of code: insert contentVersion; Which is ...
6
votes
2answers
122 views

Silence the AvoidGlobalModifier warning in @RestResource Apex controller

I have a simple Apex Controller annotated with @RestResource. According to the documentation, this must be declared global, but the static analysis complains due to the AvoidGlobalModifier PMD rule. ...
2
votes
1answer
716 views

Using PMD in IntelliJ IDE with Illuminated cloud 2

I am trying to use PMD in IntelliJ IDE using illuminated cloud. When I run PMD using pre-defined rules, no violations are reported. When I try to import custom rules from PMD's website, it does not ...
0
votes
1answer
73 views

VfUnescapeEl PMD Fix for VF Page

Can anyone provide your insights for fixing the VfUnescapeEl PMD issue in visualForce Page. For better understanding please see the below code snippet <script type="text/javascript" src="/...
0
votes
1answer
328 views

Error method has a cyclomatic complexity and nested if error

Please find the below trigger handler which is not passing PMD rules. Error 1."Deeply nested if..then statements are hard to read" for following class: Public Class LeadTriggerHandler { //Set ...
0
votes
2answers
373 views

PMD Apex static code analyser on Mac

I have used PMD before on Windows. I found this video very helpful for advising me of the correct PMD command to input for Windows. I want to use PMD on Mac. I have installed PMD (I know it's ...
2
votes
1answer
773 views

Apex CRUD Violation

if(Schema.sObjectType.SchemeMaster__c.fields.InterestRate__c.isAccessible() && Schema.sObjectType.PromotionMaster__c.fields.Name.isAccessible()) { sObj = [select name , ...
0
votes
3answers
4k views

What is apex PMD? How can I find our more about it?

I have searched google, but I am not able to find any primer on this topic.
1
vote
0answers
308 views

Facing issue in Jenkins integrated with Apex PMD

I have integrated Jenkins with PMD checksytle for Apex. package.xml <?xml version="1.0" encoding="UTF-8"?> <Package xmlns="http://soap.sforce.com/2006/04/metadata"> <types> <...
2
votes
2answers
1k views

ApexPMD Custom ruleset

I would like to add a new rule related to DMLStatements in for loops. What i have thought I could create a class with "AvoidDmlStatementsInLoopsRule" class code then convert it into .jar and ...
2
votes
1answer
2k views

ApexPMD eclipse plugin for Salesforce

I have installed ApexPmd plugin for Eclipse(Luna). After installation I can able to "Run ApexPMD" for individual Class. (a) There is an option “Add ApexPMD Nature” providing by the ApexPMD, where it ...