[ 
https://issues.apache.org/jira/browse/CAMEL-20206?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18150175#comment-18150175
 ] 

Guillaume Nodet commented on CAMEL-20206:
-----------------------------------------

h2. Proposed PR Split Strategy

Given the scale (3,095 issues, ~1,054h estimated effort), the work should be 
split into waves by area and severity.

---

h3. Wave 1 — Extreme cases (complexity > 100, 58 methods, ~110h)

One PR per area, targeting only the worst offenders. These require careful 
refactoring (extract method, decompose conditionals, introduce helper objects). 
Keep PRs small and focused to ease review.

*PR 1a — {{core/}} extreme cases*
- {{core/camel-xml-io/.../MXParser.java}} — CC=245, 166, 123, 104 (4 methods!)
- {{core/camel-core-catalog/.../AbstractCamelCatalog.java}} — CC=166, 111
- {{core/camel-core-languages/.../StringFunctionFactory.java}} — CC=154
- {{core/camel-core-model/.../RestDefinition.java}} — CC=149
- {{core/camel-core-engine/.../DefaultDumpRoutesStrategy.java}} — CC=147, 141
- {{core/camel-support/.../MessageHelper.java}} — CC=116
- {{core/camel-base-engine/.../IntrospectionSupport.java}} — CC=140
- {{core/camel-base-engine/.../AbstractCamelContext.java}} — CC=101
- {{core/camel-support/.../PackageScanHelper.java}} — CC=133
- {{core/camel-core-model/.../BeanModelHelper.java}} — CC=119
- {{core/camel-api/.../ConfigurationPropertiesValidationResult.java}} — CC=101
- {{core/camel-core-languages/.../CollectionFunctionFactory.java}} — CC=141
- {{core/camel-core-languages/.../MiscFunctionFactory.java}} — CC=101
- {{core/camel-util/.../StringQuoteHelper.java}} — CC=108

*PR 1b — {{dsl/camel-jbang}} extreme cases*
- {{dsl/camel-jbang/camel-jbang-run/.../RunPipeline.java}} — CC=238
- {{dsl/camel-jbang/camel-jbang-run/.../Exporter.java}} — CC=165, 158
- {{dsl/camel-jbang/camel-jbang-core/.../ai/CatalogDocs.java}} — CC=157
- {{dsl/camel-jbang/camel-jbang-core/.../commands/Debug.java}} — CC=143, 104
- {{dsl/camel-jbang/camel-jbang-core/.../tui/SourceViewer.java}} — CC=122, 111
- {{dsl/camel-jbang/camel-jbang-core/.../ai/AuthoringTools.java}} — CC=117
- {{dsl/camel-jbang/camel-jbang-core/.../process/ListError.java}} — CC=120
- {{dsl/camel-jbang/camel-jbang-core/.../process/CamelRouteStatus.java}} — 
CC=119
- {{dsl/camel-jbang/camel-jbang-core/.../ai/EndpointChecks.java}} — CC=128
- {{dsl/camel-jbang/camel-jbang-core/.../ai/HeaderChecks.java}} — CC=103
- {{dsl/camel-jbang/camel-jbang-core/.../commands/DependencyList.java}} — CC=111
- {{dsl/camel-jbang/camel-jbang-core/.../process/ListHealth.java}} — CC=110
- {{dsl/camel-jbang/camel-jbang-core/.../common/SemanticResultFormatter.java}} 
— CC=101
- 
{{dsl/camel-jbang/camel-jbang-core/.../commands/action/MessageTableHelper.java}}
 — CC=130
- {{dsl/camel-cli-connector/.../LocalCliConnector.java}} — CC=210, 119
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/SendMessagePopup.java}} — 
CC=115, 104
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/SemanticTab.java}} — CC=113
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/EndpointsTab.java}} — CC=109
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/OverviewTab.java}} — CC=106
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/ActionsPopup.java}} — CC=101
- {{dsl/camel-jbang/camel-jbang-plugin-tui/.../tui/Timeline.java}} — CC=105
- {{dsl/camel-kamelet-main/.../BlueprintXmlBeansHandler.java}} — CC=101

*PR 1c — {{components/}} extreme cases*
- {{components/camel-openapi-java/.../RestOpenApiReader.java}} — CC=242
- {{components/camel-bindy/.../BindyKeyValuePairFactory.java}} — CC=142
- {{components/camel-http/.../HttpProducer.java}} — CC=104, 101
- {{components/camel-mllp/.../MllpTcpServerConsumer.java}} — CC=105
- 
{{components/camel-rest-openapi/.../DefaultRestOpenapiProcessorStrategy.java}} 
— CC=111
- {{components/camel-olingo2/.../UriInfoWithType.java}} — CC=105

*PR 1d — {{tooling/}} extreme cases*
- 
{{tooling/maven/camel-package-maven-plugin/.../EndpointSchemaGeneratorMojo.java}}
 — CC=135, 105

*PR 1e — {{dsl/camel-yaml-dsl}} extreme cases*
- {{dsl/camel-yaml-dsl/.../YamlRoutesBuilderLoader.java}} — CC=163
- {{dsl/camel-yaml-dsl/.../GenerateYamlDeserializersMojo.java}} — CC=102

*PR 1f — {{catalog/}} extreme cases*
- {{catalog/camel-route-parser/.../CamelJavaRestDslParserHelper.java}} — CC=105

---

h3. Wave 2 — Bulk cleanup by module (complexity 31–100, ~625 issues, ~350h)

More mechanical refactoring. One PR per major module to keep diffs reviewable:

- *PR 2a* — {{core/}} (622 issues total across all core modules)
- *PR 2b* — {{dsl/camel-jbang/camel-jbang-plugin-tui}} (539 issues)
- *PR 2c* — {{dsl/camel-jbang/camel-jbang-core}} (428 issues)
- *PR 2d* — {{components/camel-ai}} + {{components/camel-aws}} (208 issues, 
cloud/AI theme)
- *PR 2e* — remaining {{components/}} by family (HTTP, messaging, data formats, 
etc.)
- *PR 2f* — {{tooling/}} + {{catalog/}}

---

h3. Wave 3 — Low-hanging fruit (complexity 16–30, ~2,152 issues)

Mostly mechanical "extract one helper method" fixes. Can be done by component 
family or batched by contributor interest. Each contributor can filter the 
attached CSV by file path prefix to self-assign a module.

---

h3. Conventions for all PRs

- Title format: {{CAMEL-20206: Reduce cognitive complexity in <module>}}
- Reference this JIRA in every PR title so changes auto-link here
- Keep each PR to a single module or logical area
- Do not mix waves in a single PR (extreme + bulk makes diff review impossible)

_Note: written by an AI coding agent based on SonarCloud data as of 2026-11-24._

> Cleanup overly complex methods
> ------------------------------
>
>                 Key: CAMEL-20206
>                 URL: https://issues.apache.org/jira/browse/CAMEL-20206
>             Project: Camel
>          Issue Type: Task
>          Components: came-core, camel-catalog, dsl, tooling
>            Reporter: Otavio Rodolfo Piske
>            Assignee: Guillaume Nodet
>            Priority: Major
>              Labels: help-wanted
>             Fix For: 4.x
>
>         Attachments: sonar_s3776_camel_complexity.csv
>
>
> We have a large incidence of [excessively complex 
> methods|https://sonarcloud.io/project/issues?resolved=false&rules=java%3AS3776&id=apache_camel].
> Problems with excessively long and complex methods:
> * [makes the code much harder to 
> maintain|https://martinfowler.com/bliki/FunctionLength.html]
> * reduce community ability to step in and provide easy fixes 
> * [increases the cognitive effort to read code by quickly exhausting the 
> limits of a human short term memory 
> |https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two]
> * reduce the JIT compiler ability to optimize code by inlining because the 
> generated code is larger than 325 bytes. 
> * lead to poor reuse and duplication of code 
> We should start by breaking down this complex code and, in the future, apply 
> proper design to it.
> The components catalog, tooling and dsl are specifically bad for this. 



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to