Php Blame Code Coverage (PhpBCC)
A tool that consumes a code coverage report and uses the version control history to report metrics on uncovered code by author.
What is this and how can I benefit?
- Testing Advocate - Encourages developers to NOT introduce uncovered code
- Coverage Bar Setter - Implicitly increases the overall code coverage over development time once introduced since developers are encouraged to not introduce uncovered code.
- Visibility - Provides visibility to authors. Once run, the author is alerted if some of their code is not fully covered.
- Accountability - Assigns uncovered code to authors to fix. Tasks/user stories/tickets are always assigned to someone to someone in part for visibility and also to make sure it gets done. This is the point of contact.
- Boy Scout Rule - Authors are encouraged and have full sight of code that can be cleaned up. Leave the code cleaner than you found it.
What this is NOT?
- Performance Metric Indicator - This assigns developers to be accountable for their’s and others’ code but cannot be used to show their performance. Typically, performance metrics assess both positive and negative attributes; this only reports on code that needs to be covered. Use the codebase’s code coverage improvement to report on the team’s quality rather than the individual.
- 100% Accurate
- Edited or removed test cases may show an author that introduced uncovered lines or methods, which is not necessarily true.
- Merge conflict resolutions
- Git history is editable
- There’s likely more..
- Blame Bus - Keep that blameless mentality, just assign tasks so they get done at some point and help your team want to grow.
Installation -
Global installation:
composer global require phpbcc/phpbcc
Local/project installation:
composer require-dev phpbcc/phpbcc
or manually add it to the require-dev section of your composer file.
{
"require-dev" : {
"phpbcc/phpbcc": "*"
}
}
Usage
> phpbcc --output-format=author reports/clover.xml
Sample Output
phpbcc version 1.0.0 by Chris Halbert
PHP BLAME CODE COVERAGE UNCOVERED OBJECTS (#/total) %
Chris Halbert (8/8) 100%
FileNotFoundException.php:15, 16, 17, 18 (4/8) 50%
AbstractInput.php:39, 76, 78 (3/8) 37.5%
AuthorOutput.php:157 (1/8) 12.5%
Rollout
- Ask your manager/lead if it can be tested.
- Check your code coverage.
- Add it to your build process.
- Check code coverage after your ‘testing period.’
- If it works, keep, if not, trash. Regardless, let me know what you think.
Feature Requests/Bugs
Submit feature requests or bugs at PhpBCC Issues.
Some ideas on new features: SVN/CVS/Mercurial support, a report other than Clover, different output type.
Contributing
- Build off of the interfaces established
- Ensure code coverage!
- Make sure the build passes
- Submit to PhpBCC Pull Requests
Feedback
Let me know the successes or hardships you may experience.