fix: remove unnecessary public modifiers from JUnit5 test classes and methods#364
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: remove unnecessary public modifiers from JUnit5 test classes and methods#364sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZggAC4hxdvKFWvLKU-2 for java:S5786 rule - AZggAC4hxdvKFWvLKU-3 for java:S5786 rule - AZggAC4hxdvKFWvLKU-1 for java:S5786 rule - AZggAC4hxdvKFWvLKU-4 for java:S5786 rule - AZggAC4AxdvKFWvLKU-w for java:S5786 rule Generated by SonarQube Agent (task: 6a3cb6a9-ff0e-4052-b17b-fc13f96957e6)
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.
Removes the 'public' modifier from test classes and methods across multiple test files to comply with JUnit5 best practices and SonarQube rule S5786. Test classes and methods don't require public visibility and using package-default visibility improves code clarity and follows modern testing conventions.
View Project in SonarCloud
Fixed Issues
java:S5786 - Remove this 'public' modifier. • INFO • View issue
Location:
flex-squid/src/test/java/org/sonar/flex/grammar/lexical/SpacingNoLineBreakTest.java:25Why is this an issue?
JUnit5 is more tolerant regarding the visibility of test classes and methods than JUnit4, which required everything to be
public. Test classes and methods can have any visibility exceptprivate. It is however recommended to use the default package visibility to improve readability.What changed
Removes the 'public' modifier from the test class 'SpacingNoLineBreakTest' at line 25, changing it to package-default visibility. This directly fixes the static analysis warning (java:S5786) that JUnit5 test classes should use default package visibility instead of 'public'.
java:S5786 - Remove this 'public' modifier. • INFO • View issue
Location:
flex-squid/src/test/java/org/sonar/flex/grammar/statements/ReturnStatementTest.java:29Why is this an issue?
JUnit5 is more tolerant regarding the visibility of test classes and methods than JUnit4, which required everything to be
public. Test classes and methods can have any visibility exceptprivate. It is however recommended to use the default package visibility to improve readability.What changed
Removes the 'public' modifier from the test method 'eos_is_line_terminator()' at line 29, changing it to package-private visibility. JUnit5 test methods don't need to be public, and the recommended convention is to use default (package) visibility for better readability.
java:S5786 - Remove this 'public' modifier. • INFO • View issue
Location:
flex-squid/src/test/java/org/sonar/flex/grammar/statements/ReturnStatementTest.java:37Why is this an issue?
JUnit5 is more tolerant regarding the visibility of test classes and methods than JUnit4, which required everything to be
public. Test classes and methods can have any visibility exceptprivate. It is however recommended to use the default package visibility to improve readability.What changed
Removes the 'public' modifier from the test method 'eos_is_semicolon()' at line 37, changing it to package-private visibility. JUnit5 test methods don't need to be public, and the recommended convention is to use default (package) visibility for better readability.
java:S5786 - Remove this 'public' modifier. • INFO • View issue
Location:
flex-squid/src/test/java/org/sonar/flex/grammar/statements/ReturnStatementTest.java:44Why is this an issue?
JUnit5 is more tolerant regarding the visibility of test classes and methods than JUnit4, which required everything to be
public. Test classes and methods can have any visibility exceptprivate. It is however recommended to use the default package visibility to improve readability.What changed
Removes the 'public' modifier from the test method 'eos_before_right_curly_bracket()' at line 44, changing it to package-private visibility. JUnit5 test methods don't need to be public, and the recommended convention is to use default (package) visibility for better readability.
java:S5786 - Remove this 'public' modifier. • INFO • View issue
Location:
flex-squid/src/test/java/org/sonar/flex/grammar/statements/ReturnStatementTest.java:51Why is this an issue?
JUnit5 is more tolerant regarding the visibility of test classes and methods than JUnit4, which required everything to be
public. Test classes and methods can have any visibility exceptprivate. It is however recommended to use the default package visibility to improve readability.What changed
Removes the 'public' modifier from the test method 'eos_is_end_of_input()' at line 51, changing it to package-private visibility. JUnit5 test methods don't need to be public, and the recommended convention is to use default (package) visibility for better readability.
SonarQube Remediation Agent uses AI. Check for mistakes.