openpreserve / jhove

File validation and characterisation.
http://jhove.openpreservation.org
Other
168 stars 79 forks source link

Standardize source code formatting #516

Open tledoux opened 4 years ago

tledoux commented 4 years ago

Currently, the source code is using very different conventions of code formatting (tabs or spaces for indentation, curly braces with LF before or after, separation of function name and parameters, ...). This make the commits quite hard to read and generates useless conflicts.

The idea is to define one standard for the whole project and force the commits to respect it.

A way to go could be to use google-java-format which is provided in Java (so works on every computer that tries to dev on Jhove), works with maven, provides plug-ins for the main IDE and most importantly can be define as a pre-commit hook for git which will make sure every file is indeed formatted as the others.

The initial commit (reformatting everything will be painfull) but in the long run it should make life easier...

carlwilson commented 4 years ago

This issue's a monster and will need breaking down. If there's a will to take it on during OPF's 2020 Hackathon I'll run a quick meeting with volunteers outlining the approach we'll take.

svanteschubert commented 4 years ago

What worked out well as general whitespace normalization by Maven for our ODF Toolkit project pom.xml was the editorconfig-maven-plugin

It will fix whitespace during the build by automation (instead of breaking the build).

org.ec4j.maven editorconfig-maven-plugin 0.0.11 check prepare-package format ** target You may find the [whitespace .editorconfig file here](https://github.com/tdf/odftoolkit/blob/1.0.0_SNAPSHOT/.editorconfig): # See https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties # Fix format via command line: 'mvn editorconfig:format' root=true [*.{groovy,java,kt,xml,mdtext}] end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_style = space tab_width = 4 indent_size = 4 max_line_length = off charset = utf-8
carlwilson commented 4 years ago

Thanks for this @svanteschubert and hi again, it's been a little while. I hope you're well in this strange new normal. Well, this is an exciting suggestion who doesn't like an automated approach. I've used similar with git pre-commits, but Maven is a reasonable choice here. Will check this out.

MartinSpeller commented 4 years ago

Standardize source code formatting #516 - Assigned to TBA