Repository navigation
JAVA-7379 Split define method into smaller methods to comply with line limit - #6557
Merged
leonardo-pilastri-sonarsource merged 1 commit intoNov 24, 2026
Conversation
Fixed issues: - AaIGpn4b5os8fajUEO3l for java:S138 rule Generated by SonarQube Agent (task: f04512f6-6353-4079-af5a-11eefdcf4d23)
Contributor
Contributor
|
leonardo-pilastri-sonarsource
approved these changes
Nov 24, 2026
leonardo-pilastri-sonarsource
deleted the
remediate-master-20261123-080326-cc00cd69
branch
November 24, 2026 10:12
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.




The define(Context) method in JavaPlugin exceeded the 100-line limit with 101 lines. This change refactors it into two smaller methods: addProductSpecificExtensions(Context, List) handles the SonarLint branching logic, and coreExtensions() manages the large extensions list, allowing define to focus on composition and fall below the threshold.
View Project in SonarCloud
Fixed Issues
java:S138 - This method has 101 lines, which is greater than the 100 lines authorized. Split it into smaller methods. • MAJOR • View issue
Location:
java:sonar-java-plugin/src/main/java/org/sonar/plugins/java/JavaPlugin.java:50Why is this an issue?
A method that grows too large tends to aggregate too many responsibilities. Such method inevitably become harder to understand and therefore harder to maintain.
What changed
Split the 101-line define(Context) method into smaller ones. The SonarLint vs. non-SonarLint branching now lives in addProductSpecificExtensions(Context, List), and the large Arrays.asList block of core extensions now lives in coreExtensions(). define just puts the list together, so it is now under the 100-line limit and does the same thing as before.