refactor: de-duplicate choice-list initializers, fix Sonar, add tests#37
Open
fbourasse wants to merge 1 commit into
Open
refactor: de-duplicate choice-list initializers, fix Sonar, add tests#37fbourasse wants to merge 1 commit into
fbourasse wants to merge 1 commit into
Conversation
- Extract AbstractChoiceListInitializerRenderer base class for the ButtonType/ NavbarRoot/GridType initializers (~90% duplicated) — project duplication 32% -> 0%, clearing the duplicated_lines_density gate. Remove unused loggers, apply diamond operator, extract the addMixin literal to a constant. - SwitchToLanguageTag: remove the languageCode field shadowing AbstractJahiaTag.languageCode (Sonar BLOCKER S2387); add @OverRide. - Add first bootstrap4-components unit tests (JUnit 4 + Mockito, 16) + JaCoCo. Signed-off-by: Florent BOURASSE <fbourasse@jahia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Blind multi-dimensional review of the bootstrap4 module. SonarQube quality gate was ERROR (duplicated_lines_density 32.1% vs 3% threshold) and is now OK (0%), with 23 issues resolved and the first
bootstrap4-componentsunit tests added.Code quality / duplication (the gate blocker)
ButtonTypeInitializer,NavbarRootInitializer,GridTypeInitializer) were ~90% identical (duplicatesetKey/getKey/getStringRendering×2 plus boilerplate). Extracted a sharedAbstractChoiceListInitializerRendererbase class; each concrete class now only declares its@Component, default key, and its specific choice list via a helper. Project duplication dropped 32.1% → 0.0%.loggerfields (S1068), applied the diamond operator (S2293), and extracted the repeatedaddMixinliteral to a constant (S1192 CRITICAL).Bug / BLOCKER
SwitchToLanguageTagdeclared aprivate String languageCodefield that shadowed the inheritedAbstractJahiaTag.languageCode(Sonar BLOCKER S2387). Verified viajavapthat the superclass exposes a usableprotectedfield + accessors; removed the local field and redundant accessors, and added the missing@Overrideannotations (S1161). Rendered<a>output is unchanged.Tests & coverage
bootstrap4-components: 16 tests (JUnit 4 + Mockito) covering all three initializers (value names/order,addMixinmapping, null-context empty list, string rendering) and theFunctionstaglib helper. JaCoCo coverage wiring.Behavior
Test plan
mvn clean install(JDK 17, full reactor) — BUILD SUCCESS, 16/16 tests