Implementing Quality in Java
Vincent Massol ● Speaker Bio ● CTO XWiki SAS ● Your Projects ● XWiki (community-driven open source project) ● Past: Maven, Apache Cargo, Apache Cactus, Pattern Testing ● Other Credentials: ● LesCastCodeurs podcast ● Creator of OSSGTP open source group in Paris ● 3 books: JUnit in Action, Maven: A Developer’s Notebook, BBWM
What is quality ?
The XWiki project
Examples of Quality actions ● Coding rules (Checkstyle, ...) ● Test coverage ● Track bugs ● Don’t use Commons Lang 2.x ● Use SLF4J and don’t draw Log4J/JCL in dependencies ● Automated build ● Automated unit tests ● Stable automated functional tests ● Ensure API stability ● Code reviews ● License header checks ● Release with Java 6 ● Ensure javadoc exist ● Prevent JAR hell ● Release often (every 2 weeks) ● Collaborative design ● Test on supported environments (DB & Browsers)
Quality Tip #1 API Stability
Using CLIRR <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>clirr-maven-pluginclirr-maven-plugin</artifactId> <configuration> <ignored> <difference> <differenceType>7006</differenceType> <className>org/xwiki/.../MetaDataBlock</className> <method>org.xwiki....block.Block clone()</method> <to>org.xwiki.rendering.block.MetaDataBlock</to> <justification>XDOM#clone() doesn't clone the meta data</justification> </difference> ...
CLIRR Report
Internal Package + AspectJ
Quality Tip #2 Test Coverage
Test Coverage Strategy ● When devs add code (and thus tests), increase the TPC percentage ● Put the Jacoco check in “Quality” Maven Profile ● Have a CI job to execute that profile regularly ● About 15% overhead compared to build without checks ● “Cheat mode”: Add easier-to-write test
Use Jacoco to fail the build <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-pluginjacoco-maven-plugin</artifactId> <executions> <execution><id>jacoco-prepare</id> <goals><goal>prepare-agentprepare-agent</goal></goals> </execution> <execution><id>jacoco-check</id> <goals><goal>checkcheck</goal></goals> </execution> </executions> <configuration> <check> <instructionRatio>${xwiki.jacoco.instructionRatio}${xwiki.jacoco.instructionRatio}</...> </check>}
Quality Tip #3 Bug Fixing Day
BFD Strategy ● Every Thursday ● Goal is to close the max number of bugs ● Triaging:Can be closed with Won’t fix, Duplicate, Cannot Reproduce, etc ● Close low hanging fruits in priority ● Started with last 365 days and currently with last 1500 days (we need to catch up with 80 bugs!)
Results
Conclusion ● Slowly add new quality check over time ● Everyone must be on board ● Favor Active Quality (i.e. make the build fail) over Passive checks ● Be ready to adapt/remove checks if found not useful enough ● Quality brings some risks: ● Potentially less committers for your project (especially open source) ● Project seen as “less fun”
Be proud of your Quality ! “I have offended God and mankind because my work didn't reach the quality it should have.” Leonardo daVinci, on his death bed
Implementing Quality on Java projects (Short version)

Implementing Quality on Java projects (Short version)