The reason a bonus for lines of code produces long code
Measure what you want and you will get exactly that — the metric, not the quality the metric was supposed to represent.
Reward defines the output. The metric does not fail because people cheat; it fails because people succeed at optimising exactly what was measured.