Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Whole-tree reformat with mvn formatter:format (#118)
13b1fdb37e3aa7f621d68d93c5118c7932ea7425
46 changes: 46 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Java sources
*.java text diff=java
*.kt text diff=kotlin
*.groovy text diff=java
*.scala text diff=java
*.gradle text diff=java
*.gradle.kts text diff=kotlin

# These files are text and should be normalized (Convert crlf => lf)
*.css text diff=css
*.scss text diff=css
*.sass text
*.df text
*.htm text diff=html
*.html text diff=html
*.js text
*.mjs text
*.cjs text
*.jsp text
*.jspf text
*.jspx text
*.properties text
*.tld text
*.tag text
*.tagx text
*.xml text
*.md text diff=markdown
*.awk text

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.jar binary
*.so binary
*.war binary
*.jks binary

# Common build-tool wrapper scripts ('.cmd' versions are handled by 'Common.gitattributes')
mvnw text eol=lf
gradlew text eol=lf

# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
6 changes: 4 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## Code format

The project has not adopted the MetricsHub Eclipse formatter profile yet (see issue #118). Until it does, match the style of the file you are editing: the `org.metricshub.ipmi.client` packages use tabs, the `org.metricshub.ipmi.core` packages (forked from the Verax IPMI library) use 4 spaces. Do not reformat code you are not otherwise changing. Once `formatter-maven-plugin` is configured, simply run `mvn formatter:format` before committing.
The code is formatted with the MetricsHub Eclipse formatter profile (`metricshub-eclipse-formatter.xml`, byte-identical to jawk's): tabs, 120-column lines. `formatter:validate` runs at the `validate` phase, so unformatted code fails the build. Simply run `mvn formatter:format` before committing, and do not hand-format code.

Checkstyle (`checkstyle.xml`, byte-identical to jawk's) runs at `verify` with `failOnViolation=true`. Fix violations rather than suppressing them; when a suppression is justified, wrap the code in `// CHECKSTYLE.OFF: <RuleName>` / `// CHECKSTYLE.ON: <RuleName>` comments.

All Java source files under `src/main/java` must include the proper LGPL-3 license header (the `license-maven-plugin` check covers `main/java/**/*.java` only; tests, Markdown and resources carry no header). When you add a new source file, run `mvn license:update-file-header` before committing (and before building, since the build fails if a source file lacks the header).

Expand All @@ -24,7 +26,7 @@ Unit tests must not depend on a real BMC. Exercising the RMCP+ session code agai

## Code quality reports

Code quality reports (checkstyle, pmd/cpd, spotbugs) are generated by `mvn verify site` into ./target/checkstyle-result.xml, ./target/pmd.xml, ./target/cpd.xml and ./target/spotbugsXml.xml. They are not yet gated (issues #114, #115, #116, #117 track the clean-up). Do not add new violations: check the reports for the files you changed before committing and submitting your code. On JDK 21+ the SpotBugs plugin version inherited from the parent POM cannot read the JDK class files; run `mvn com.github.spotbugs:spotbugs-maven-plugin:4.10.4.1:spotbugs` instead.
Code quality reports (checkstyle, pmd/cpd, spotbugs) are generated by `mvn verify site` into ./target/checkstyle-result.xml, ./target/pmd.xml, ./target/cpd.xml and ./target/spotbugsXml.xml. Checkstyle is gated (the build fails on any error); PMD/CPD and SpotBugs are not yet gated (issues #114, #115, #116 track the clean-up). Do not add new violations: check the reports for the files you changed before committing and submitting your code. On JDK 21+ the SpotBugs plugin version inherited from the parent POM cannot read the JDK class files; run `mvn com.github.spotbugs:spotbugs-maven-plugin:4.10.4.1:spotbugs` instead.

## Documentation

Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ See **[Project Documentation](https://metricshub.org/ipmi-java)** and the [Javad

The IPMI Java Client is a library that communicates with the IPMI host, fetches Field Replaceable Units (FRUs) and Sensors information then reports these information as a text output.

## Upgrading

Version 1.2.03 makes the `protected` fields of the protocol classes (`AbstractIpmiRunner`, `MessageHandler`, `IpmiLanMessage`, `ConfidentialityAlgorithm`, `IntegrityAlgorithm`) `private`. Subclasses must use the new `protected` accessors instead; see [Upgrading from 1.2.02](https://metricshub.org/ipmi-java/#upgrading-from-1-2-02) for the list. The `IpmiClient` API is unchanged.

## Build instructions

This is a simple Maven project. Build with:
Expand All @@ -18,6 +22,22 @@ This is a simple Maven project. Build with:
mvn verify
```

## Code format

The code is formatted with the MetricsHub Eclipse formatter profile ([metricshub-eclipse-formatter.xml](metricshub-eclipse-formatter.xml), shared with the other MetricsHub Java projects), and the build fails on unformatted code. Simply run the below command before committing:

```bash
mvn formatter:format
```

The build also fails on [Checkstyle](checkstyle.xml) violations. A justified violation can be suppressed with `// CHECKSTYLE.OFF: <RuleName>` and `// CHECKSTYLE.ON: <RuleName>` comments.

To ignore the whole-tree reformat commit in `git blame`, run once:

```bash
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

## Release instructions

The artifact is deployed to Sonatype's [Maven Central](https://central.sonatype.com/).
Expand Down
243 changes: 122 additions & 121 deletions checkstyle.xml
Original file line number Diff line number Diff line change
@@ -1,130 +1,131 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<!--

Custom Checkstyle configuration that checks coding conventions,
roughly following the SUN coding conventions from:

- the Java Language Specification at
http://java.sun.com/docs/books/jls/second_edition/html/index.html

- the Sun Code Conventions at http://java.sun.com/docs/codeconv/

- the Javadoc guidelines at
http://java.sun.com/j2se/javadoc/writingdoccomments/index.html

- the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html

- some best practices

Checkstyle is very configurable. Be sure to read the documentation at
http://checkstyle.sf.net (or in your downloaded distribution).

Most Checks are configurable, be sure to consult the documentation.

To completely disable a check, just comment it out or delete it.

Finally, it is worth reading the documentation.

-->
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">

<module name="Checker">

<!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="FileLength"/>

<module name="TreeWalker">
<module name="TypeName">
<property name="format" value="^[A-Z][A-Za-z0-9_]*$"/>
</module>

<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName"/>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>

<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports"/>

<!-- Checks for Size Violations (MethodLength relaxed, e.g. max=700). -->
<!-- <module name="LineLength"/> -->
<module name="MethodLength">
<property name="max" value="700"/>
</module>

<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<!--<module name="LineLength"/>-->
<module name="ParameterNumber">
<property name="tokens" value="METHOD_DEF"/>
</module>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<!--
Formatting (whitespace/brace/line-wrap) checks have been disabled
because the Eclipse formatter profile (metricshub-eclipse-formatter.xml) covers these rules.
-->

<!-- Keep checking that files end with a newline -->
<module name="NewlineAtEndOfFile" />

<!-- Translation checks (not formatting-related) -->
<module name="Translation" />

<!-- File-length checks (size, not formatting) -->
<!-- module name="FileLength" /-->

<!-- Disable strictly formatting-related regex (trailing spaces) -->
<!--
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="minimum" value="0"/>
<property name="maximum" value="0"/>
<property name="message" value="Line has trailing spaces."/>
</module>
-->

<module name="TreeWalker">

<!-- Suppression of specific rules -->
<!-- CHECKSTYLE.OFF: <ruleName> -->
<!-- CHECKSTYLE.ON: <ruleName> -->
<module name="SuppressionCommentFilter">
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)" />
<property name="onCommentFormat" value="CHECKSTYLE.ON\: ([\w\|]+)" />
<property name="checkFormat" value="$1" />
</module>

<!-- Naming conventions (unaffected by formatter) -->
<module name="ConstantName" />
<module name="LocalFinalVariableName" />
<module name="LocalVariableName" />
<module name="MemberName" />
<module name="MethodName" />
<module name="PackageName" />
<module name="ParameterName" />
<module name="StaticVariableName" />
<module name="TypeName" />

<!-- Import-related checks (not formatting) -->
<module name="AvoidStarImport" />
<module name="IllegalImport" />
<module name="RedundantImport" />
<module name="UnusedImports" />

<!-- Size checks (not formatting) -->
<module name="MethodLength">
<property name="max" value="2000" />
</module>
<module name="ParameterNumber">
<property name="tokens" value="METHOD_DEF" />
</module>

<!-- Disable all whitespace/indent/wrapping checks because the Eclipse formatter enforces
spacing -->
<!--
<module name="EmptyForIteratorPad"/>
<module name="GenericWhitespace"/>
<module name="MethodParamPad"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAround">
<property name="tokens"
value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN, COLON, DIV_ASSIGN,
EQUAL, GE, GT, LE, LITERAL_RETURN, LT, MINUS_ASSIGN, MOD_ASSIGN, NOT_EQUAL,
PLUS_ASSIGN, QUESTION, SL_ASSIGN, SR_ASSIGN, STAR_ASSIGN"/>
<module name="WhitespaceAfter">
<property name="tokens" value="COMMA, SEMI"/>
</module>

<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<module name="RedundantModifier"/>

<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="AvoidNestedBlocks"/>
<!-- <module name="EmptyBlock"/> -->
<module name="LeftCurly">
<property name="option" value="eol"/>
<module name="WhitespaceAround">
<property name="tokens" value="ASSIGN, BAND_ASSIGN, BOR_ASSIGN, BSR_ASSIGN, BXOR_ASSIGN,
COLON, DIV_ASSIGN, EQUAL, GE, GT, LE, LITERAL_RETURN, LT,
MINUS_ASSIGN, MOD_ASSIGN, NOT_EQUAL, PLUS_ASSIGN, QUESTION,
SL_ASSIGN, SR_ASSIGN, STAR_ASSIGN"/>
</module>
<!-- <module name="NeedBraces"/> -->

<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!--<module name="AvoidInlineConditionals"/>-->
<module name="EmptyStatement"/>
<module name="EqualsHashCode"/>
<!-- <module name="HiddenField"/> -->
<module name="IllegalInstantiation"/>
<module name="InnerAssignment"/>
<!-- <module name="MagicNumber"/> -->
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>

<!-- Class design checks -->
<!-- <module name="FinalClass"/> -->
<module name="HideUtilityClassConstructor"/>
<module name="InterfaceIsType"/>
<!-- <module name="VisibilityModifier"/> -->

<!-- Misc. other checks -->
<module name="ArrayTypeStyle"/>
<!-- <module name="FinalParameters"/> -->
<!-- <module name="TodoComment" ...> -->
<!-- <module name="UpperEll"/> -->

</module>
</module>
-->

<!-- Modifier checks (unaffected by formatting) -->
<module name="ModifierOrder" />
<module name="RedundantModifier" />

<!-- Block-level checks (only disabling Opening‐brace style) -->
<module name="AvoidNestedBlocks">
<property name="allowInSwitchCase" value="true" />
</module>
<module name="NeedBraces" />

<!-- Common coding problem checks (unaffected by formatting) -->
<module name="EmptyStatement" />
<module name="EqualsHashCode" />
<module name="HiddenField">
<property name="ignoreConstructorParameter" value="true" />
<property name="ignoreSetter" value="true" />
</module>
<module name="IllegalInstantiation" />
<module name="InnerAssignment" />
<module name="MissingSwitchDefault" />
<module name="SimplifyBooleanExpression" />
<module name="SimplifyBooleanReturn" />

<!-- Design checks (unrelated to formatting) -->
<module name="FinalClass" />
<module name="HideUtilityClassConstructor" />
<module name="InterfaceIsType" />
<module name="VisibilityModifier" />

<!-- Miscellaneous (keep non-formatting Todo checks) -->
<module name="ArrayTypeStyle" />
<module name="TodoComment">
<property name="format" value="FIXME" />
</module>
<module name="TodoComment">
<property name="format" value="TODO" />
<property name="severity" value="warning" />
</module>
<module name="TodoComment">
<property name="format" value="XXX" />
<property name="severity" value="warning" />
</module>
<module name="UpperEll" />

</module>
</module>
Loading
Loading