Skip to content

Adopt the MetricsHub Eclipse formatter profile and formatter-maven-plugin, as in jawk #118

Description

@bertysentry

Goal

Format the code base with the same Eclipse formatter profile and Maven plugin as jawk (and maven-skin-tools, which ships the byte-identical profile), so that every MetricsHub Java project looks the same and formatting stops being a review topic.

Current state

  • No formatter is configured. src/main/java mixes 33 tab-indented and 246 space-indented files (the Verax core uses 4 spaces, the MetricsHub client layer uses tabs), and all 279 files have CRLF line endings.
  • Checkstyle (see the companion issue on checkstyle.xml) still carries formatting rules (WhitespaceAround, LeftCurly, MethodParamPad, …) that a formatter makes redundant.

What jawk does (reference)

pom.xml (link):

<plugin>
	<groupId>net.revelc.code.formatter</groupId>
	<artifactId>formatter-maven-plugin</artifactId>
	<version>2.29.0</version>
	<executions>
		<execution>
			<phase>validate</phase>
			<goals>
				<goal>validate</goal>
			</goals>
		</execution>
	</executions>
	<configuration>
		<directories>
			<directory>${project.build.sourceDirectory}</directory>
			<directory>${project.build.testSourceDirectory}</directory>
		</directories>
		<includes>
			<include>**/*.java</include>
		</includes>
		<configFile>metricshub-eclipse-formatter.xml</configFile>
	</configuration>
</plugin>
  • metricshub-eclipse-formatter.xml at the repository root: Eclipse CodeFormatterProfile named MetricsHub (version 23); tabs (tabulation.char=tab, tabulation.size=2, indentation.size=4), lineSplit=120, comment.line_length=120, continuation_indentation=2, join_wrapped_lines=false, one blank line between import groups, newline at end of file. Copy it verbatim from jawk (it is identical in maven-skin-tools; winrm-java carries a 25-byte variant that should be reconciled too).
  • formatter:validate runs at validate, so an unformatted file fails mvn verify; developers run mvn formatter:format before committing (jawk's CONTRIBUTING.md: "You never need to worry about code formatting at all. Simply run mvn formatter:format before committing").
  • Same approach in maven-skin-tools (formatter-maven-plugin 2.29.0, validate goal at the validate phase).

Proposed steps

  1. Add metricshub-eclipse-formatter.xml (copied from jawk) and the plugin configuration above to pom.xml; add a "Code format" section to README.md/CONTRIBUTING.md.
  2. Run mvn formatter:format once on the whole tree in a dedicated commit (expect a large diff: ~280 files), and list that commit in .git-blame-ignore-revs so git blame stays usable.
  3. Decide line endings with .gitattributes (jawk has one) so the formatter and Git agree on CRLF vs LF.
  4. Land the reformat right after the pending fix PRs (Don't abort the SDR repository walk on OEM or undecodable records #112 and the ones for A single lost UDP response stalls collection for 300 s; per-message timeout is not configurable from IpmiClientConfiguration #77/Sync retry never waits for the resent message: MessageListener.response is never reset #78/Timeouts and cancellation: waitForResponse counts sleeps instead of wall-clock, swallows InterruptedException, and non-daemon threads keep the JVM alive #79/Session-setup failures leave the state machine stuck and mask the real cause ("Illegal connection state: Rakp1Waiting") #109) to avoid rebasing them across a whole-tree reformat.
  5. Then switch checkstyle.xml to the jawk variant that drops the formatting checks (companion issue).

Acceptance

  • mvn verify fails on an unformatted file and passes on the formatted tree.
  • The formatter profile is byte-identical to jawk's.
  • Checkstyle, PMD, SpotBugs reports are unchanged or lower after the reformat (no new violations introduced by wrapping).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions