Code Formatting
Code Formatting
JADX enforces code style using two Gradle-integrated tools: Spotless (formatting) and Checkstyle (style rule checks). Both tools use config files that can be imported into IDEs.
Prerequisite: Gradle wrapper (./gradlew) must be available in the repository root.
Tools
Spotless
- Purpose: Reformats all source code using Eclipse formatter; fails the build if any diff exists after reformatting.
- Formatter config location:
config/code-formatter/ - IDE integration:
- Eclipse: Import config files directly.
- IntelliJ IDEA: Use the Eclipse Code Formatter plugin.
Apply formatting manually:
1./gradlew spotlessApply
Checkstyle
- Purpose: Checks code style issues not covered by formatting — unused imports, naming conventions, etc.
- Config location:
config/checkstyle/ - IDE integration: Most IDEs have Checkstyle plugins that run checks in real time.
Running All Checks
Run formatting + style checks without executing tests:
1./gradlew spotlessApply
2./gradlew check -x test
Checks also run automatically during a full build:
1./gradlew build
Recommended Pre-commit Workflow
1./gradlew spotlessApply # Auto-fix formatting
2./gradlew check -x test # Verify all style checks pass
3# Repeat until check -x test exits with no errors