Reduce cognitive complexity in client and Jackson code#24
Reduce cognitive complexity in client and Jackson code#24sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZZmth6y2HDYqP_XynxM for java:S3776 rule - AZZmtiC92HDYqP_Xyn2H for java:S1192 rule - AZZmth2O2HDYqP_Xynvj for java:S3776 rule - AZZmthz_2HDYqP_Xyntj for java:S3776 rule - AZZmth912HDYqP_XynzY for java:S3776 rule Generated by SonarQube Agent (task: ec7c10b5-c52f-4ac6-96b0-824b7ec02fb0)
|
|
SonarQube reviewer guideSummary: Large-scale refactoring across multiple modules to improve code maintainability through method extraction and increased testability, with no functional changes to the public API. Review Focus: These are significant refactorings that break down complex methods into smaller, focused helper methods. Pay particular attention to:
Start review at:
|




Refactored several oversized methods into smaller helpers across the C# and Java XML clients and Jackson modules, and replaced repeated PHP JSON client type literals with shared constants. This lowers SonarQube cognitive complexity and duplication warnings, making the code easier to read, test, and maintain.
View Project in SonarCloud
Fixed Issues
java:S3776 - Refactor this method to reduce its Cognitive Complexity from 123 to the 15 allowed. • CRITICAL • View issue
Location:
csharp-xml-client/src/main/java/com/webcohesion/enunciate/modules/csharp_client/CSharpXMLClientModule.java:190Why is this an issue?
Cognitive Complexity is a measure of how hard it is to understand the control flow of a unit of code. Code with high cognitive complexity is hard to read, understand, test, and modify.
What changed
This hunk turns the top-level method into a simple coordinator: it now delegates the JAX-WS checks and JAXB checks to separate helper methods and returns the accumulated result. That directly helps address the reported excessive cognitive complexity by removing large blocks of nested logic from the flagged method.
java:S3776 - Refactor this method to reduce its Cognitive Complexity from 130 to the 15 allowed. • CRITICAL • View issue
Location:
java-xml-client/src/main/java/com/webcohesion/enunciate/modules/java_xml_client/JavaXMLClientModule.java:146Why is this an issue?
Cognitive Complexity is a measure of how hard it is to understand the control flow of a unit of code. Code with high cognitive complexity is hard to read, understand, test, and modify.
What changed
This hunk starts extracting setup and control-flow work out of the oversized source-generation method. It moves facet-filter creation into a helper call, keeps the up-to-date check at the top level, and delegates the heavy generation logic to a new method. That directly helps the reported excessive cognitive complexity problem by reducing branching and nesting in the original method.
java:S3776 - Refactor this method to reduce its Cognitive Complexity from 161 to the 15 allowed. • CRITICAL • View issue
Location:
jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/api/impl/DataTypeExampleImpl.java:138Why is this an issue?
Cognitive Complexity is a measure of how hard it is to understand the control flow of a unit of code. Code with high cognitive complexity is hard to read, understand, test, and modify.
What changed
This hunk starts extracting logic out of the overly complex
buildmethod by replacing nested type-id and override handling with helper method calls. That directly helps address the reported excessive cognitive complexity by flattening control flow and making the main method easier to read.java:S3776 - Refactor this method to reduce its Cognitive Complexity from 85 to the 15 allowed. • CRITICAL • View issue
Location:
jackson/src/main/java/com/webcohesion/enunciate/modules/jackson/model/types/JsonTypeFactory.java:49Why is this an issue?
Cognitive Complexity is a measure of how hard it is to understand the control flow of a unit of code. Code with high cognitive complexity is hard to read, understand, test, and modify.
What changed
This hunk starts refactoring the overly complex method by removing the inlined Accessor-specific logic and delegating it to a new helper,
findSpecifiedType(accessor, context). That directly helps with the reported excessive cognitive complexity because the main method now has less branching and nesting, while preserving the same early-return behavior when a specific type is found.java:S1192 - Define a constant instead of duplicating this literal "String" 17 times. • CRITICAL • View issue
Location:
php-json-client/src/main/java/com/webcohesion/enunciate/modules/php_json_client/ClientClassnameForMethod.java:67Why is this an issue?
Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.
What changed
This hunk introduces shared constants for repeated type-name literals such as String, Boolean, Integer, Object, and Array. It is the foundation of the fix for the duplicated string literal code smell because later hunks can now reference a single definition instead of repeating the same text throughout the class.
SonarQube Remediation Agent uses AI. Check for mistakes.