code formatting

32 views
Skip to first unread message

Toby Dickenson

unread,
Nov 14, 2025, 5:04:19 AMNov 14
to ope...@googlegroups.com
Hi all,

Having consistent formatting for our java code is helpful. But I find it difficult to maintain consistency when I also contribute to other projects with different formatting styles. Is this something we can automate?

I like gnu indent for formatting C, but I am not sure what is common in the java world.

Toby

Jan

unread,
Nov 14, 2025, 3:13:40 PMNov 14
to ope...@googlegroups.com
Hi Toby!
There is a formatter in Eclipse that can be used to reformat the code.
The Wiki says that OpenPnP code shall follow Google Java Style
(https://github.com/openpnp/openpnp/wiki/Developers-Guide#coding-style)
and it provides a definition for the Eclipse formatter. It also says,
that old code might not follow the style but new code has to. So at
least the rules how to format are clear but can not be enforced...

Jan
> --
> You received this message because you are subscribed to the Google
> Groups "OpenPnP" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to openpnp+u...@googlegroups.com
> <mailto:openpnp+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/openpnp/
> CAH35urdTQQ-wrZrHZpDY9ToCpboCdjZLXMODT-nFA1Sgvr0RrA%40mail.gmail.com
> <https://groups.google.com/d/msgid/openpnp/CAH35urdTQQ-
> wrZrHZpDY9ToCpboCdjZLXMODT-nFA1Sgvr0RrA%40mail.gmail.com?
> utm_medium=email&utm_source=footer>.

Arthur Wolf

unread,
Nov 14, 2025, 4:40:48 PMNov 14
to ope...@googlegroups.com
Prettier is the standard "command line" tool for this that you could use to enforce a certain style across a codebase, or just on the files you touch.
OpenPNP follows this style: https://google.github.io/styleguide/javaguide.html and you can adapt a prettier config to follow that, this would be a good start I think:

{
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false,
  "semi": true,
  "singleQuote": true,
  "trailingComma": "none",
  "bracketSpacing": true,
  "arrowParens": "always"
}

Note most modern code editors (if you use eclipse you probably want to just use the config OpenPNP provides at https://github.com/openpnp/openpnp/wiki/Developers-Guide#coding-style but for others), there are extensions that let you integrate prettier pretty easily.


--
You received this message because you are subscribed to the Google Groups "OpenPnP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openpnp+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/openpnp/CAH35urdTQQ-wrZrHZpDY9ToCpboCdjZLXMODT-nFA1Sgvr0RrA%40mail.gmail.com.


--
勇気とユーモア
Reply all
Reply to author
Forward
0 new messages