{"id":11047,"date":"2023-03-27T11:04:43","date_gmt":"2023-03-27T09:04:43","guid":{"rendered":"https:\/\/texei.com\/?p=11047"},"modified":"2023-08-10T16:29:58","modified_gmt":"2023-08-10T14:29:58","slug":"enforce-code-standards-with-pmd","status":"publish","type":"post","link":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/","title":{"rendered":"Enforce code standards with PMD"},"content":{"rendered":"\r\n<p>Developers working on a project usually set <strong>coding rules<\/strong> to have a standardized codebase. It is an important piece of the code <strong>maintainability<\/strong>, and it can be very easy to deviate from a rule or make mistakes. This is where tools like <strong>PMD<\/strong> come in play. PMD is a Java application that <strong>analyzes<\/strong> a code against a given set of rules. It can look at a wide variety of features, from naming conventions to cognitive complexity, or the risk of SOQL injection for example. It supports several languages, including <strong>Apex<\/strong>, so let&#8217;s see how we can use it to improve our code quality.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id=\"h-how-to-install-and-use-pmd\">How to install and use PMD ?\u00a0<\/h3>\r\n\r\n\r\n\r\n<p>To install PMD, follow <a href=\"https:\/\/pmd.github.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">these instruction<\/a>. As stated in the <a href=\"https:\/\/pmd.github.io\/latest\/pmd_userdocs_installation.html\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a>, you will need Java JRE and Open JDK to run it. You could also create a permanent alias to run it quickly.<\/p>\r\n\r\n\r\n\r\n<p>In order to run properly, PMD needs to know which rules to check when performing its analysis. This is done by giving it a file (called a ruleset) containing the list of rules to take in account. For the moment, let&#8217;s use the full standard set of Apex rules and discuss later how to customize it.<\/p>\r\n\r\n\r\n\r\n<p>Once installed, we can run PMD using the following command:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>pmd -d &lt;path_to_file&gt; -R &lt;path_to_ruleset&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>with the following parameters:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><code>-d &lt;path_to_file&gt;<\/code> : the path to the file or folder to be analyzed<\/li>\r\n\r\n\r\n\r\n<li><code>-R &lt;path_to_ruleset&gt;<\/code> : the path to the ruleset file<\/li>\r\n\r\n\r\n\r\n<li>(optionnal) <code>-f &lt;format&gt;<\/code> : the output format among the <a href=\"https:\/\/pmd.github.io\/latest\/pmd_userdocs_report_formats.html\" target=\"_blank\" rel=\"noreferrer noopener\">available ones<\/a>, such as JSON, HTML or colored text (default is plain text)<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>There are other options not used here but detailed in the proper <a href=\"https:\/\/pmd.github.io\/latest\/pmd_userdocs_cli_reference.html\" target=\"_blank\" rel=\"noreferrer noopener\">documentation<\/a>.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">Analyze a file<\/h3>\r\n\r\n\r\n\r\n<p>Now we know how to run PMD, let&#8217;s see how it works on a piece of code. To illustrate how it works, we will use the following class, deliberately written in such a way that PMD will raise errors when analyzing it:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>class testClass {\r\n    public static void method1 () {\r\n        String s = 'test';\r\n\r\n        for (Integer i = 1; i &lt; 100; i++) {\r\n            List&lt;Account&gt; Accs = [select id, name from Account];\r\n            if (Accs.size() &gt; 0) system.Debug('Not empty list');\r\n            for (account a : accs) {\r\n                a.RecordTypeId = '012500000009WAr';\r\n            }\r\n        }\r\n    }\r\n}<\/code><\/pre>\r\n\r\n\r\n\r\n<p>We may notice some slight deviation with what is usually considered good code writing in the developer community. Let&#8217;s run PMD on this class with the previous command, and look at the output:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>.\/testClass.cls:1:\tApexSharingViolations:\tApex classes should declare a sharing model if DML or SOQL\/SOSL is used\r\n.\/testClass.cls:1:\tClassNamingConventions:\tThe class name 'testClass' doesn't match '[A-Z][a-zA-Z0-9_]*'\r\n.\/testClass.cls:2:\tApexDoc:\tMissing ApexDoc comment\r\n.\/testClass.cls:3:\tUnusedLocalVariable:\tVariable 's' defined but not used\r\n.\/testClass.cls:6:\tOperationWithLimitsInLoop:\tAvoid operations in loops that may hit governor limits\r\n.\/testClass.cls:6:\tLocalVariableNamingConventions:\tThe local variable name 'Accs' doesn't match '[a-z][a-zA-Z0-9]*'\r\n.\/testClass.cls:6:\tApexCRUDViolation:\tValidate CRUD permission before SOQL\/DML operation or enforce user mode\r\n.\/testClass.cls:7:\tAvoidDebugStatements:\tAvoid debug statements since they impact on performance\r\n.\/testClass.cls:7:\tIfStmtsMustUseBraces:\tAvoid using if statements without curly braces\r\n.\/testClass.cls:7:\tIfElseStmtsMustUseBraces:\tAvoid using if...else statements without curly braces\r\n.\/testClass.cls:7:\tDebugsShouldUseLoggingLevel:\tCalls to System.debug should specify a logging level.\r\n.\/testClass.cls:9:\tAvoidHardcodingId:\tHardcoding Ids is bound to break when changing environments.<\/code><\/pre>\r\n\r\n\r\n\r\n<p>As we can see, the output is a list of violations of the rules, with the line and a message about the violation. For instance, there is an issue with the class naming convention (<code>ClassNamingConventions<\/code>, line 1). PMD also detected the presence of SOQL in a loop (<code>OperationWithLimitsInLoop<\/code>, line 6). With that bit of information in mind, we can start correcting our code so that it fits the rules.<\/p>\r\n\r\n\r\n\r\n<p>In some case, we might happen to have good reasons to willingly break some rule. Then we would want to tell PMD to <strong>ignore<\/strong> a class or a line. There are several ways to do so. First there is an <strong>annotation<\/strong> that can be added to a class to suppress PMD warnings. It works with a single rule, a list of rules or for all PMD entirely. This is done by placing one of the following lines before a class definition:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>\/\/ This will suppress all the PMD warnings in this class\r\n@SuppressWarnings('PMD')\r\n\/\/ This will suppress a single rule warning in this class\r\n@SuppressWarnings('PMD.ExcessiveClassLength')\r\n\/\/ This will suppress a list of rule warnings in this class\r\n@SuppressWarnings('PMD.EmptyCatchBlock, PMD.AvoidDebugStatements')<\/code><\/pre>\r\n\r\n\r\n\r\n<p>If we want to suppress rules at the <strong>line level<\/strong>, we can also use the <code>\/\/NOPMD<\/code> comment, which tells PMD to ignore the line in its analysis. Finally, there are more complex ways to customize the warning suppression in the ruleset, based on rules properties. This method is defined in the documentation about <a href=\"https:\/\/pmd.github.io\/latest\/pmd_userdocs_suppressing_warnings.html\" target=\"_blank\" rel=\"noreferrer noopener\">suppressing warnings<\/a>.<\/p>\r\n\r\n\r\n\r\n<p>These feature allows us to bypass PMD for exceptional cases, but we need a more systematic approach of rule management for a full project. This is were the ruleset comes into play. It allows us to define the rules we want and those we don&#8217;t. Let&#8217;s see in the next part how to use it.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">Building a ruleset<\/h3>\r\n\r\n\r\n\r\n<p>We mentioned earlier the <strong>ruleset<\/strong> file, where we configure the list of rules that should be checked by PMD. There are pre-defined rules, different for each supported language, that can be added to the ruleset. Let&#8217;s see how to setup and customize the ruleset.<\/p>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\" id=\"h-basic-ruleset-usage\">Basic ruleset usage<\/h2>\r\n\r\n\r\n\r\n<p>First a word about the available rules. They are classified into <strong>categories<\/strong>, which are defined as follow for Apex:<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_bestpractices.html\" target=\"_blank\" rel=\"noreferrer noopener\">Best practices<\/a><\/strong>: generic rules and best practices such those related to test classes or variable usage<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_codestyle.html\" target=\"_blank\" rel=\"noreferrer noopener\">Code Style<\/a><\/strong>: rules related to various naming conventions and clean code<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_design.html#avoiddeeplynestedifstmts\" target=\"_blank\" rel=\"noreferrer noopener\">Design<\/a><\/strong>: checks design metrics of the code, like complexity, class length or number of methods<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_documentation.html\" target=\"_blank\" rel=\"noreferrer noopener\">Documentation<\/a><\/strong>: check the presence and concordance of <a href=\"https:\/\/github.com\/SalesforceFoundation\/ApexDoc\" target=\"_blank\" rel=\"noreferrer noopener\">ApexDoc<\/a> for classes and methods (similar to <a href=\"https:\/\/en.wikipedia.org\/wiki\/Javadoc\" target=\"_blank\" rel=\"noreferrer noopener\">JavaDoc<\/a>)<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_errorprone.html\" target=\"_blank\" rel=\"noreferrer noopener\">Error Prone<\/a><\/strong>: check for code that could lead to bugs or errors, like empty block or hardcoded Ids<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_performance.html\" target=\"_blank\" rel=\"noreferrer noopener\">Performance<\/a><\/strong>: check code that could lead to performance issues, such as debugs statements or SOQL\/DML in loops<\/li>\r\n\r\n\r\n\r\n<li><strong><a href=\"https:\/\/pmd.github.io\/latest\/pmd_rules_apex_security.html\" target=\"_blank\" rel=\"noreferrer noopener\">Security<\/a><\/strong>: look for potential security issues such as SOQL injections<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p>The ruleset is a XML file that contains all rules PMD should use. Here is its basic structure:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;?xml version=\"1.0\" ?&gt;\r\n&lt;ruleset\r\n    name=\"My PMD ruleset\"\r\n    xmlns=\"http:\/\/pmd.sourceforge.net\/ruleset\/2.0.0\"\r\n    xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n    xsi:schemaLocation=\"http:\/\/pmd.sourceforge.net\/ruleset\/2.0.0 https:\/\/pmd.sourceforge.io\/ruleset_2_0_0.xsd\"\r\n&gt;\r\n    &lt;description&gt;\r\n        My PMD ruleset\r\n    &lt;\/description&gt;\r\n    &lt;rule ref=\"category\/apex\/bestpractices.xml\/UnusedLocalVariable\"&gt;\r\n    &lt;\/rule&gt;\r\n&lt;\/ruleset&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Here, the first lines contain the definition of the ruleset and its description. Then the <code>&lt;rule&gt;<\/code> tag adds a rule, with a reference containing its language (<code>apex<\/code>), category (<code>bestpractices<\/code>) and name (<code>UnusedLocalVariable<\/code>). This allows us to include a single rule, but we might want to add an entire category. This can be done with the same tag, by only including the name of the category:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;rule ref=\"category\/apex\/codestyle.xml\"&gt;&lt;\/rule&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>When adding a category, we can choose to <strong>exclude<\/strong> a specific rule from that category. For instance, the following code adds all <code>codestyle<\/code> rules except the one called <code>FieldDeclarationsShouldBeAtStart<\/code>:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;rule ref=\"category\/apex\/codestyle.xml\"&gt;\r\n    &lt;exclude name=\"FieldDeclarationsShouldBeAtStart\" \/&gt;\r\n&lt;\/rule&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading\">Customizing the rules<\/h2>\r\n\r\n\r\n\r\n<p>Some rules have <strong>properties<\/strong> that can be set to configure their behavior. For instance, the <code>AvoidDeeplyNestedIfStmts<\/code> rule checks that there is no excessively nested <code>if<\/code> statements in the code. We can set the nesting threshold using the <code>problemDepth<\/code> parameter (default value is 3). There is also the option to customize the <strong>error message<\/strong> that get displayed.<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;rule ref=\"category\/apex\/design.xml\/AvoidDeeplyNestedIfStmts\" message=\"There is more than 5 nested If statements\"&gt;\r\n    &lt;properties&gt;\r\n        &lt;property name=\"problemDepth\" value=\"5\" \/&gt;\r\n    &lt;\/properties&gt;\r\n&lt;\/rule&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>With this feature, we can for instance customize rules with our own naming conventions. For rules dedicated to class and variable names, we can define <strong>regular expression<\/strong> to apply for different situations (such as test classes, static or final variables).<\/p>\r\n\r\n\r\n\r\n<p>We also may need to <strong>ignore<\/strong> files from being processing by PMD with the <code>&lt;exclude-pattern&gt;<\/code> tag. And if a file should be included despite matching an exclude pattern, we can use the <code>&lt;include-pattern&gt;<\/code> to specify it. This comes in addition with the previously seen <code>@SuppressWarnings<\/code> and <code>NOPMD<\/code> features. For example, the following lines make PMD ignore all files ending by <code>Test.cls<\/code> but will still include the file <code>SpecificTest.cls<\/code> in the analysis:<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>&lt;exclude-pattern&gt;.*\/force-app\/main\/default\/classes\/*Test.cls&lt;\/exclude-pattern&gt;\r\n&lt;include-pattern&gt;.*\/force-app\/main\/default\/classes\/SpecificTest.cls&lt;\/include-pattern&gt;<\/code><\/pre>\r\n\r\n\r\n\r\n<p>Until now, we only worked with the rules provided by PMD, but it may not be enough. If we need to customize even more our ruleset, there is the option to <strong>create our own rules<\/strong>. This can be done using <a href=\"https:\/\/www.w3schools.com\/xml\/xpath_intro.asp\" target=\"_blank\" rel=\"noreferrer noopener\">XPath<\/a> or by defining custom Java classes. It enables us to make complex calculations to evaluate one&#8217;s code. However, this feature is outside the article&#8217;s scope but there are some information about the way to handle it in the <a href=\"https:\/\/pmd.github.io\/latest\/pmd_userdocs_extending_writing_rules_intro.html\" target=\"_blank\" rel=\"noreferrer noopener\">dedicated documentation<\/a>. We can also check <a href=\"https:\/\/github.com\/rsoesemann\/unhappy-soup\/blob\/master\/ruleset.xml\" target=\"_blank\" rel=\"noreferrer noopener\">this example of ruleset<\/a> for Apex, that defines custom rules with XPath relevant for Salesforce environments.<\/p>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\">Summary and references<\/h3>\r\n\r\n\r\n\r\n<p><strong>Coding standards<\/strong> are important in a team so that developers understand each other&#8217;s code easily. PMD can help us enforce them by pointing where and how a code can be improved. In this article, we saw how to implement it in a project using its main features, and to customize our rules so that it best fits our team&#8217;s standards. This software can be part of an <strong>CI\/CD strategy<\/strong>, where the code is automatically analyzed before merging into the main branch. Note that there exists a tool that comes with PMD, which can detect duplicate code (CPD for Copy\/Paste Detector). However, it doesn&#8217;t support Apex at the moment.<\/p>\r\n\r\n\r\n\r\n<ul class=\"wp-block-list\">\r\n<li><a href=\"https:\/\/github.com\/pmd\/pmd\">PMD Github<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/pmd.github.io\/latest\/index.html\">Official documentation<\/a><\/li>\r\n\r\n\r\n\r\n<li><a href=\"https:\/\/analysis-tools.dev\/tag\/apex\" target=\"_blank\" rel=\"noreferrer noopener\">A list of Apex static code analyzers<\/a><\/li>\r\n<\/ul>\r\n<p>&nbsp;<\/p>\r\n<p>If you want to discover other articles, it is <a href=\"https:\/\/texei.com\/conseils\/day-7-manage-your-permissions-sets-with-the-new-assignment-expiration-feature-on-permission-sets-and-permission-set-groups\/\">here<\/a> !<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Developers working on a project usually set coding rules to have a standardized codebase. It is an important piece of the code maintainability, and it can be very easy to deviate from a rule or make mistakes. This is where tools like PMD come in play. PMD is a Java application that analyzes a code [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":11562,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[300],"tags":[306,307,308],"class_list":["post-11047","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-advices","tag-apex-en","tag-development-en","tag-pmd-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.1 (Yoast SEO v27.1.1) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Enforce code standards with PMD - Texe\u00ef<\/title>\n<meta name=\"description\" content=\"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Enforce code standards with PMD\" \/>\n<meta property=\"og:description\" content=\"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !\" \/>\n<meta property=\"og:url\" content=\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\" \/>\n<meta property=\"og:site_name\" content=\"Texe\u00ef\" \/>\n<meta property=\"article:published_time\" content=\"2023-03-27T09:04:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-10T14:29:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1440\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Loic Nicolas\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\"},\"author\":{\"name\":\"Loic Nicolas\",\"@id\":\"https:\/\/texei.com\/#\/schema\/person\/32d30458389e87b451b28c5a2822fff6\"},\"headline\":\"Enforce code standards with PMD\",\"datePublished\":\"2023-03-27T09:04:43+00:00\",\"dateModified\":\"2023-08-10T14:29:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\"},\"wordCount\":1284,\"publisher\":{\"@id\":\"https:\/\/texei.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png\",\"keywords\":[\"Apex\",\"Development\",\"PMD\"],\"articleSection\":[\"Advices\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\",\"url\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\",\"name\":\"Enforce code standards with PMD - Texe\u00ef\",\"isPartOf\":{\"@id\":\"https:\/\/texei.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png\",\"datePublished\":\"2023-03-27T09:04:43+00:00\",\"dateModified\":\"2023-08-10T14:29:58+00:00\",\"description\":\"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !\",\"breadcrumb\":{\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage\",\"url\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png\",\"contentUrl\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png\",\"width\":1440,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/texei.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advices\",\"item\":\"https:\/\/texei.com\/en\/category\/advices\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enforce code standards with PMD\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/texei.com\/#website\",\"url\":\"https:\/\/texei.com\/\",\"name\":\"Texe\u00ef\",\"description\":\"Turn your IT into Business\",\"publisher\":{\"@id\":\"https:\/\/texei.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/texei.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/texei.com\/#organization\",\"name\":\"Texe\u00ef\",\"url\":\"https:\/\/texei.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/texei.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2021\/03\/logo-essai-1.jpg\",\"contentUrl\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2021\/03\/logo-essai-1.jpg\",\"width\":2560,\"height\":1102,\"caption\":\"Texe\u00ef\"},\"image\":{\"@id\":\"https:\/\/texei.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/texei.com\/#\/schema\/person\/32d30458389e87b451b28c5a2822fff6\",\"name\":\"Loic Nicolas\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/texei.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/07\/avatar_user_14_1690808344-96x96.png\",\"contentUrl\":\"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/07\/avatar_user_14_1690808344-96x96.png\",\"caption\":\"Loic Nicolas\"},\"url\":\"https:\/\/texei.com\/en\/author\/loicnicolas\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Enforce code standards with PMD - Texe\u00ef","description":"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/","og_locale":"en_US","og_type":"article","og_title":"Enforce code standards with PMD","og_description":"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !","og_url":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/","og_site_name":"Texe\u00ef","article_published_time":"2023-03-27T09:04:43+00:00","article_modified_time":"2023-08-10T14:29:58+00:00","og_image":[{"width":1440,"height":1080,"url":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png","type":"image\/png"}],"author":"Loic Nicolas","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#article","isPartOf":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/"},"author":{"name":"Loic Nicolas","@id":"https:\/\/texei.com\/#\/schema\/person\/32d30458389e87b451b28c5a2822fff6"},"headline":"Enforce code standards with PMD","datePublished":"2023-03-27T09:04:43+00:00","dateModified":"2023-08-10T14:29:58+00:00","mainEntityOfPage":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/"},"wordCount":1284,"publisher":{"@id":"https:\/\/texei.com\/#organization"},"image":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage"},"thumbnailUrl":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png","keywords":["Apex","Development","PMD"],"articleSection":["Advices"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/","url":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/","name":"Enforce code standards with PMD - Texe\u00ef","isPartOf":{"@id":"https:\/\/texei.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage"},"image":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage"},"thumbnailUrl":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png","datePublished":"2023-03-27T09:04:43+00:00","dateModified":"2023-08-10T14:29:58+00:00","description":"PMD is a static code analyzer that supports Apex language. Discover how to enforce code standards with PMD !","breadcrumb":{"@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#primaryimage","url":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png","contentUrl":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/03\/Remote-ideation-1.png","width":1440,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/texei.com\/en\/advices\/enforce-code-standards-with-pmd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/texei.com\/"},{"@type":"ListItem","position":2,"name":"Advices","item":"https:\/\/texei.com\/en\/category\/advices\/"},{"@type":"ListItem","position":3,"name":"Enforce code standards with PMD"}]},{"@type":"WebSite","@id":"https:\/\/texei.com\/#website","url":"https:\/\/texei.com\/","name":"Texe\u00ef","description":"Turn your IT into Business","publisher":{"@id":"https:\/\/texei.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/texei.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/texei.com\/#organization","name":"Texe\u00ef","url":"https:\/\/texei.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/texei.com\/#\/schema\/logo\/image\/","url":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2021\/03\/logo-essai-1.jpg","contentUrl":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2021\/03\/logo-essai-1.jpg","width":2560,"height":1102,"caption":"Texe\u00ef"},"image":{"@id":"https:\/\/texei.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/texei.com\/#\/schema\/person\/32d30458389e87b451b28c5a2822fff6","name":"Loic Nicolas","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/texei.com\/#\/schema\/person\/image\/","url":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/07\/avatar_user_14_1690808344-96x96.png","contentUrl":"https:\/\/texei.com\/dev\/wp-content\/uploads\/2023\/07\/avatar_user_14_1690808344-96x96.png","caption":"Loic Nicolas"},"url":"https:\/\/texei.com\/en\/author\/loicnicolas\/"}]}},"_links":{"self":[{"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/posts\/11047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/comments?post=11047"}],"version-history":[{"count":0,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/posts\/11047\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/media\/11562"}],"wp:attachment":[{"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/media?parent=11047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/categories?post=11047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/texei.com\/en\/wp-json\/wp\/v2\/tags?post=11047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}