[Misc] Make JUnit5 test classes and methods package-private (SonarCloud java:S5786)#5826
Open
vmassol wants to merge 1 commit into
Open
[Misc] Make JUnit5 test classes and methods package-private (SonarCloud java:S5786)#5826vmassol wants to merge 1 commit into
vmassol wants to merge 1 commit into
Conversation
…ud java:S5786) Mechanical, behaviour-preserving cleanup of SonarCloud rule java:S5786 across 13 modules: JUnit5 no longer requires test classes or test methods to be public, package-private is the recommended visibility. Co-Authored-By: Vincent Massol <vincent@massol.net>
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
Mechanical, behaviour-preserving cleanup of SonarCloud rule java:S5786 ("JUnit5 test classes and methods should have default package visibility") across 13 modules. 27 issues fixed in 27 test files (55
publicmodifiers removed).JUnit5 no longer requires test classes or test methods to be
public; package-private is the recommended visibility.Details
For every flagged test file the
publicmodifier was removed from:@Nested/ helper class declarations), and@Test,@BeforeEach,@AfterEach,@BeforeAll,@AfterAll,@ParameterizedTest, etc.).Other modifiers (e.g.
staticon@BeforeAllmethods) and non-JUnit members were left untouched — in particular XWiki-specific lifecycle methods such as@BeforeComponent public void configure(...)keep their visibility (they are not flagged by S5786). No production code changed; only test visibility modifiers.Modules touched:
xwiki-platform-annotation-core,xwiki-platform-csrf,xwiki-platform-display-html,xwiki-platform-livedata-livetable,xwiki-platform-localization-source-jar,xwiki-platform-mentions-notifications,xwiki-platform-notifications-api,xwiki-platform-notifications-filters-default,xwiki-platform-refactoring-default,xwiki-platform-search-solr-embedded,xwiki-platform-security-authentication-default,xwiki-platform-security-authorization-api,xwiki-platform-user-resource.All fixed issues belong to SonarCloud rule
java:S5786. See the open S5786 issues for this project.Test plan
mvn clean install -Plegacy,snapshot -DskipTestsacross all 13 modules in one reactor — BUILD SUCCESS. Test sources still compile and Checkstyle passes; visibility-only changes are behaviour-preserving.🤖 Generated with Claude Code
Generated by Claude Code