gnodet opened a new pull request, #30722:
URL: https://github.com/apache/camel/pull/30722
## CAMEL-20206: Reduce cognitive complexity in core modules
Behavior-preserving refactoring to reduce cognitive complexity (SonarQube
rule S3776) in several core modules.
### Changes
**camel-xml-io — MXParser.java**
- Added `@SuppressWarnings("java:S3776")` to 4 methods (`nextImpl`,
`parseProlog`, `parseEpilog`, `parseAttribute`) — vendored XmlPull parser where
complexity is inherent in the XML spec state machine
**camel-core-languages — StringFunctionFactory, CollectionFunctionFactory,
MiscFunctionFactory**
- Converted giant if-else chains in `createFunction()` to `Map<String,
FunctionParser>` dispatch tables
- Each function parser is now a private static method
- Added `@FunctionalInterface FunctionParser` type for the dispatch
**camel-core-model — RestDefinition.java**
- Extracted `resolveWithFallback(CamelContext, String, String)` to eliminate
~20 repeated if/else verb-vs-rest fallback blocks
- Extracted `inferConsumesProduces(RestBindingDefinition, String)` using a
switch expression for binding mode → content type mapping
**camel-core-engine — DefaultDumpRoutesStrategy.java**
- Extracted `shouldInclude(String entity)` to replace 15 repeated
`include.contains("*") || include.contains("all") || include.contains(entity)`
conditions
**camel-util — StringQuoteHelper.java**
- Extracted `handleQuoteChar(...)` to deduplicate the near-identical
single-quote and double-quote handling blocks
- Extracted `updateQuoteRange(...)` to consolidate quote range tracking logic
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]