SlideShare a Scribd company logo
2
Most read
3
Most read
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

More Related Content

What's hot (11)

PDF
Puppeteer can automate that! - Frontmania
Önder Ceylan
 
PPTX
LA INFORMÁTICA JURÍDICA Y EL DERECHO
isaiaschambilla
 
PPTX
Basic HTML
coachhahn
 
PDF
Basic Html Notes
NextGenr
 
PPT
Design-Principles.ppt
nazimsattar
 
DOCX
Descripción de casos de normatividad aplicables al usuario en la legislación ...
Roseck
 
PPTX
Http
NITT, KAMK
 
PPTX
Ley de delitos informaticos
catalinocordero
 
PPTX
Informatica juridica metadocumental y metadecisional
Alexandra Flores
 
PDF
Web engineering notes unit 2
inshu1890
 
Puppeteer can automate that! - Frontmania
Önder Ceylan
 
LA INFORMÁTICA JURÍDICA Y EL DERECHO
isaiaschambilla
 
Basic HTML
coachhahn
 
Basic Html Notes
NextGenr
 
Design-Principles.ppt
nazimsattar
 
Descripción de casos de normatividad aplicables al usuario en la legislación ...
Roseck
 
Ley de delitos informaticos
catalinocordero
 
Informatica juridica metadocumental y metadecisional
Alexandra Flores
 
Web engineering notes unit 2
inshu1890
 

Similar to What is-pmd (6)

PDF
Checking code-with-pmd
3trg
 
PDF
Code analyzer: FindBugs and PMD
Kan-Han (John) Lu
 
PPT
Code quality tools
Lena Petsenchuk
 
PDF
Code quality tools for dev
Deepu S Nath
 
PPTX
Salesforce static code analysis
Prasanna Deshpande ☁
 
PPSX
Coding standard
FAROOK Samath
 
Checking code-with-pmd
3trg
 
Code analyzer: FindBugs and PMD
Kan-Han (John) Lu
 
Code quality tools
Lena Petsenchuk
 
Code quality tools for dev
Deepu S Nath
 
Salesforce static code analysis
Prasanna Deshpande ☁
 
Coding standard
FAROOK Samath
 
Ad

More from 3trg (8)

PDF
Pmd naming-rules
3trg
 
PDF
Suppressing warnings
3trg
 
PDF
Mark violation-for-review
3trg
 
PDF
Clearing violations
3trg
 
PDF
Pmd eclipse
3trg
 
PDF
Java basic data types
3trg
 
PDF
Java basic syntax
3trg
 
PDF
What is Java
3trg
 
Pmd naming-rules
3trg
 
Suppressing warnings
3trg
 
Mark violation-for-review
3trg
 
Clearing violations
3trg
 
Pmd eclipse
3trg
 
Java basic data types
3trg
 
Java basic syntax
3trg
 
What is Java
3trg
 
Ad

Recently uploaded (20)

PDF
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
PDF
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
PDF
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
Simplify React app login with asgardeo-sdk
vaibhav289687
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PPTX
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PDF
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
Dipole Tech Innovations – Global IT Solutions for Business Growth
dipoletechi3
 
Empower Your Tech Vision- Why Businesses Prefer to Hire Remote Developers fro...
logixshapers59
 
Latest Capcut Pro 5.9.0 Crack Version For PC {Fully 2025
utfefguu
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
Simplify React app login with asgardeo-sdk
vaibhav289687
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
UI5con_2025_Accessibility_Ever_Evolving_
gerganakremenska1
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
AI + DevOps = Smart Automation with devseccops.ai.pdf
Devseccops.ai
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Transforming Insights: How Generative AI is Revolutionizing Data Analytics
LetsAI Solutions
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 

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