Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Description

Enforces Google Java Style formatting via Spotify's fmt-maven-plugin using optional git hooks and comprehensive documentation for both human and AI contributors.

Changes

Git Hook Infrastructure

  • .githooks/pre-commit - Automatically runs fmt-maven-plugin before commits, staging formatted files
  • install-git-hooks.sh - One-command setup script that configures git to use custom hooks directory

Documentation

  • CONTRIBUTING.md - Added "Automated Formatting" section with installation and manual formatting instructions; updated PR checklist
  • .github/copilot-instructions.md - Added "Code Formatting" section to inform Copilot of formatting requirements
  • .githooks/README.md - Documents hook behavior and usage

Usage

Install hook (recommended):

./install-git-hooks.sh

Manual formatting:

./mvnw com.spotify.fmt:fmt-maven-plugin:format

Disable hook:

git config --unset core.hooksPath

Checklist:

  • Public methods are documented
  • Public methods are tested
  • New and existing tests pass when run locally
  • There are no new warnings or errors

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.3/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/xapi-java/.codeql-scratch/dbs/java/working/files-to-index10508208780964532575.list --sourceArchiveDir=/home/REDACTED/work/xapi-java/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/xapi-java/.codeql-scratch/dbs/java/trap/java (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Chore]: Integrate code formatting step with post-commit hook or Copilot guidance</issue_title>
<issue_description>### What

Integrate the automatic running of the Spotify Maven formatter plugin using either a Git post-commit (or pre-commit) hook, or by documenting the formatting requirement in the Copilot/CONTRIBUTING.md instructions. Options:

  • Script a post-commit (or pre-commit) hook to run:
    ./mvnw com.spotify.fmt:fmt-maven-plugin:format
  • Optionally, add a script for easier hook installation for contributors
  • Alternatively or additionally, update documentation and Copilot instructions so all contributors (and Copilot) are aware of the required formatting step.

Goal: Enforce consistent Java code formatting (Google Java Style Guide) across contributions.

Why

Maintains code quality and consistency, reduces formatting noise in pull requests, and ensures both Copilot and human contributors are aligned with project code style. Prevents format-related reviews and errors.

Notes

See project guidance for CheckStyle and Google Java Style enforcement. If possible, provide a simple install script for the hook. Consider pros/cons of hook vs. documentation, or using both approaches.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Nov 24, 2025
Co-authored-by: thomasturrell <1552612+thomasturrell@users.noreply.github.com>
Copilot AI changed the title [WIP] Integrate Spotify Maven formatter plugin with Git hooks Integrate automatic code formatting with git hooks and documentation Nov 24, 2025
Copilot AI requested a review from thomasturrell November 24, 2025 12:22
@thomasturrell thomasturrell marked this pull request as ready for review November 24, 2025 12:34
Copilot AI review requested due to automatic review settings November 24, 2025 12:34
Copilot AI requested a review from thomasturrell November 24, 2025 12:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enforces Google Java Style formatting using Spotify's fmt-maven-plugin with optional git hooks and documentation. The changes primarily apply automated formatting to existing test and source files to ensure code consistency.

  • Reformats test files to follow Google Java Style guidelines (indentation, line breaks, spacing)
  • Reformats source files including validators, model classes, and validation constraints
  • Updates Javadoc comments to use more concise formatting

Reviewed changes

Copilot reviewed 191 out of 192 changed files in this pull request and generated 11 comments.

File Description
Test files (VariantValidatorForUuidTests.java, StatementsValidatorTest.java, etc.) Applied automated formatting to test methods, builder patterns, and assertions
Validator source files (StatementVerbValidator.java, ActorValidator.java, etc.) Reformatted code structure and Javadoc comments
Model source files (SubStatement.java, StatementResult.java, etc.) Reformatted Javadoc and code structure
Validation constraint files (Variant.java, ValidActor.java, etc.) Simplified Javadoc formatting

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

@thomasturrell thomasturrell merged commit e4473c3 into main Nov 24, 2025
13 of 14 checks passed
@thomasturrell thomasturrell deleted the copilot/integrate-code-formatting-plugin branch November 24, 2025 14:31
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.

[Chore]: Integrate code formatting step with post-commit hook or Copilot guidance

2 participants