Easy Way to Improve Code Coverage

I have a bunch of unit tests that get automatically run over Poker Copilot several times a day. In theory, these help me detect when I accidentally break some feature while changing code elsewhere in the application. In practice, the unit tests are only a first line of defense – but a helpful one.

Code coverage” is a measure (as a percentage) of how much of my code is covered by these unit tests. OCD types like to have high code coverage. Lazy people struggle to reach a double digit percentage. I oscillate between the two camps. Consider me “lazy OCD”.

Typically to get the code coverage up, you write more tests. Over the last month I’ve been tidying things up in the code, in preparation for the coming release of version 2. Finding and deleting unused methods and classes reduced the lines of code in Poker Copilot by 13.6%.

So there it is: the easy way to improve code coverage is to delete unused code. Finding that unused code is a bit trickier – unless you have IntelliJ IDEA‘s wonderful, amazing, indispensable static analysis tools.