Skip to content

[#26] Enforce formatting - #51

Open
MohammedNaser28 wants to merge 1 commit into
mnemosyne-systems:mainfrom
MohammedNaser28:feat/26-enforce-formatting
Open

MohammedNaser28 wants to merge 1 commit into
mnemosyne-systems:mainfrom
MohammedNaser28:feat/26-enforce-formatting

Conversation

@MohammedNaser28

@MohammedNaser28 MohammedNaser28 commented Nov 13, 2026 •

Copy link
Copy Markdown

Close #26

This PR adds make format, make format-check and make checkstyle, and runs them in CI.
CI checks formatting of all files, and the existing code is formatted in this PR.

  • Java: Spotless with google-java-format (2-space). Frontend: Prettier defaults.
  • CI runs the format and Checkstyle checks before the tests, and make test runs them too.
  • Line endings are LF, enforced with .gitattributes.
  • Prettier covers the whole src/frontend folder, so index.html and the config files are formatted too.

Checkstyle enforces unused/redundant imports, tabs and OneStatementPerLine;
NeedBraces and AvoidStarImport would fail on many places in existing code, so they are not enabled yet.

Other open PRs need to rebase and run make format after this is merged.

@MohammedNaser28

Copy link
Copy Markdown
Author

@jesperpedersen
The existing code is not reformatted here. The changes about 11,000 lines ( Java files and frontend files).

if this config and rules accepted i can do it as a separate commit in this PR, or a separate PR?
Once it's done, the "changed files only" mode can be removed so CI checks everything.

@MohammedNaser28
MohammedNaser28 force-pushed the feat/26-enforce-formatting branch from a10b283 to 793a642 Compare November 13, 2026 14:01
@jesperpedersen

Copy link
Copy Markdown
Contributor

@MohammedNaser28 Do the formatting as well

@sksingh2005

Copy link
Copy Markdown
Collaborator

@MohammedNaser28 Sorry rebase is needed now

@MohammedNaser28

Copy link
Copy Markdown
Author

@sksingh2005 no problem i will rebase

@MohammedNaser28
MohammedNaser28 force-pushed the feat/26-enforce-formatting branch from 6f75412 to 3135444 Compare November 13, 2026 20:59
@MohammedNaser28

Copy link
Copy Markdown
Author

@sksingh2005 Done

@sksingh2005 sksingh2005 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this! The tooling does what #26 asked for: both the backend and frontend are formatted, Java uses google-java-format with 2-space indents, and the checks run in CI.

What I verified on the branch:

  • CI is green (test and frontend-check).
  • mvn spotless:check checkstyle:check test-compile passes locally.
  • Frontend lint has 0 errors and the vitest tests pass (4/4).
  • Checkstyle blocks bad code: I added an unused import and the build failed with UnusedImports.
  • The reformat changes only layout. In the Java files, only whitespace and Javadoc wrapping changed, imports are unchanged, and no string literals were split.

There are some things to address before merging.

Required changes

  1. The description and comments don't match the config.
    The PR body says CI checks "changed files only (ratchet against main)", and the Makefile comment says "Reformats Java changed files". There is no ratchetFrom in the Spotless config, so it checks all files. That's correct, since the whole codebase was reformatted, but please update the PR description, the Makefile comments, CONTRIBUTING.md and docs/BUILDING.md to say that.

  2. The Checkstyle rules don't match the description.
    The PR body says OneStatementPerLine is not enabled, but checkstyle.xml enables it. The XML comment lists only NeedBraces and AvoidStarImport as deferred. Please make both agree with what is actually configured.

Suggested changes

  1. Line endings on Windows. With core.autocrlf=true, npm run format:check reports 226 files, all because of CRLF line endings. Please add "endOfLine": "auto" to .prettierrc.json, or add * text=auto eol=lf to .gitattributes.

  2. Fail fast in CI. In ci.yml, move the spotless:check and checkstyle:check steps before mvn test, so formatting failures show up without waiting for the full test run.

  3. Hook the checks into the normal flow. mvn verify and make test don't run the formatting checks right now. Please bind spotless:check and checkstyle:check to the verify phase, or call format-check from make test.

  4. Prettier coverage. The globs only match src/**, so index.html, eslint.config.js, vite.config.js and vitest.config.js are not checked, and index.html already fails Prettier. Please widen the globs, or say in the docs that these files are excluded on purpose.

  5. Small fix: remove the trailing whitespace in the step name "Check formatting " in both ci.yml and lint.yml.

Follow-up (not blocking)

  • Please open an issue to enable NeedBraces and AvoidStarImport once the existing violations are fixed.
  • This PR touches almost every source file, so other open PRs will need to rebase and run make format after it's merged.

Thanks again, nice work overall!

@jesperpedersen

Copy link
Copy Markdown
Contributor

We are using Unix line endings

Add make format, format-check and checkstyle targets (Spotless with
google-java-format, Prettier, Checkstyle) and run them in CI. Format
the existing code. Add my name to the acknowledgement file.
@MohammedNaser28

Copy link
Copy Markdown
Author

@sksingh2005 @jesperpedersen
Done all Required Changes , I will open a new issue for NeedBraces and AvoidStarImport

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Add a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enforce formatting

3 participants