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

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

h2. SonarCloud Analysis — Cognitive Complexity (java:S3776)

Extracted all open issues from SonarCloud for rule 
[java:S3776|https://sonarcloud.io/project/issues?id=apache_camel&rules=java%3AS3776&s=IMPACT_RANK&issueStatuses=OPEN%2CCONFIRMED]
 (Cognitive Complexity of methods should not be too high).

*Total: 3,095 open issues across 257 modules — ~1,054 hours estimated effort.*

---

h3. Complexity distribution

|| Range || Count ||
| 16–30 (just over threshold) | 2,152 |
| 31–50 (bad) | 624 |
| 51–100 (very bad) | 261 |
| >100 (extreme) | 58 |

---

h3. By area

|| Area || Issues || Max CC || Effort ||
| camel-jbang (DSL) | 1,061 | 238 | 388h |
| components | 1,110 | 242 | 305h |
| core | 622 | 245 | 247h |
| tooling | 137 | 135 | 51h |
| DSL (non-jbang) | 115 | 210 | 45h |
| catalog | 45 | 105 | 17h |

---

h3. Top modules by issue count

|| Module || Issues || Max CC || Effort ||
| dsl/camel-jbang/camel-jbang-plugin-tui | 539 | 122 | 190h |
| dsl/camel-jbang/camel-jbang-core | 428 | 157 | 162h |
| components/camel-ai | 105 | 63 | 24h |
| core/camel-support | 103 | 133 | 39h |
| components/camel-aws | 103 | 71 | 23h |
| tooling/maven | 98 | 135 | 34h |
| dsl/camel-yaml-dsl | 72 | 163 | 25h |
| core/camel-console | 69 | 83 | 25h |
| core/camel-core-processor | 58 | 86 | 20h |
| core/camel-base-engine | 57 | 140 | 24h |

---

h3. Worst individual methods (complexity > 100)

|| CC || File || Line || Effort ||
| 245 | {{core/camel-xml-io/.../MXParser.java}} | 1057 | 3h55min |
| 242 | {{components/camel-openapi-java/.../RestOpenApiReader.java}} | 546 | 
3h52min |
| 238 | {{dsl/camel-jbang/camel-jbang-run/.../RunPipeline.java}} | 386 | 
3h48min |
| 210 | {{dsl/camel-cli-connector/.../LocalCliConnector.java}} | 1699 | 3h20min 
|
| 166 | {{core/camel-core-catalog/.../AbstractCamelCatalog.java}} | 224 | 
2h36min |
| 165 | {{dsl/camel-jbang/camel-jbang-run/.../Exporter.java}} | 323 | 2h35min |
| 163 | {{dsl/camel-yaml-dsl/.../YamlRoutesBuilderLoader.java}} | 106 | 2h33min 
|
| 154 | {{core/camel-core-languages/.../StringFunctionFactory.java}} | 44 | 
2h24min |
| 149 | {{core/camel-core-model/.../RestDefinition.java}} | 1112 | 2h19min |
| 147 | {{core/camel-core-engine/.../DefaultDumpRoutesStrategy.java}} | 376 | 
2h17min |

---

The full list (3,095 issues) is attached as a CSV file (sorted by complexity 
descending).

_Note: data extracted from SonarCloud on 2026-11-24 by an AI coding agent._

> 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
>            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