improving code quality using ci
TRANSCRIPT
Slide 1
Improving code quality with Continuous Integration
Martin de Keijzer
13/07/2010 PHPBenelux user group meeting
About me
Software Engineer at Ibuildings
PHP developer for 6 years
PHPBenelux
Contents of this talk
What is CI
Benefits
CruiseControl & PHPUnderControl
The tools underneath
Preparing a project
Adding your project
Questions
What is CI?
A quick introduction
What is Continuous Integration
Methodology
QA automation
Continuous code checking
An electronic guide
Benefits
How can YOU benefit?
Benefits
No more forgetting
Human errors get minimized
Run all QA processes from 1 single process
Reporting features for each run
Better overall code quality
CruiseControl & phpUnderControl
A very common couple
Cruise Control
Java based CI server
The core for phpUnderControl
Has it's own webserver
Extensible for multiple languages
PHPUnderControl
A frontend for CruiseControl
Adjusted to the needs of a PHP developer
Easy interface
PHPUnderControl
PHPUnderControl
The tools underneath
This will sound familiar
Tools
Disclaimer: There are alternatives, it's the output format of each individual tool that counts.
Source: http://www.flickr.com/photos/sebastian_bergmann/3356003644/
Disclaimer: There are alternatives, it's the output format of each individual tool that counts.
Tools
Most tools can be obtained through PEAR
http://pear.php.net/manual/en/installation.getting.php
Tools: Version control
CVS / SVN / Git etc..
Basis for detecting changes
Keeps track of changes
Keeps track of who did the changes
Tools: Documentation
phpDocumentor
A standard for in-code documentation
Human readable documentation
Gives a quick understanding of code or API's
PHPUnderControl
Tools: Code sniffer
PEAR package PHPCodeSniffer
Checks coding standards and assigns warnings and errors
Internal standards
Readability
PHPUnderControl
Tools: PHP Mess Detector
Code size (long methods or classes)
Short method or function names
Cyclometic complexity
Rulesets at phpmd.org
Protects against writing complex code
PHPUnderControl
Tools: PHP Copy Paste detection
Detects copied and pasted code
Reduces the chance of duplicate code errors
Tools: PHPUnit
Used for automated testing
Checks if your assumption is still correct even after changing the code
Extensible (e.g. test usages you didn't assume)
PHPUnderControl
PHPUnderControl
PHPUnderControl
Preparing a project
Getting ready to go
Preparing a project
Single XML file based on Apache Ant
Directories for generated artifacts
Each job is a target
One 'build' target to combine the jobs for a single build
Preparing a project