Skip to content

[Misc] Simplify code flagged by SonarCloud (inline returns, factor duplicated literals)#5831

Open
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-tgugtc
Open

[Misc] Simplify code flagged by SonarCloud (inline returns, factor duplicated literals)#5831
vmassol wants to merge 1 commit into
masterfrom
claude/vigilant-dirac-tgugtc

Conversation

@vmassol

@vmassol vmassol commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Mechanical, behaviour-preserving cleanup of two SonarCloud rules across 15 modules (20 issues fixed in 19 files):

  • java:S1488 — "Immediately return this expression instead of assigning it to the temporary variable" (12 issues). Each Type tmp = <expr>; return tmp; was collapsed to return <expr>;.
  • java:S1192 — "Define a constant instead of duplicating this literal" / "Use already-defined constant" (8 issues). A private static final constant 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:

  • Coincidental value matches where the two literals mean different things (e.g. a plugin-name constant "package" vs. the package.xml XML root-element name; a script-context binding key vs. an id-namespace segment).
  • Illegal forward references — the suggested existing constant is declared textually after the flagged static-field initializer.

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_q1Yj5qvzeRorI

S1192: 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

…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>
@vmassol vmassol added the llm-agent To be used for PRs created autonomously by LLM agents. label Jul 13, 2026 — with Claude
@vmassol vmassol self-assigned this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm-agent To be used for PRs created autonomously by LLM agents.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant