What is PMD?
While PMD doesn't authoritatively represent anything, a few retroacronyms have been proposed, including, for example, Programming Slip-up Indicator and Undertaking Complies with Time constraints.
Working of PMD
PMD Working Rules
Prior to running standards, PMD parses the source document into an information structure called an abstract syntax tree (AST). This tree addresses the syntactic construction of the code and encodes syntactic relations between source code components.
For example, in Java, technique statements have a place with a class: in the AST, the hubs addressing strategy statements will be relatives of a hub addressing the statement of their encasing class. This portrayal is hence a lot more extravagant than the first source code (which, for a program, is only a chain of characters) or the symbolic chain created by a lexer (which is, for example, what Checkstyle deals with).
Reasonably, PMD rules work by matching a "pattern" against the AST of a document. Rules investigate the AST and find hubs that fulfil a few circumstances that are normal for the particular thing the standard is attempting to signal. Leads then, at that point, report an infringement on these hubs.
Installation of PMD in Different Operating Systems
2. Linux Operating System:
3. Mac Operating System:
4. Windows( Chocolaty):
Writing New Rules
PMD upholds two methods for characterizing rules: utilizing an XPath query or utilizing a Java visitor. XPath rules are a lot simpler to set up since they're characterized straightforwardly in your ruleset XML and are expressive enough for almost any undertaking.
Then again, a few pieces of PMD's Programming interface are just open from Java, for example, getting to the utilization of a statement. Furthermore, Java rules permit you to do some convoluted handling, to which an XPath rule couldn't scale.
Eventually, picking one technique or the other relies upon the trouble of what your standard does. I'd encourage you to keep to XPath except if you have no other decision.
Defining a New Rule in XML
New rules should be proclaimed in a ruleset before they're referred to. This is the situation for both XPath and Java rules. To do this, the standard component is utilized, yet rather than referencing the ref property, it specifies the class characteristic with the execution class of your standard.
Documentation in PMD
The documentation sources can be found in two puts in light of how they are produced:
All handwritten documentation is put away in the subfolders under docs/pages. The organizer structure looks like the sidebar structure. Since all pages utilize a straightforward permalink, in the delivered HTML pages, all pages are levelled in one registry. This makes it simple to see the documentation additionally disconnected.
The classes for a language %lang% are situated in pmd-%lang%/src/primary/assets/classification/%lang% . So for Java the classes can be found under pmd-java/src/primary/assets/classification/java. The XML classification records in this catalogue are changed during incorporation into markdown pages depicting the principles they contain. These pages are set under docs/like the written by hand documentation and are then delivered with Jekyll like most of them. The standard documentation generator is the different submodulepmd-doc.
Changing the documentation of a standard should, in this way, not be finished on the markdown page, however straightforwardly on the XML rule tag compared to the standard, in the significant classification record.
The XML documentation of rules can contain GitHub seasoned markdown. Simply envelop the markdown inside the CDATA area by the XML. CDATA segments safeguard all organizing inside the delimiters and permit them to compose code tests without getting away from exceptional XML characters.