Replies: 1 comment 4 replies
-
@aklmmap Thanks for the question. I have some follow up questions for clarification:
From the snippet I see, it seems like it is flagging assert method calls, when they occur outside of test classes. Is that correct? Then I don't understand, why the ContactTrigger is flagged, because I don't see a assert method call... I very good tool to analyze the AST, e.g. the ContactTrigger, and develop rules is the designer -> see https://pmd.github.io/latest/pmd_userdocs_extending_designer_reference.html In order to copy the code snippet into the Designer, I've typed it here from what I could read from the screenshot: trigger ContactTrigger on Contact (before insert, before update, before delete, after insert, after update, after delete) {
ContactTriggerDAO contactDAO = new ContactTriggerDAO();
if (contactDAO.getTriggerFlag('Contact')) {
new ContactTriggerHandler().run();
}
} I can only see |
Beta Was this translation helpful? Give feedback.
-
We use the following code to throw violations where a test class should use test methods. isTestMethodOrClass(node) is the predefined method used here to check whether a node here is test method or class.
it is working fine for test classes where the violations are being captured correctly.
Unfortunately this violation is flagging for triggers also where as it should only be flagged for test classes. Please find the snippet of the violation for a trigger in the attachment.
Code starts here:
Originally posted by @aklmmap in #2998 (comment)
Beta Was this translation helpful? Give feedback.
All reactions