--- name: neqsim-code-hygiene version: "1.0.0" description: "Fix formatting, Checkstyle, Spotless, and JavaDoc build failures in NeqSim Java code. USE WHEN: the build fails on spotless:check, checkstyle:check, or javadoc:javadoc; a PR shows formatting/import-order/JavaDoc violations; or you edited any .java file and need to make it CI-clean. Covers the exact recurring errors (JavadocParagraph

, orphan

after lists, single-line @param/@return, import ordering, HTML5 tables, unused variables) and the fix-and-verify loop." last_verified: "2026-09-18" --- # NeqSim Code Hygiene: Formatting, Checkstyle, Spotless & JavaDoc Fixes This skill is the fix-it playbook for the code-quality gates that fail NeqSim CI: `spotless:check` (formatting), `checkstyle:check` (style, imports, JavaDoc structure), and `javadoc:javadoc` (HTML5-valid JavaDoc). It maps each recurring error message to its exact cause and fix, and gives the mandatory verify loop. For the separate rule set on which Java **language features** are allowed, load `neqsim-java8-rules`. ## When to Use This Skill - The build fails on `spotless:check`, `checkstyle:check`, or `javadoc:javadoc`. - A PR or the Problems panel shows formatting, import-order, or JavaDoc violations. - You created or edited ANY `.java` file (main, test, or examples) and must make it CI-clean. - You pasted a JavaDoc/error block and asked "fix errors like this". ## The Fix-and-Verify Loop (do this every time) 1. **Format first** — Spotless fixes whitespace/indentation but NOT import order or JavaDoc content: ```bash ./mvnw spotless:apply ``` 2. **Fix Checkstyle/JavaDoc by hand** — imports, `

` tags, single-line JavaDoc, tables (below). 3. **Verify each gate** on the touched files, then the whole set: ```bash ./mvnw spotless:check ./mvnw checkstyle:check ./mvnw javadoc:javadoc ``` 4. **Re-run `spotless:apply`** after hand edits (JavaDoc edits can change wrapping), then `git add`. 5. NEVER bypass with `git commit --no-verify`. > Order matters: hand-fix JavaDoc/imports, then `spotless:apply` last so the committed > file is both style-correct and formatter-clean. ## Spotless - AI-generated Java is **not** auto-formatted; a single unformatted file fails the whole CI build. - Profile: Eclipse `.config/neqsim_formatter.xml` (pom.xml), applied to `src/main/java` and `src/test/java`. - `spotless:apply` fixes: indentation (2 spaces), trailing whitespace, blank lines, brace placement, line wrapping of long method chains and string concatenations. - `spotless:apply` does NOT fix: import ordering, JavaDoc content/structure, unused variables. - Convenience wrapper also available: `python devtools/run_spotless.py` / `devtools/run_spotless.sh`. ## Checkstyle: Import Ordering Config: `.config/checkstyle_neqsim.xml` (Google style + project overrides). Imports must be **alphabetical by full path**, grouped in this order with the groups appearing top-to-bottom: ```java import com.google.gson.JsonObject; // com.* import java.util.HashMap; // java.* (HashMap before HashSet before List...) import java.util.HashSet; import java.util.List; import neqsim.thermo.system.SystemInterface; // neqsim.* import org.apache.logging.log4j.LogManager; // org.* (goes last) import org.apache.logging.log4j.Logger; ``` Rule: sort strictly by the full import string. `java.util.HashMap` sorts before `java.util.HashSet`; `org.*` comes after `neqsim.*`. No blank lines inside a group unless the project's config requires group separation — match the surrounding file. ## Checkstyle: JavadocParagraph (`

` errors) The `JavadocParagraph` rule requires that **every `

` tag is preceded by a blank JavaDoc line** (a lone ` *`). This is the most common failure. ```java // WRONG —

immediately after a heading/text line: /** *

Hardy Cross Method

*

Balances loop flows iteratively...

*/ // CORRECT — blank ` *` line before

: /** *

Hardy Cross Method

* *

Balances loop flows iteratively... */ ``` Notes: - Do NOT self-close or add a closing `

` — JavaDoc treats `

` as an opening separator. - The blank line rule applies before **every** `

`, including ones after `

`, `
`, ``.

## JavaDoc: Orphan `

` After a List (`javadoc:javadoc` HTML error) Starting a ``/`` | Remove it — the list already closed the paragraph | | Committing with `--no-verify` to skip the gate | Never bypass; fix the violation | | Hand-indenting long method chains | Let `spotless:apply` wrap them | | Guessing a deprecated method's replacement | Read the `@deprecated` JavaDoc tag for the named successor | | Deleting a deprecated member to clear a warning | Fix the *call site*; other callers may still need the member | ## Validation Checklist - [ ] `./mvnw spotless:apply` run, files re-`git add`ed - [ ] `./mvnw spotless:check` passes - [ ] `./mvnw checkstyle:check` passes (imports sorted, `

` preceded by blank line, no single-line JavaDoc) - [ ] `./mvnw javadoc:javadoc` passes (no orphan `

`, tables have ``, no plain-text `@see`) - [ ] Every method with a `throws` clause has a matching `@throws` - [ ] No `[deprecation]` warnings — call sites migrated to the successor named in the `@deprecated` tag - [ ] Code still compiles with Java 8 (see `neqsim-java8-rules`) ## References - `.config/checkstyle_neqsim.xml` — Checkstyle rules (Google style + overrides) - `.config/neqsim_formatter.xml` — Eclipse formatter profile used by Spotless - `neqsim-java8-rules` skill — forbidden Java 9+ features and JavaDoc requirements - `AGENTS.md` / `.github/copilot-instructions.md` — Spotless and JavaDoc mandates