[Misc] Define constants for duplicated String literals (SonarCloud java:S1192)#5787
Conversation
…va:S1192) Extract private constants for String literals that were duplicated 3+ times within MimeTypesUtil, FeedPlugin, SchedulerPlugin and SchedulerPluginApi, resolving 21 SonarCloud java:S1192 issues. Co-Authored-By: Vincent Massol <vincent@massol.net>
|
I would have expected |
|
Good point — I looked into it. These four files are excluded from Checkstyle entirely (file-level So un-excluding them can't be done as part of this S1192-only PR — each would need a full Checkstyle cleanup (Javadoc, complexity refactors, the remaining sub-threshold literals, etc.), which is a substantially larger effort per file. I've kept the Generated by Claude Code |
Description
Fixes 21 SonarCloud
java:S1192issues ("Define a constant instead of duplicating this literal N times") by extractingprivate static final Stringconstants for String literals that were duplicated 3+ times within a single class.Files changed (issues resolved):
MimeTypesUtil— 9 (MIME-type literals repeated across theMIME_TYPESlookup table; constants declared before the static array so they can be referenced from its initializer)FeedPlugin— 6 (XWiki.FeedEntryClass,feedimgurl,updateFeedError,title,author,fullContent)SchedulerPlugin— 4 (jobName,status,Paused,Normal)SchedulerPluginApi— 2 (error,jobName)No behavior change — only literal-to-constant extraction. Javadoc occurrences of the same words were intentionally left untouched. The three affected Maven modules build cleanly (checkstyle + Spoon pass).
SonarCloud issues (rule
java:S1192, projectorg.xwiki.platform:xwiki-platform):https://sonarcloud.io/project/issues?resolved=false&rules=java%3AS1192&id=org.xwiki.platform%3Axwiki-platform
Generated by Claude Code