Skip to content

Conversation

@HarshMehta112
Copy link

@HarshMehta112 HarshMehta112 commented Nov 21, 2025

Fixed : #10

Overview

This project enforces consistent code formatting using Spotless with Google Java Format. All Java code must adhere to the Google Java Style Guide to maintain code quality and consistency across contributions.

Automated Formatting Checks

CI/CD Enforcement

Every pull request automatically runs a formatting check in the CI pipeline. Pull requests will fail if code is not properly formatted.

The CI workflow includes:

./mvnw spotless:check

This ensures that all merged code follows the established formatting standards.

Local Development

Check Formatting

To check if your code is properly formatted:

cd apigateway
./mvnw spotless:check

On Windows:

cd apigateway
.\mvnw.cmd spotless:check

Apply Formatting

To automatically format all Java files:

cd apigateway
./mvnw spotless:apply

On Windows:

cd apigateway
.\mvnw.cmd spotless:apply

Pre-commit Best Practice

Always run mvnw spotless:apply before committing your changes to avoid CI failures.

What Gets Formatted

The Spotless configuration formats:

  • ✅ All Java source files (src/main/java/**/*.java)
  • ✅ All Java test files (src/test/java/**/*.java)

Formatting Rules Applied

  1. Google Java Format - Standard Google style formatting
  2. Import Organization - Imports ordered as: java, javax, org, com, vaultweb
  3. Unused Import Removal - Automatically removes unused imports
  4. Trailing Whitespace - Removes trailing whitespace from lines
  5. End with Newline - Ensures files end with a newline character

Signed-off-by: Harsh Mehta <harshmehta010102@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Automated Java Code Formatting Check to Backend Workflow

1 participant