What is PMD?PMD is an open-source static source code analyzer that reports on issues found inside application code. PMD incorporates work in rule sets and supports the capacity to compose custom guidelines. PMD doesn't report aggregation blunders, as it can just deal with very shaped source documents. Issues revealed by PMD are fairly wasteful code or awful programming propensities, which can lessen the presentation and viability of the program, assuming that they amass. It can examine records written in Java, JavaScript, Peak and Visualforce, PLSQL, Apache Speed, XML, and XSL. Also, it incorporates CPD, the duplicate glue indicator. CPD tracks down copied code in Java, C, C++, C#, Sweet, PHP, Ruby, Fortran, JavaScript, PLSQL, Apache Speed, Scala, Objective C, Matlab, Python, Go, Quick and Salesforce.com Zenith and Visualforce. 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 RulesPrior 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 Systems1. Windows:
2. Linux Operating System:
3. Mac Operating System:
4. Windows( Chocolaty):
Writing New RulesPMD 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 XMLNew 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. Example: https://github.com/pmd/pmd/releases/download/pmd_releases%2F6.49.0/pmd-bin-6.49.0.zip Documentation in PMDThe documentation sources can be found in two puts in light of how they are produced:
Handwritten Documentation 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. Rule Documentation 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. Example:
Next TopicRegionMatches() Method in Java
|