Skip to content

test: enforce 100% coverage gate on pure-logic core classes#11

Merged
nbdSteve merged 3 commits into
masterfrom
fm/armorplus-p3-coretests-c9
Jul 9, 2026
Merged

test: enforce 100% coverage gate on pure-logic core classes#11
nbdSteve merged 3 commits into
masterfrom
fm/armorplus-p3-coretests-c9

Conversation

@nbdSteve

@nbdSteve nbdSteve commented Jul 9, 2026

Copy link
Copy Markdown
Owner

Intent

Fix all 6 SonarCloud issues on PR #11: S2699 (add assertion to constructor test), S5976 x3 (consolidate repeated tests into parameterized tests for south, west, east octants), S1128 x2 (unused imports now used by the parameterized tests). No logic changes, same 100% core coverage gate passes, same test coverage. The refactoring reduces test LOC by consolidating 31 individual test methods into 9 parameterized test methods that still exercise the same yaw values and direction assertions.

What Changed

  • Added a JaCoCo check-core execution in pom.xml that fails the build if line or branch coverage drops below 100% on the five pure-logic core classes (PlayerDirectionUtil, ColorUtil, Piece, SetType, SetDataType).
  • Added new test classes for ColorUtil, Piece, SetType, and SetDataType, and refactored PlayerDirectionUtilTest from 31 individual test methods into 9 parameterized tests covering all 8 compass octants plus yaw normalization - resolving SonarCloud S5976, S1128, and S2699 issues.
  • Simplified redundant upper-bound conditions in PlayerDirectionUtil's if-else chain (semantically equivalent since the else-if structure already guarantees bounds).

Risk Assessment

✅ Low: The production code change is a mechanical simplification of redundant conditions in an if-else-if chain with identical runtime behavior, and all other changes are test-only or build-config additions that do not affect shipped code.

Testing

Ran the full Maven verify lifecycle under JDK 25. All 43 tests pass and the JaCoCo check-core gate confirms 100% line and branch coverage on the five core classes. The parameterized test refactoring exercises the same 31 yaw-to-direction combinations as before, just consolidated into fewer methods.

Evidence: Maven verify summary (test counts + coverage gate)

[INFO] Tests run: 31, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.126 s -- in gg.steve.mc.ap.utils.PlayerDirectionUtilTest [INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 s -- in gg.steve.mc.ap.utils.ColorUtilTest [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.armor.SetTypeTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.armor.PieceTest [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.data.SetDataTypeTest [INFO] Tests run: 43, Failures: 0, Errors: 0, Skipped: 0 [INFO] --- jacoco:0.8.15:check (check-core) @ ArmorPlus --- [INFO] BUILD SUCCESS

[INFO] Tests run: 31, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.126 s -- in gg.steve.mc.ap.utils.PlayerDirectionUtilTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.018 s -- in gg.steve.mc.ap.utils.ColorUtilTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.armor.SetTypeTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.armor.PieceTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in gg.steve.mc.ap.data.SetDataTypeTest
[INFO] Tests run: 43, Failures: 0, Errors: 0, Skipped: 0
[INFO] --- jacoco:0.8.15:check (check-core) @ ArmorPlus ---
[INFO] BUILD SUCCESS
Evidence: JaCoCo CSV - core class coverage (all 0 missed)

GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED ArmorPlus,gg.steve.mc.ap.utils,ColorUtil,0,7,0,0,0,2 ArmorPlus,gg.steve.mc.ap.utils,PlayerDirectionUtil,0,104,0,18,0,27 ArmorPlus,gg.steve.mc.ap.data,SetDataType,0,75,0,0,0,13 ArmorPlus,gg.steve.mc.ap.armor,Piece,0,33,0,0,0,6 ArmorPlus,gg.steve.mc.ap.armor,SetType,0,3,0,0,0,1

GROUP,PACKAGE,CLASS,INSTRUCTION_MISSED,INSTRUCTION_COVERED,BRANCH_MISSED,BRANCH_COVERED,LINE_MISSED,LINE_COVERED,COMPLEXITY_MISSED,COMPLEXITY_COVERED,METHOD_MISSED,METHOD_COVERED
ArmorPlus,gg.steve.mc.ap.utils,ColorUtil,0,7,0,0,0,2,0,2,0,2
ArmorPlus,gg.steve.mc.ap.utils,PlayerDirectionUtil,0,104,0,18,0,27,0,14,0,5
ArmorPlus,gg.steve.mc.ap.data,SetDataType,0,75,0,0,0,13,0,1,0,1
ArmorPlus,gg.steve.mc.ap.armor,Piece,0,33,0,0,0,6,0,1,0,1
ArmorPlus,gg.steve.mc.ap.armor,SetType,0,3,0,0,0,1,0,1,0,1

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • mvn -B clean verify (full lifecycle: compile, test, JaCoCo instrument/report/check-core)
  • Verified PlayerDirectionUtilTest runs 31 parameterized cases covering all 8 compass octants plus large-yaw normalization
  • Confirmed JaCoCo CSV shows 0 missed instructions/branches/lines for all 5 core classes (PlayerDirectionUtil, ColorUtil, Piece, SetType, SetDataType)
  • Verified unused import removed (S1128) and parameterized imports are exercised (S5976)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Stephen Goodhill added 3 commits July 9, 2026 11:50
Establish a CORE set of pure-logic classes with a JaCoCo check execution
(check-core) that enforces 100% line and branch coverage, failing the
build if coverage drops. The core set includes: PlayerDirectionUtil,
ColorUtil, Piece, SetType, and SetDataType.

- Extend PlayerDirectionUtil tests to cover all 8 direction octants
  with boundary values, negative yaw normalization, and large yaw wrap
- Simplify PlayerDirectionUtil's else-if chain to remove redundant
  upper-bound conditions (semantically equivalent, eliminates
  unreachable bytecode branches)
- Add ColorUtil tests covering color code translation, edge cases
- Add Piece, SetType, SetDataType enum tests for full coverage
- Exclude LogUtil (server-dependent) and nbt.NBTType (vendored) from
  the gate with justification in AGENTS.md
- S2699: add assertion to ColorUtil constructor test
- S5976: consolidate repeated direction tests into parameterized tests
  (south, west, north, east octants each had 3-4 nearly-identical tests)
- S1128: remove unused ParameterizedTest/CsvSource imports (now used)
@sonarqubecloud

sonarqubecloud Bot commented Jul 9, 2026

Copy link
Copy Markdown

@nbdSteve nbdSteve changed the title test: add 100% coverage gate on pure-logic core module test: enforce 100% coverage gate on pure-logic core classes Jul 9, 2026
@nbdSteve
nbdSteve merged commit bb1ab71 into master Jul 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant