Adevinta Germany Marc Prengemann Dec 5, 2016

Checkstyle on Changed Files with Gradle

M2 Related OWASP risk: Inadequate Supply Chain Security Learn more →

Article Summary

Marc Prengemann from mobile.de faced 30,000+ Checkstyle violations in their Android codebase. Instead of grinding to a halt, his team found a smarter way forward.

The mobile.de Android team integrated Checkstyle into their PR review process but discovered their legacy codebase had tens of thousands of existing violations. Rather than attempting a massive cleanup, they built a custom Gradle task to check only modified files in pull requests, enabling incremental improvement without blocking development.

Key Takeaways

Critical Insight

A custom Gradle task that runs Checkstyle only on PR changes lets teams enforce coding standards on new code while tackling legacy violations incrementally.

The article includes the full Gradle implementation with Git integration that you can drop into your own Android project today.

About This Article

Problem

Mobile.de's Android team found that Checkstyle flagged over 30,000 code quality issues in their legacy codebase. Fixing all of them in a single development cycle wasn't realistic.

Solution

Marc Prengemann's team built a custom Gradle task called checkstyleChanged. It uses Git diff commands and GitHub PR builder environment variables to run Checkstyle only on files that were actually modified between branches.

Impact

This incremental approach let the team enforce coding standards on new pull requests while slowly tackling the older violations. Development workflows stayed unblocked and they avoided the need for massive refactoring efforts.