Skip to content

(chores): fix SonarCloud S6201 in multiple modules#22303

Merged
orpiske merged 16 commits intoapache:mainfrom
orpiske:ci-camel-4-sonarcloud-S6201
Mar 31, 2026
Merged

(chores): fix SonarCloud S6201 in multiple modules#22303
orpiske merged 16 commits intoapache:mainfrom
orpiske:ci-camel-4-sonarcloud-S6201

Conversation

@orpiske
Copy link
Copy Markdown
Contributor

@orpiske orpiske commented Mar 28, 2026

Summary

  • Replace traditional instanceof check + explicit cast with Java 16+ pattern matching instanceof across 103 files in 14 module groups
  • Addresses ~250 SonarCloud S6201 violations (pattern matching for instanceof operator)
  • All changes are purely mechanical — semantically equivalent, no behavioral changes
  • Note: The MailConverters semantic fix was removed from this PR and submitted separately in camel-mail: fix incorrect guard in MailConverters multipart loop #22340
  • Note: Renamed pattern variable elementelem in DefaultCxfBinding.java to avoid shadowing (per review feedback)

Modules fixed:

  • Core: camel-support, camel-core-model, camel-core-languages, camel-base-engine, camel-yaml-io
  • AWS: camel-aws-bedrock, camel-aws-config, camel-aws2-ddb, camel-aws-secrets-manager, camel-aws-xray, camel-aws2-cw, camel-aws2-ec2, camel-aws2-eventbridge, camel-aws2-mq, camel-aws2-msk, camel-aws2-s3, camel-aws2-sns, camel-aws2-sqs, camel-aws2-sts, camel-aws2-translate
  • Azure: camel-azure-functions, camel-azure-servicebus
  • CXF: camel-cxf-common, camel-cxf-soap, camel-cxf-rest, camel-cxf-spring-soap, camel-cxf-spring-rest, camel-cxf-transport
  • Components: camel-elasticsearch, camel-jackson3 (+avro, +protobuf), camel-mail, camel-netty, camel-netty-http, camel-opensearch, camel-pqc, camel-sjms, camel-smpp, camel-spring-rabbitmq, camel-zeebe

Test plan

  • All affected modules compile with mvn -DskipTests install
  • Formatting verified with mvn formatter:format impsort:sort
  • CI passes on all affected modules

🤖 Claude Code on behalf of Otavio R. Piske

@orpiske orpiske requested review from davsclaus and oscerd March 28, 2026 10:22
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

Copy link
Copy Markdown
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@apupier
Copy link
Copy Markdown
Contributor

apupier commented Mar 30, 2026

for better readability when next users will have to read the git history, it will be better to have the real description inthe commit message as title and the Sonar ID reference only as part of the commit message body

@apupier
Copy link
Copy Markdown
Contributor

apupier commented Mar 30, 2026

/component-test mail

@github-actions
Copy link
Copy Markdown
Contributor

/component-test mail tests passed successfully.

@orpiske
Copy link
Copy Markdown
Contributor Author

orpiske commented Mar 30, 2026

Thanks for the feedback @apupier. Noted — future commits will use a descriptive title with the SonarCloud reference in the body only.

Claude Code on behalf of Otavio R. Piske

orpiske and others added 16 commits March 30, 2026 15:41
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>
The instanceof pattern matching change in MailConverters also changed
which variable was checked in the inner loop guard, making it a semantic
fix rather than a mechanical refactoring. Revert it here so it can be
submitted as a separate PR.

Claude Code on behalf of Otavio R. Piske

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename `element` to `elem` in the instanceof pattern match at line 1198
to avoid confusion with the `Element element = null` declared in the
if-branch above. They are in mutually exclusive scopes so it compiled
correctly, but this improves readability.

SonarCloud S6201 follow-up.

Claude Code on behalf of Otavio R. Piske

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@orpiske orpiske force-pushed the ci-camel-4-sonarcloud-S6201 branch from d9c791b to ea3baa5 Compare March 30, 2026 15:42
@orpiske orpiske merged commit f9ce2c3 into apache:main Mar 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants