[Misc] Simplify code flagged by SonarCloud (inline returns, factor duplicated literals)#5831
Open
vmassol wants to merge 1 commit into
Open
[Misc] Simplify code flagged by SonarCloud (inline returns, factor duplicated literals)#5831vmassol wants to merge 1 commit into
vmassol wants to merge 1 commit into
Conversation
…plicated literals) * java:S1488 - immediately return the expression instead of assigning it to a temporary variable (12 issues). * java:S1192 - define/reuse a constant instead of duplicating a string literal (8 issues). 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 two SonarCloud rules across 15 modules (20 issues fixed in 19 files):
Type tmp = <expr>; return tmp;was collapsed toreturn <expr>;.private static finalconstant was introduced (or an existing one reused) and the duplicated string literal replaced.No production behaviour changed.
Notes on skipped S1192 sites
A few flagged S1192 sites were intentionally left out because the fix would not be safe/clean:
"package"vs. thepackage.xmlXML root-element name; a script-context binding key vs. an id-namespace segment).SonarCloud issues
S1488:
AZST1DhIZAC_a1NHeUDr,AX8RXBaZAp4U05lfTbt6,AZBvgR98cj_-G2g1uBsF,AXnpAhD5DDFOvAKXAQuj,AXnpAhD5DDFOvAKXAQuk,AW5-S-iw1Yj5qvzeRo32,AW5-S-hi1Yj5qvzeRo3x,AW5-S5Nq1Yj5qvzeRmzt,AW5-S-ET1Yj5qvzeRouh,AW5-S-XD1Yj5qvzeRo17,AW5-S-Ve1Yj5qvzeRo1M,AW5-S9_q1Yj5qvzeRorIS1192:
AZ9CRJnEiM_eM0I2UHyr,AZ8slQrNRFoArOAacNPX,AXnpAdZCDDFOvAKXAQEa,AW5-S-MH1Yj5qvzeRox6,AW5-S-L-1Yj5qvzeRoxy,AW5-S-AD1Yj5qvzeRos5,AW5-S7pB1Yj5qvzeRn8i,AW5-S51K1Yj5qvzeRm5_See the open SonarCloud issues for this project.
The modified Maven modules build cleanly (
mvn clean install -DskipTests, which runs Checkstyle + Spoon).Generated by Claude Code