(chores): fix SonarCloud S6201 in multiple modules#22303
(chores): fix SonarCloud S6201 in multiple modules#22303orpiske wants to merge 14 commits intoapache:mainfrom
Conversation
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude Code on behalf of Otavio R. Piske Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
gnodet
left a comment
There was a problem hiding this comment.
Good mechanical refactoring overall. 103 files, all pattern matching transformations are semantically correct with proper variable scoping. CI is green.
One change in MailConverters.java is a semantic improvement (not purely mechanical) — see inline comment. One nit on variable naming in DefaultCxfBinding.java.
Claude Code on behalf of Guillaume Nodet
| while (content instanceof MimeMultipart) { | ||
| if (multipart.getCount() < 1) { | ||
| while (content instanceof MimeMultipart mimeMultipart) { | ||
| if (mimeMultipart.getCount() < 1) { |
There was a problem hiding this comment.
Semantic change — this is not a purely mechanical transformation.
The original code checked multipart.getCount() < 1, where multipart is the method parameter (the outer Multipart). That check was actually dead code: since we're inside for (int i = 0; i < size; i++) where size = multipart.getCount(), the outer count is always ≥ 1 when this line is reached.
The new code checks mimeMultipart.getCount() < 1, which is the inner MimeMultipart (the content variable). This is the correct thing to check — it guards against calling getBodyPart(0) on an empty multipart on the next line.
So this is actually a bug fix (replacing a dead guard with a meaningful one), not a mechanical refactoring. Worth noting since the PR claims "no behavioral changes". The fix itself is correct and an improvement.
| } else if (part instanceof Element) { | ||
| addNamespace((Element) part, nsMap); | ||
| answer.add(new DOMSource((Element) part)); | ||
| } else if (part instanceof Element element) { |
There was a problem hiding this comment.
nit: The pattern variable element here reuses the same name as the local variable Element element = null declared at line 1182 in the if branch above. They're in mutually exclusive scopes so this compiles and works correctly, but it's mildly confusing when reading the code. Consider using a different name like elem to make it visually distinct.
Not blocking.
Summary
instanceofcheck + explicit cast with Java 16+ pattern matchinginstanceofacross 103 files in 14 module groupsModules fixed:
Test plan
mvn -DskipTests installmvn formatter:format impsort:sort🤖 Generated with Claude Code on behalf of Otavio R. Piske