SlideShare a Scribd company logo
Follow this topic:
@rjsmelo
PHP Quality Assurance
RICARDO MELO
PHPLX Meetup - July 2014
@rjsmelo 2
RICARDO MELO
●
CTO @ DRI
●
PHP, Mysql, Linux and lots of other
OSS
●
ZCE, RHCE, LPI 3, ITIL, etc
●
+10 years building (and breaking)
things
@rjsmelo 3
About
●
14 Year old academic spin-off
●
Pragmatic OSS Orientation
●
PHP, Mysql, SugarCRM, Drupal,
JavaScript, Linux, etc.
●
Crafters, Integrators
●
Always looking for software developers
– Yes, right now!
1999 - 2014 DRI. Some Rights Reserved. 4
Outline
●
Quality Assurance
●
PHP QA Tools
– Phpcpd, phpmd, pdepend, phploc, phpcs, phpdcd, phpdox
– PHPUnit
●
Build Servers
– Jenkins
1999 - 2014 DRI. Some Rights Reserved. 5
Quality Assurance
Credits: https://www.flickr.com/photos/blondinrikard/13035892635
1999 - 2014 DRI. Some Rights Reserved. 6
phpcpd
●
phpcpd is a Copy/Paste Detector (CPD) for PHP code. It
scans a PHP project for duplicated code.
[root@localhost sut]# phpcpd wordpress/
phpcpd 2.0.1 by Sebastian Bergmann.
Found 46 exact clones with 1571 duplicated lines in 26 files:
- /vagrant/sut/wordpress/wp-admin/includes/class-ftp-pure.php:103-118
/vagrant/sut/wordpress/wp-admin/includes/class-ftp-sockets.php:123-138
- /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php:37-60
/vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php:31-54
- /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php:184-212
/vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php:190-218
- /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-direct.php:347-383
/vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php:354-390
1999 - 2014 DRI. Some Rights Reserved. 7
phpmd
●
phpmd scans PHP source code and looks for potential
problems such as possible bugs, dead code, suboptimal
code, and overcomplicated expressions
[root@localhost sut]# phpmd wp-admin text cleancode,codesize,controversial,design,naming,unusedcode
/dev/shm/workpress/wordpress/wp-admin/comment.php:40 The function comment_footer_die() contains an exit
expression.
/dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase.
/dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase.
/dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase.
/dev/shm/workpress/wordpress/wp-admin/custom-background.php:53 Avoid excessively long variable names like
$admin_header_callback. Keep variable name length under 20.
/dev/shm/workpress/wordpress/wp-admin/custom-background.php:53 Avoid excessively long variable names like
$admin_image_div_callback. Keep variable name length under 20.
/dev/shm/workpress/wordpress/wp-admin/custom-background.php:85 The method admin_load is not named in
camelCase.
/dev/shm/workpress/wordpress/wp-admin/custom-background.php:112 The method take_action() has a Cyclomatic
Complexity of 13. The configured cyclomatic complexity threshold is 10.
/dev/shm/workpress/wordpress/wp-admin/custom-background.php:112 The method take_action() has an NPath
complexity of 864. The configured NPath complexity threshold is 200.
1999 - 2014 DRI. Some Rights Reserved. 8
pdepend
●
pdepend can generate a large set of software metrics from
a given code base. These values can be used to measure
the quality of a software project and they help to identify
the parts of an application where a code refactoring should
be applied.
pdepend --summary-xml=/tmp/summary.xml --jdepend-chart=/tmp/jdepend.svg --overview-pyramid=/tmp/pyramid.svg
wp-admin
PDepend 2.0.0
Parsing source files:
............................................................ 60
............................................................ 120
......................................................... 177
Calculating Cyclomatic Complexity metrics:
............................................................ 1200
........................ 1695
Calculating Node Loc metrics:
............................................................ 1200
.................. 1579
1999 - 2014 DRI. Some Rights Reserved. 9
pdepend – output example
1999 - 2014 DRI. Some Rights Reserved. 10
pdepend – output example
1999 - 2014 DRI. Some Rights Reserved. 11
phploc
●
phploc is a tool for quickly measuring the size of a PHP
project.
[vagrant@localhost wordpress]$ phploc wp-admin/
phploc 2.0.6 by Sebastian Bergmann.
Directories 4
Files 177
Size
Lines of Code (LOC) 72137
Comment Lines of Code (CLOC) 16702 (23.15%)
Non-Comment Lines of Code (NCLOC) 55435 (76.85%)
Logical Lines of Code (LLOC) 21517 (29.83%)
Classes 6804 (31.62%)
Average Class Length 133
Average Method Length 9
Functions 8134 (37.80%)
Average Function Length 11
Not in classes or functions 6579 (30.58%)
1999 - 2014 DRI. Some Rights Reserved. 12
phpcs
●
phpcs tokenizes PHP, JavaScript and CSS files and
detects violations of a defined set of coding standards. It is
an essential development tool that ensures your code
remains clean and consistent. It can also help prevent
some common semantic errors made by developers.
$ phpcs src/
FILE: /vagrant/sut/phpunit/src/Extensions/GroupTestSuite.php
--------------------------------------------------------------------------------
FOUND 7 ERROR(S) AND 2 WARNING(S) AFFECTING 8 LINE(S)
--------------------------------------------------------------------------------
44 | WARNING | PHP version not specified
44 | ERROR | Missing @category tag in file comment
52 | ERROR | There must be exactly one blank line before the tags in class
| | comments
65 | ERROR | Missing @category tag in class comment
68 | ERROR | Missing function doc comment
74 | WARNING | Line exceeds 85 characters; contains 91 characters
79 | ERROR | Multi-line function call not indented correctly; expected 12
| | spaces but found 10
80 | ERROR | Multi-line function call not indented correctly; expected 12
| | spaces but found 10
86 | ERROR | Multi-line function call not indented correctly; expected 20
| | spaces but found 18
--------------------------------------------------------------------------------
1999 - 2014 DRI. Some Rights Reserved. 13
phpdcd
●
phpdcd is a Dead Code Detector (DCD) for PHP code. It
scans a PHP project for code that is no longer used.
$ phpdcd src/
phpdcd 1.0.2 by Sebastian Bergmann.
- PHPUnit_Extensions_GroupTestSuite::__construct()
LOC: 31, declared in /vagrant/sut/phpunit/src/Extensions/GroupTestSuite.php:68
- PHPUnit_Extensions_PhptTestCase::count()
LOC: 4, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:120
- PHPUnit_Extensions_PhptTestCase::getName()
LOC: 4, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:194
- PHPUnit_Extensions_PhptTestCase::run()
LOC: 57, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:131
1999 - 2014 DRI. Some Rights Reserved. 14
phpdox
●
phpDox is the documentation generator for PHP projects.
This includes, but is not limited to, API documentation.
[root@localhost phpunit]# phpdox
phpDox %development% - Copyright (C) 2010 - 2014 by Arne Blankerts
[23.07.2014 - 19:03:23] Using config file './phpdox.xml.dist'
[23.07.2014 - 19:03:23] Registered enricher 'build'
[23.07.2014 - 19:03:23] Registered enricher 'git'
[23.07.2014 - 19:03:23] Registered enricher 'checkstyle'
[23.07.2014 - 19:03:23] Registered enricher 'pmd'
[23.07.2014 - 19:03:23] Registered enricher 'phpunit'
[23.07.2014 - 19:03:23] Registered enricher 'phploc'
[23.07.2014 - 19:03:23] Registered output engine 'xml'
[23.07.2014 - 19:03:23] Registered output engine 'html'
[23.07.2014 - 19:03:23] Starting to process project 'PHPUnit'
[23.07.2014 - 19:03:23] Starting collector
[23.07.2014 - 19:03:23] Scanning directory 'src' for files to process
..................................................[50]
..................................................[100]
................... [119]
1999 - 2014 DRI. Some Rights Reserved. 15
PHPUnit
●
PHPUnit is the de-facto standard for unit testing in PHP
projects. It provides both a framework that makes the
writing of tests easy as well as the functionality to easily
run the tests and analyze their results.
[root@localhost phpunit]# phpunit
PHPUnit 4.3-ge243de0 by Sebastian Bergmann.
Configuration read from /vagrant/sut/phpunit/phpunit.xml.dist
............................................................. 61 / 1295 ( 4%)
............................................................. 122 / 1295 ( 9%)
............................................................. 183 / 1295 ( 14%)
............................................................. 244 / 1295 ( 18%)
............................................................. 305 / 1295 ( 23%)
............................................................. 366 / 1295 ( 28%)
1999 - 2014 DRI. Some Rights Reserved. 16
Jenkins
1999 - 2014 DRI. Some Rights Reserved. 17
Quick How-To
●
http://jenkins-php.org/
– Install plugins
– Orchestrate the tools
– Configure the tools
– Create a Job
1999 - 2014 DRI. Some Rights Reserved. 18
Jenkins Demo
●
Demo
●
Vagrant box with PHP QA tools installed available at
https://github.com/rjsmelo/vagrant-phpqa
Thank you
Follow this topic:
@rjsmelo
QA
www.dri-global.com
@rjsmelo
ricardo.melo@dri-global.com
Ad

Recommended

Docker and Running multiple versions of PHP @ CareerZoo Dublin
Docker and Running multiple versions of PHP @ CareerZoo Dublin
rjsmelo
 
Docker & PHP - Practical use case
Docker & PHP - Practical use case
rjsmelo
 
Http2 on go1.6rc2
Http2 on go1.6rc2
Jxck Jxck
 
Desarrollo web backend: Spring Boot, MongoDB y Azure
Desarrollo web backend: Spring Boot, MongoDB y Azure
Patxi Gortázar
 
HTTP2Study chronicle #http2conf
HTTP2Study chronicle #http2conf
Jxck Jxck
 
Extensible web
Extensible web
Jxck Jxck
 
Extensible web #html5j
Extensible web #html5j
Jxck Jxck
 
Debian packaging talk, Pysheff sept 2012
Debian packaging talk, Pysheff sept 2012
takluyver
 
Cache in Chromium: Disk Cache
Cache in Chromium: Disk Cache
Chang W. Doh
 
Caching in Docker - the hardest thing in computer science
Caching in Docker - the hardest thing in computer science
Jarek Potiuk
 
Workshop - Golang language
Workshop - Golang language
Vincent Composieux
 
ORTC SVC SimulCast
ORTC SVC SimulCast
Jxck Jxck
 
Migration from drupal 7 to drupal 8
Migration from drupal 7 to drupal 8
Krzysztof (Chris) Ozog
 
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
DrupalCamp Kyiv
 
Chromium: NaCl and Pepper API
Chromium: NaCl and Pepper API
Chang W. Doh
 
DevTools Package Development
DevTools Package Development
Sagar Deogirkar
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
Chang W. Doh
 
Dockerandjenkins citz2014
Dockerandjenkins citz2014
Martin Kenneth Michalsky
 
openSUSE tools on Debian
openSUSE tools on Debian
Hideki Yamane
 
about Debian "squeeze" @201002 OSC Tokyospring
about Debian "squeeze" @201002 OSC Tokyospring
Hideki Yamane
 
Statyczna analiza kodu PHP
Statyczna analiza kodu PHP
The Software House
 
Git & G
Git & G
SangJung Woo
 
Local Community for Debian (2013 Taiwan miniDebConf)
Local Community for Debian (2013 Taiwan miniDebConf)
Hideki Yamane
 
find & improve some bottleneck in Debian project (DebConf14 LT)
find & improve some bottleneck in Debian project (DebConf14 LT)
Hideki Yamane
 
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Codemotion
 
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Андрей Вандакуров
 
Hyperscale SIG Introduction
Hyperscale SIG Introduction
Davide Cavalca
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestration
Giulio De Donato
 
PHP Development Tools
PHP Development Tools
Antony Abramchenko
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
Wim Godden
 

More Related Content

What's hot (20)

Cache in Chromium: Disk Cache
Cache in Chromium: Disk Cache
Chang W. Doh
 
Caching in Docker - the hardest thing in computer science
Caching in Docker - the hardest thing in computer science
Jarek Potiuk
 
Workshop - Golang language
Workshop - Golang language
Vincent Composieux
 
ORTC SVC SimulCast
ORTC SVC SimulCast
Jxck Jxck
 
Migration from drupal 7 to drupal 8
Migration from drupal 7 to drupal 8
Krzysztof (Chris) Ozog
 
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
DrupalCamp Kyiv
 
Chromium: NaCl and Pepper API
Chromium: NaCl and Pepper API
Chang W. Doh
 
DevTools Package Development
DevTools Package Development
Sagar Deogirkar
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
Chang W. Doh
 
Dockerandjenkins citz2014
Dockerandjenkins citz2014
Martin Kenneth Michalsky
 
openSUSE tools on Debian
openSUSE tools on Debian
Hideki Yamane
 
about Debian "squeeze" @201002 OSC Tokyospring
about Debian "squeeze" @201002 OSC Tokyospring
Hideki Yamane
 
Statyczna analiza kodu PHP
Statyczna analiza kodu PHP
The Software House
 
Git & G
Git & G
SangJung Woo
 
Local Community for Debian (2013 Taiwan miniDebConf)
Local Community for Debian (2013 Taiwan miniDebConf)
Hideki Yamane
 
find & improve some bottleneck in Debian project (DebConf14 LT)
find & improve some bottleneck in Debian project (DebConf14 LT)
Hideki Yamane
 
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Codemotion
 
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Андрей Вандакуров
 
Hyperscale SIG Introduction
Hyperscale SIG Introduction
Davide Cavalca
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestration
Giulio De Donato
 
Cache in Chromium: Disk Cache
Cache in Chromium: Disk Cache
Chang W. Doh
 
Caching in Docker - the hardest thing in computer science
Caching in Docker - the hardest thing in computer science
Jarek Potiuk
 
ORTC SVC SimulCast
ORTC SVC SimulCast
Jxck Jxck
 
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
Migration from Drupal 7 to Drupal 8 - How Docker can save our lives!
DrupalCamp Kyiv
 
Chromium: NaCl and Pepper API
Chromium: NaCl and Pepper API
Chang W. Doh
 
DevTools Package Development
DevTools Package Development
Sagar Deogirkar
 
Ninja Build: Simple Guide for Beginners
Ninja Build: Simple Guide for Beginners
Chang W. Doh
 
openSUSE tools on Debian
openSUSE tools on Debian
Hideki Yamane
 
about Debian "squeeze" @201002 OSC Tokyospring
about Debian "squeeze" @201002 OSC Tokyospring
Hideki Yamane
 
Local Community for Debian (2013 Taiwan miniDebConf)
Local Community for Debian (2013 Taiwan miniDebConf)
Hideki Yamane
 
find & improve some bottleneck in Debian project (DebConf14 LT)
find & improve some bottleneck in Debian project (DebConf14 LT)
Hideki Yamane
 
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Docker and .NET Core - Best Friends Forever - Michael Newton - Codemotion Rom...
Codemotion
 
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Opensourceman ( url for slides with animations https://goo.gl/R638tW )
Андрей Вандакуров
 
Hyperscale SIG Introduction
Hyperscale SIG Introduction
Davide Cavalca
 
More developers on DevOps with Docker orchestration
More developers on DevOps with Docker orchestration
Giulio De Donato
 

Similar to PHP QA Tools (20)

PHP Development Tools
PHP Development Tools
Antony Abramchenko
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
Wim Godden
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
Learned lessons in a real world project
Learned lessons in a real world project
Codium
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themes
Otto Kekäläinen
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
OpenShift Origin
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM i
Zend by Rogue Wave Software
 
drupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_company
Ganesh Kulkarni
 
Chicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - Mediafly
Mediafly
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 
Installing php 7.4 Nginx Laravel 7.x on Centos 8
Installing php 7.4 Nginx Laravel 7.x on Centos 8
Raja Rozali Raja Hasan
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
Brian Brazil
 
Monitoring Cloud Native Applications with Prometheus
Monitoring Cloud Native Applications with Prometheus
Jacopo Nardiello
 
SHARE.ORG Orlando 2015
SHARE.ORG Orlando 2015
Filipe Miranda
 
Introduction to PaaS and Heroku
Introduction to PaaS and Heroku
Tapio Rautonen
 
Php through the eyes of a hoster
Php through the eyes of a hoster
Combell NV
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
Wong Hoi Sing Edison
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Programmable infrastructure with FlyScript
Programmable infrastructure with FlyScript
Riverbed Technology
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
Wim Godden
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Bastian Feder
 
Learned lessons in a real world project
Learned lessons in a real world project
Codium
 
Automatic testing and quality assurance for WordPress plugins and themes
Automatic testing and quality assurance for WordPress plugins and themes
Otto Kekäläinen
 
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
Extending OpenShift Origin: Build Your Own Cartridge with Bill DeCoste of Red...
OpenShift Origin
 
Building and managing applications fast for IBM i
Building and managing applications fast for IBM i
Zend by Rogue Wave Software
 
drupal ci cd concept cornel univercity.pptx
drupal ci cd concept cornel univercity.pptx
rukuntravel
 
Edp bootstrapping a-software_company
Edp bootstrapping a-software_company
Ganesh Kulkarni
 
Chicago Docker Meetup Presentation - Mediafly
Chicago Docker Meetup Presentation - Mediafly
Mediafly
 
Developing and Deploying PHP with Docker
Developing and Deploying PHP with Docker
Patrick Mizer
 
Installing php 7.4 Nginx Laravel 7.x on Centos 8
Installing php 7.4 Nginx Laravel 7.x on Centos 8
Raja Rozali Raja Hasan
 
Prometheus and Docker (Docker Galway, November 2015)
Prometheus and Docker (Docker Galway, November 2015)
Brian Brazil
 
Monitoring Cloud Native Applications with Prometheus
Monitoring Cloud Native Applications with Prometheus
Jacopo Nardiello
 
SHARE.ORG Orlando 2015
SHARE.ORG Orlando 2015
Filipe Miranda
 
Introduction to PaaS and Heroku
Introduction to PaaS and Heroku
Tapio Rautonen
 
Php through the eyes of a hoster
Php through the eyes of a hoster
Combell NV
 
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
[HKDUG] #20161210 - BarCamp Hong Kong 2016 - What's News in PHP?
Wong Hoi Sing Edison
 
Lean Drupal Repositories with Composer and Drush
Lean Drupal Repositories with Composer and Drush
Pantheon
 
Programmable infrastructure with FlyScript
Programmable infrastructure with FlyScript
Riverbed Technology
 
Ad

More from rjsmelo (6)

PHPUnit your bug exterminator
PHPUnit your bug exterminator
rjsmelo
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmers
rjsmelo
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
rjsmelo
 
A Certificação LPI
A Certificação LPI
rjsmelo
 
PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013
rjsmelo
 
PHP e a (in)segurança de aplicações
PHP e a (in)segurança de aplicações
rjsmelo
 
PHPUnit your bug exterminator
PHPUnit your bug exterminator
rjsmelo
 
OWASP TOP 10 for PHP Programmers
OWASP TOP 10 for PHP Programmers
rjsmelo
 
Redis & ZeroMQ: How to scale your application
Redis & ZeroMQ: How to scale your application
rjsmelo
 
A Certificação LPI
A Certificação LPI
rjsmelo
 
PHP and Application Security - OWASP Road Show 2013
PHP and Application Security - OWASP Road Show 2013
rjsmelo
 
PHP e a (in)segurança de aplicações
PHP e a (in)segurança de aplicações
rjsmelo
 
Ad

Recently uploaded (20)

FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Crypto Super 500 - 14th Report - June2025.pdf
Crypto Super 500 - 14th Report - June2025.pdf
Stephen Perrenod
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
 
Down the Rabbit Hole – Solving 5 Training Roadblocks
Down the Rabbit Hole – Solving 5 Training Roadblocks
Rustici Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
AudGram Review: Build Visually Appealing, AI-Enhanced Audiograms to Engage Yo...
SOFTTECHHUB
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Securing Account Lifecycles in the Age of Deepfakes.pptx
Securing Account Lifecycles in the Age of Deepfakes.pptx
FIDO Alliance
 
Data Validation and System Interoperability
Data Validation and System Interoperability
Safe Software
 
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
SAP Modernization Strategies for a Successful S/4HANA Journey.pdf
Precisely
 

PHP QA Tools

  • 1. Follow this topic: @rjsmelo PHP Quality Assurance RICARDO MELO PHPLX Meetup - July 2014
  • 2. @rjsmelo 2 RICARDO MELO ● CTO @ DRI ● PHP, Mysql, Linux and lots of other OSS ● ZCE, RHCE, LPI 3, ITIL, etc ● +10 years building (and breaking) things
  • 3. @rjsmelo 3 About ● 14 Year old academic spin-off ● Pragmatic OSS Orientation ● PHP, Mysql, SugarCRM, Drupal, JavaScript, Linux, etc. ● Crafters, Integrators ● Always looking for software developers – Yes, right now!
  • 4. 1999 - 2014 DRI. Some Rights Reserved. 4 Outline ● Quality Assurance ● PHP QA Tools – Phpcpd, phpmd, pdepend, phploc, phpcs, phpdcd, phpdox – PHPUnit ● Build Servers – Jenkins
  • 5. 1999 - 2014 DRI. Some Rights Reserved. 5 Quality Assurance Credits: https://www.flickr.com/photos/blondinrikard/13035892635
  • 6. 1999 - 2014 DRI. Some Rights Reserved. 6 phpcpd ● phpcpd is a Copy/Paste Detector (CPD) for PHP code. It scans a PHP project for duplicated code. [root@localhost sut]# phpcpd wordpress/ phpcpd 2.0.1 by Sebastian Bergmann. Found 46 exact clones with 1571 duplicated lines in 26 files: - /vagrant/sut/wordpress/wp-admin/includes/class-ftp-pure.php:103-118 /vagrant/sut/wordpress/wp-admin/includes/class-ftp-sockets.php:123-138 - /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php:37-60 /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php:31-54 - /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpext.php:184-212 /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php:190-218 - /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-direct.php:347-383 /vagrant/sut/wordpress/wp-admin/includes/class-wp-filesystem-ssh2.php:354-390
  • 7. 1999 - 2014 DRI. Some Rights Reserved. 7 phpmd ● phpmd scans PHP source code and looks for potential problems such as possible bugs, dead code, suboptimal code, and overcomplicated expressions [root@localhost sut]# phpmd wp-admin text cleancode,codesize,controversial,design,naming,unusedcode /dev/shm/workpress/wordpress/wp-admin/comment.php:40 The function comment_footer_die() contains an exit expression. /dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase. /dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase. /dev/shm/workpress/wordpress/wp-admin/credits.php:23 The variable $wp_version is not named in camelCase. /dev/shm/workpress/wordpress/wp-admin/custom-background.php:53 Avoid excessively long variable names like $admin_header_callback. Keep variable name length under 20. /dev/shm/workpress/wordpress/wp-admin/custom-background.php:53 Avoid excessively long variable names like $admin_image_div_callback. Keep variable name length under 20. /dev/shm/workpress/wordpress/wp-admin/custom-background.php:85 The method admin_load is not named in camelCase. /dev/shm/workpress/wordpress/wp-admin/custom-background.php:112 The method take_action() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. /dev/shm/workpress/wordpress/wp-admin/custom-background.php:112 The method take_action() has an NPath complexity of 864. The configured NPath complexity threshold is 200.
  • 8. 1999 - 2014 DRI. Some Rights Reserved. 8 pdepend ● pdepend can generate a large set of software metrics from a given code base. These values can be used to measure the quality of a software project and they help to identify the parts of an application where a code refactoring should be applied. pdepend --summary-xml=/tmp/summary.xml --jdepend-chart=/tmp/jdepend.svg --overview-pyramid=/tmp/pyramid.svg wp-admin PDepend 2.0.0 Parsing source files: ............................................................ 60 ............................................................ 120 ......................................................... 177 Calculating Cyclomatic Complexity metrics: ............................................................ 1200 ........................ 1695 Calculating Node Loc metrics: ............................................................ 1200 .................. 1579
  • 9. 1999 - 2014 DRI. Some Rights Reserved. 9 pdepend – output example
  • 10. 1999 - 2014 DRI. Some Rights Reserved. 10 pdepend – output example
  • 11. 1999 - 2014 DRI. Some Rights Reserved. 11 phploc ● phploc is a tool for quickly measuring the size of a PHP project. [vagrant@localhost wordpress]$ phploc wp-admin/ phploc 2.0.6 by Sebastian Bergmann. Directories 4 Files 177 Size Lines of Code (LOC) 72137 Comment Lines of Code (CLOC) 16702 (23.15%) Non-Comment Lines of Code (NCLOC) 55435 (76.85%) Logical Lines of Code (LLOC) 21517 (29.83%) Classes 6804 (31.62%) Average Class Length 133 Average Method Length 9 Functions 8134 (37.80%) Average Function Length 11 Not in classes or functions 6579 (30.58%)
  • 12. 1999 - 2014 DRI. Some Rights Reserved. 12 phpcs ● phpcs tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards. It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers. $ phpcs src/ FILE: /vagrant/sut/phpunit/src/Extensions/GroupTestSuite.php -------------------------------------------------------------------------------- FOUND 7 ERROR(S) AND 2 WARNING(S) AFFECTING 8 LINE(S) -------------------------------------------------------------------------------- 44 | WARNING | PHP version not specified 44 | ERROR | Missing @category tag in file comment 52 | ERROR | There must be exactly one blank line before the tags in class | | comments 65 | ERROR | Missing @category tag in class comment 68 | ERROR | Missing function doc comment 74 | WARNING | Line exceeds 85 characters; contains 91 characters 79 | ERROR | Multi-line function call not indented correctly; expected 12 | | spaces but found 10 80 | ERROR | Multi-line function call not indented correctly; expected 12 | | spaces but found 10 86 | ERROR | Multi-line function call not indented correctly; expected 20 | | spaces but found 18 --------------------------------------------------------------------------------
  • 13. 1999 - 2014 DRI. Some Rights Reserved. 13 phpdcd ● phpdcd is a Dead Code Detector (DCD) for PHP code. It scans a PHP project for code that is no longer used. $ phpdcd src/ phpdcd 1.0.2 by Sebastian Bergmann. - PHPUnit_Extensions_GroupTestSuite::__construct() LOC: 31, declared in /vagrant/sut/phpunit/src/Extensions/GroupTestSuite.php:68 - PHPUnit_Extensions_PhptTestCase::count() LOC: 4, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:120 - PHPUnit_Extensions_PhptTestCase::getName() LOC: 4, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:194 - PHPUnit_Extensions_PhptTestCase::run() LOC: 57, declared in /vagrant/sut/phpunit/src/Extensions/PhptTestCase.php:131
  • 14. 1999 - 2014 DRI. Some Rights Reserved. 14 phpdox ● phpDox is the documentation generator for PHP projects. This includes, but is not limited to, API documentation. [root@localhost phpunit]# phpdox phpDox %development% - Copyright (C) 2010 - 2014 by Arne Blankerts [23.07.2014 - 19:03:23] Using config file './phpdox.xml.dist' [23.07.2014 - 19:03:23] Registered enricher 'build' [23.07.2014 - 19:03:23] Registered enricher 'git' [23.07.2014 - 19:03:23] Registered enricher 'checkstyle' [23.07.2014 - 19:03:23] Registered enricher 'pmd' [23.07.2014 - 19:03:23] Registered enricher 'phpunit' [23.07.2014 - 19:03:23] Registered enricher 'phploc' [23.07.2014 - 19:03:23] Registered output engine 'xml' [23.07.2014 - 19:03:23] Registered output engine 'html' [23.07.2014 - 19:03:23] Starting to process project 'PHPUnit' [23.07.2014 - 19:03:23] Starting collector [23.07.2014 - 19:03:23] Scanning directory 'src' for files to process ..................................................[50] ..................................................[100] ................... [119]
  • 15. 1999 - 2014 DRI. Some Rights Reserved. 15 PHPUnit ● PHPUnit is the de-facto standard for unit testing in PHP projects. It provides both a framework that makes the writing of tests easy as well as the functionality to easily run the tests and analyze their results. [root@localhost phpunit]# phpunit PHPUnit 4.3-ge243de0 by Sebastian Bergmann. Configuration read from /vagrant/sut/phpunit/phpunit.xml.dist ............................................................. 61 / 1295 ( 4%) ............................................................. 122 / 1295 ( 9%) ............................................................. 183 / 1295 ( 14%) ............................................................. 244 / 1295 ( 18%) ............................................................. 305 / 1295 ( 23%) ............................................................. 366 / 1295 ( 28%)
  • 16. 1999 - 2014 DRI. Some Rights Reserved. 16 Jenkins
  • 17. 1999 - 2014 DRI. Some Rights Reserved. 17 Quick How-To ● http://jenkins-php.org/ – Install plugins – Orchestrate the tools – Configure the tools – Create a Job
  • 18. 1999 - 2014 DRI. Some Rights Reserved. 18 Jenkins Demo ● Demo ● Vagrant box with PHP QA tools installed available at https://github.com/rjsmelo/vagrant-phpqa