Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
1
vote
2answers
33 views

Why apex classes should declare a sharing model if dml or soql is used?

I have installed Apex PMD in my visual studio code for the static analysis of my code. I have a global class and inside it, I have written some DML/SOQL query. The static analyzer shows a warning ...
0
votes
1answer
20 views

Pmd analysis command not giving any output

I am running pmd command to fetch the report in html format but every time it gives me error Following command is used pmd.bat -d D:\TestSBX02\AllData\force-app\main\default\classes -f html -R D:\...
0
votes
0answers
41 views

Resolve PMD's ApexCRUDViolation

I'm having trouble resolving the ApexCRUDViolation for this method. It seems similar to this example, am I handling the fields queried via relationship correctly (e.g. ChargentOrders__Order__r....
0
votes
0answers
17 views

Are there any recent tools to help find org health?

I am looking to get metrics using Apex PMD on the status of all metadata in our org. Are there any ways to compile all of this data or any other tools that will be able to compile this data and ...
0
votes
0answers
87 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
135 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
316 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
2k 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
762 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
3k 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
149 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
863 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
95 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
400 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
437 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
994 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
351 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 ...