SlideShare une entreprise Scribd logo
1  sur  9
Télécharger pour lire hors ligne
What is PMD ?
PMD is a source code analyzer.
It finds unused variables, empty catch blocks,
unnecessary object creation, and so forth.
PMD works by scanning Java code and checks for violations
in three major areas:
– Compliance with coding standards
– Coding antipatterns
– Cut and Paste Detector (CPD)
Compliance with coding standards
● Naming conventions
– class, method, parameter and variable names
● Class and method length
● Existence and formatting of comments and JavaDocs
Coding antipatterns
● Possible bugs - Empty try/catch/finally/switch blocks
● Dead code - Unused local variables, parameters and private methods
● Empty (if/while) statements
● Suboptimal code - wasteful String/StringBuffer usage
Coding antipatterns (2)
Overcomplicated expressions
– unnecessary if statements, for loops that could be while loops
Duplicate code
– copied/pasted code means copied/pasted bugs
Classes with high Cyclomatic Complexity measurements
Cut and Paste Detector (CPD)
a tool that scans files and looks for suspect code replication.
CPD can be parametrized by the minimum size of the code block.
Stakeholders
● Developers use PMD to comply with coding standards and
deliver quality code.
● Team leaders and Quality Assurance folks use it to change the
nature of code reviews.
● Team members can do peer-to-peer discussion
PMD has the potential to transform a mechanical and syntax check
oriented code review into a to dynamic peer-to-peer discussion.
Rules
PMD comes with many predefined rules; we can add more or
customize existing one.
EmptyFinallyBlock
– Avoid empty finally blocks - these can be deleted
UnnecessaryReturn
– Avoid unnecessary return statements
LongVariable
– Detects when a field, local variable is declared with a long name
PMD rules has been grouped into Rule sets
Rule set: Naming Rules
– Rule: VariableNamingConventions
– Rule: MethodNamingConventions
– Rule: ClassNamingConventions
– Rule: NoPackage
Rule set: Unused Code Rules
– Rule: UnusedPrivateField
– Rule: UnusedLocalVariable

Contenu connexe

Tendances

Android PPT Presentation 2018
Android PPT Presentation 2018Android PPT Presentation 2018
Android PPT Presentation 2018Rao Purna
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React? Lisa Gagarina
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating SystemBilal Mirza
 
Android technology _seminar_ ppt
Android technology _seminar_ pptAndroid technology _seminar_ ppt
Android technology _seminar_ pptvikas bharat
 
Different wait methods or commands in Selenium
Different wait methods or commands in SeleniumDifferent wait methods or commands in Selenium
Different wait methods or commands in SeleniumVinay Kumar Pulabaigari
 
Android App Development Proposal PowerPoint Presentation Slides
Android App Development Proposal PowerPoint Presentation SlidesAndroid App Development Proposal PowerPoint Presentation Slides
Android App Development Proposal PowerPoint Presentation SlidesSlideTeam
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With JestBen McCormick
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS Ganesh Kondal
 
Android testing
Android testingAndroid testing
Android testingJinaTm
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner GuideAndri Yadi
 
Android simple calculator
Android simple calculatorAndroid simple calculator
Android simple calculatorKATHEESKUMAR S
 
Basic Guide For Mobile Application Testing
Basic Guide For Mobile Application TestingBasic Guide For Mobile Application Testing
Basic Guide For Mobile Application TestingSourabh Kasliwal
 

Tendances (20)

Android PPT Presentation 2018
Android PPT Presentation 2018Android PPT Presentation 2018
Android PPT Presentation 2018
 
Node js
Node jsNode js
Node js
 
How to go about testing in React?
How to go about testing in React? How to go about testing in React?
How to go about testing in React?
 
Apple's ios
Apple's iosApple's ios
Apple's ios
 
Cucumber presenation
Cucumber presenationCucumber presenation
Cucumber presenation
 
iOS PPT
iOS PPTiOS PPT
iOS PPT
 
Hybrid mobile app
Hybrid mobile appHybrid mobile app
Hybrid mobile app
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating System
 
Android technology _seminar_ ppt
Android technology _seminar_ pptAndroid technology _seminar_ ppt
Android technology _seminar_ ppt
 
Different wait methods or commands in Selenium
Different wait methods or commands in SeleniumDifferent wait methods or commands in Selenium
Different wait methods or commands in Selenium
 
Android App Development Proposal PowerPoint Presentation Slides
Android App Development Proposal PowerPoint Presentation SlidesAndroid App Development Proposal PowerPoint Presentation Slides
Android App Development Proposal PowerPoint Presentation Slides
 
Saving Time By Testing With Jest
Saving Time By Testing With JestSaving Time By Testing With Jest
Saving Time By Testing With Jest
 
NodeJS - Server Side JS
NodeJS - Server Side JS NodeJS - Server Side JS
NodeJS - Server Side JS
 
Android testing
Android testingAndroid testing
Android testing
 
iOS Development - A Beginner Guide
iOS Development - A Beginner GuideiOS Development - A Beginner Guide
iOS Development - A Beginner Guide
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
AID in android
AID in androidAID in android
AID in android
 
Android simple calculator
Android simple calculatorAndroid simple calculator
Android simple calculator
 
Consuming GraphQL in C#
Consuming GraphQL in C#Consuming GraphQL in C#
Consuming GraphQL in C#
 
Basic Guide For Mobile Application Testing
Basic Guide For Mobile Application TestingBasic Guide For Mobile Application Testing
Basic Guide For Mobile Application Testing
 

Similaire à What is-pmd

Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality ToolsOrest Ivasiv
 
Quality in coding (phpmd & phpcpd with Symfony 2)
Quality in coding (phpmd & phpcpd with Symfony 2)Quality in coding (phpmd & phpcpd with Symfony 2)
Quality in coding (phpmd & phpcpd with Symfony 2)Dionyshs Tsoumas
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applicationsChandra Sekhar Saripaka
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programmingJuggernaut Liu
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDKan-Han (John) Lu
 
Code smells quality of code
Code smells   quality of codeCode smells   quality of code
Code smells quality of codeHasan Al Mamun
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoringkimsrung lov
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Arnaud Bouchez
 
11. Lecture 19 Code standards and review.ppt
11. Lecture 19 Code standards and review.ppt11. Lecture 19 Code standards and review.ppt
11. Lecture 19 Code standards and review.pptMaddalaSeshu
 
Writing Good Code
Writing Good CodeWriting Good Code
Writing Good CodeLeo Liang
 
A Tool to Detect Plagiarism in Java Source Code.pdf
A Tool to Detect Plagiarism in Java Source Code.pdfA Tool to Detect Plagiarism in Java Source Code.pdf
A Tool to Detect Plagiarism in Java Source Code.pdfKayla Smith
 
Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Shirish Bari
 
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)PVS-Studio
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytechyannick grenzinger
 

Similaire à What is-pmd (20)

Java Code Quality Tools
Java Code Quality ToolsJava Code Quality Tools
Java Code Quality Tools
 
Quality in coding (phpmd & phpcpd with Symfony 2)
Quality in coding (phpmd & phpcpd with Symfony 2)Quality in coding (phpmd & phpcpd with Symfony 2)
Quality in coding (phpmd & phpcpd with Symfony 2)
 
Coding standard
Coding standardCoding standard
Coding standard
 
Best practices in enterprise applications
Best practices in enterprise applicationsBest practices in enterprise applications
Best practices in enterprise applications
 
Code Review
Code ReviewCode Review
Code Review
 
Coding conventions
Coding conventionsCoding conventions
Coding conventions
 
Reading Notes : the practice of programming
Reading Notes : the practice of programmingReading Notes : the practice of programming
Reading Notes : the practice of programming
 
Code analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMDCode analyzer: FindBugs and PMD
Code analyzer: FindBugs and PMD
 
Code smells quality of code
Code smells   quality of codeCode smells   quality of code
Code smells quality of code
 
Code Smell and Refactoring
Code Smell and RefactoringCode Smell and Refactoring
Code Smell and Refactoring
 
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)Object Pascal Clean Code Guidelines Proposal (at EKON 22)
Object Pascal Clean Code Guidelines Proposal (at EKON 22)
 
Sonar En
Sonar EnSonar En
Sonar En
 
11. Lecture 19 Code standards and review.ppt
11. Lecture 19 Code standards and review.ppt11. Lecture 19 Code standards and review.ppt
11. Lecture 19 Code standards and review.ppt
 
Quality culture
Quality cultureQuality culture
Quality culture
 
Writing Good Code
Writing Good CodeWriting Good Code
Writing Good Code
 
Coding standards
Coding standardsCoding standards
Coding standards
 
A Tool to Detect Plagiarism in Java Source Code.pdf
A Tool to Detect Plagiarism in Java Source Code.pdfA Tool to Detect Plagiarism in Java Source Code.pdf
A Tool to Detect Plagiarism in Java Source Code.pdf
 
Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)Writing Clean Code (Recommendations by Robert Martin)
Writing Clean Code (Recommendations by Robert Martin)
 
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
Interview with Dmitriy Vyukov - the author of Relacy Race Detector (RRD)
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 

Plus de 3trg

Pmd naming-rules
Pmd naming-rulesPmd naming-rules
Pmd naming-rules3trg
 
Suppressing warnings
Suppressing warningsSuppressing warnings
Suppressing warnings3trg
 
Mark violation-for-review
Mark violation-for-reviewMark violation-for-review
Mark violation-for-review3trg
 
Clearing violations
Clearing violationsClearing violations
Clearing violations3trg
 
Checking code-with-pmd
Checking code-with-pmdChecking code-with-pmd
Checking code-with-pmd3trg
 
Pmd eclipse
Pmd eclipsePmd eclipse
Pmd eclipse3trg
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types3trg
 
Java basic syntax
Java basic syntaxJava basic syntax
Java basic syntax3trg
 
What is Java
What is JavaWhat is Java
What is Java3trg
 

Plus de 3trg (9)

Pmd naming-rules
Pmd naming-rulesPmd naming-rules
Pmd naming-rules
 
Suppressing warnings
Suppressing warningsSuppressing warnings
Suppressing warnings
 
Mark violation-for-review
Mark violation-for-reviewMark violation-for-review
Mark violation-for-review
 
Clearing violations
Clearing violationsClearing violations
Clearing violations
 
Checking code-with-pmd
Checking code-with-pmdChecking code-with-pmd
Checking code-with-pmd
 
Pmd eclipse
Pmd eclipsePmd eclipse
Pmd eclipse
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types
 
Java basic syntax
Java basic syntaxJava basic syntax
Java basic syntax
 
What is Java
What is JavaWhat is Java
What is Java
 

Dernier

Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 

Dernier (20)

Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 

What is-pmd

  • 1. What is PMD ? PMD is a source code analyzer. It finds unused variables, empty catch blocks, unnecessary object creation, and so forth.
  • 2. PMD works by scanning Java code and checks for violations in three major areas: – Compliance with coding standards – Coding antipatterns – Cut and Paste Detector (CPD)
  • 3. Compliance with coding standards ● Naming conventions – class, method, parameter and variable names ● Class and method length ● Existence and formatting of comments and JavaDocs
  • 4. Coding antipatterns ● Possible bugs - Empty try/catch/finally/switch blocks ● Dead code - Unused local variables, parameters and private methods ● Empty (if/while) statements ● Suboptimal code - wasteful String/StringBuffer usage
  • 5. Coding antipatterns (2) Overcomplicated expressions – unnecessary if statements, for loops that could be while loops Duplicate code – copied/pasted code means copied/pasted bugs Classes with high Cyclomatic Complexity measurements
  • 6. Cut and Paste Detector (CPD) a tool that scans files and looks for suspect code replication. CPD can be parametrized by the minimum size of the code block.
  • 7. Stakeholders ● Developers use PMD to comply with coding standards and deliver quality code. ● Team leaders and Quality Assurance folks use it to change the nature of code reviews. ● Team members can do peer-to-peer discussion PMD has the potential to transform a mechanical and syntax check oriented code review into a to dynamic peer-to-peer discussion.
  • 8. Rules PMD comes with many predefined rules; we can add more or customize existing one. EmptyFinallyBlock – Avoid empty finally blocks - these can be deleted UnnecessaryReturn – Avoid unnecessary return statements LongVariable – Detects when a field, local variable is declared with a long name
  • 9. PMD rules has been grouped into Rule sets Rule set: Naming Rules – Rule: VariableNamingConventions – Rule: MethodNamingConventions – Rule: ClassNamingConventions – Rule: NoPackage Rule set: Unused Code Rules – Rule: UnusedPrivateField – Rule: UnusedLocalVariable