{"results":{"result":{"added-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-url":"https://github.com/umbraco/Umbraco-CMS/pull/19528","old-code-health":4.17279317954644,"modified-files":{"code-health":4.383319656532666,"old-code-health":4.17279317954644,"files":[{"file":"src/Umbraco.Core/Services/ContentBlueprintEditingService.cs","loc":204,"old-loc":203,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"src/Umbraco.Core/Services/ContentService.cs","loc":2495,"old-loc":2494,"code-health":2.3447291314452414,"old-code-health":2.3447291314452414},{"file":"src/Umbraco.Core/Services/IContentService.cs","loc":101,"old-loc":98,"code-health":10.0,"old-code-health":10.0},{"file":"tests/Umbraco.Tests.Common/Builders/DataTypeBuilder.cs","loc":221,"old-loc":135,"code-health":9.3931346077612,"old-code-health":9.636288422716657},{"file":"tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTestWithContent.cs","loc":52,"old-loc":51,"code-health":10.0,"old-code-health":10.0},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs","loc":246,"old-loc":326,"code-health":9.6882083290695,"old-code-health":8.816158827775617},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs","loc":247,"old-loc":53,"code-health":9.6882083290695,"old-code-health":10.0},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.cs","loc":86,"old-loc":84,"code-health":10.0,"old-code-health":10.0},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentServiceTests.cs","loc":2574,"old-loc":2574,"code-health":3.5419947626013197,"old-code-health":3.5419947626013197},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/TelemetryProviderTests.cs","loc":260,"old-loc":257,"code-health":9.096655465156704,"old-code-health":9.096655465156704}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"19528","analysis-time":"2025-06-23T08:09:09Z","negative-impact-count":2,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":1,"commits":["2da9d9b0b8480d92de433af6bb80f8f5bf642f41","94659db533e01947ca11786e27353635289ceaa4","f7b3de4857471044fb8ce9f1933cad32b7446be5","59fe3208235a00c235bda48318672b5cf88eb183","5d985ed0f878a47bd59885b86f9550b060cfa4bc","c6076956b7652305cc8cf31f82167aba49debdd3","136fe690c943baad6bcbb672589ef84ecaf61c77","69c0b8a53aae0be8178f9ca59a1817d4637402cb","00f2ba8828496547e50f7682b55f70ff458b83ad","a65579a56db36928a083828714d579f22654dd21","4c0feedbd30cc7d50f35dbb52df842252a83cf80"],"is-negative-review":true,"negative-findings":{"number-of-types":2,"number-of-files-touched":2,"findings":[{"method":"CreateSimpleElementDataType","why-it-occurs":"A Complex Method has a high cyclomatic complexity. The recommended threshold for the C# language is a cyclomatic complexity lower than 9.","name":"Complex Method","file":"tests/Umbraco.Tests.Common/Builders/DataTypeBuilder.cs","refactoring-examples":[{"diff":"diff --git a/complex_method.js b/complex_method.js\nindex 10cce78e6d..0c1a8cabaf 100644\n--- a/complex_method.js\n+++ b/complex_method.js\n@@ -1,15 +1,20 @@\n function postItem(item) {\n   if (!item.id) {\n-    if (item.x != null && item.y != null) {\n-      post(item);\n-    } else {\n-      throw Error(\"Item must have x and y\");\n-    }\n+    // extract a separate function for creating new item\n+    postNew(item);\n   } else {\n-    if (item.x < 10 && item.y > 25) {\n-      put(item);\n-    } else {\n-      throw Error(\"Item must have an x and y value between 10 and 25\");\n-    }\n+    // and one for updating existing items\n+    updateItem(item);\n   }\n }\n+\n+function postNew(item) {\n+  validateNew(item);\n+  post(item);\n+}\n+\n+function updateItem(item) {\n+  validateUpdate(item);\n+  put(item);\n+}\n+\n","language":"c#","improvement-type":"Complex Method"}],"change-level":"warning","is-hotspot?":false,"line":162,"what-changed":"CreateSimpleElementDataType has a cyclomatic complexity of 9, threshold = 9","how-to-fix":"There are many reasons for Complex Method. Sometimes, another design approach is beneficial such as a) modeling state using an explicit state machine rather than conditionals, or b) using table lookup rather than long chains of logic. In other scenarios, the function can be split using [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html). Just make sure you extract natural and cohesive functions. Complex Methods can also be addressed by identifying complex conditional expressions and then using the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring.","change-type":"introduced"},{"why-it-occurs":"String is a generic type that fail to capture the constraints of the domain object it represents. In this module, 40 % of all function arguments are string types.","name":"String Heavy Function Arguments","file":"tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"what-changed":"In this module, 40.0% of all arguments to its 9 functions are strings. The threshold for string arguments is 39.0%","how-to-fix":"Heavy string usage indicates a missing domain language. Introduce data types that encapsulate the semantics. For example, a user_name is better represented as a constrained User type rather than a pure string, which could be anything.","change-type":"introduced"}]},"positive-impact-count":4,"repo":"Umbraco-CMS","code-health":4.383319656532666,"version":"3.0","authors":["Laura Neto"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":4,"number-of-files-touched":2,"findings":[{"method":"CreateContentFromBlueprint","why-it-occurs":"A Bumpy Road is a function that contains multiple chunks of nested conditional logic inside the same function. The deeper the nesting and the more bumps, the lower the code health.\n\nA bumpy code road represents a lack of encapsulation which becomes an obstacle to comprehension. In imperative languages there’s also an increased risk for feature entanglement, which leads to complex state management. CodeScene considers the following rules for the code health impact: 1) The deeper the nested conditional logic of each bump, the higher the tax on our working memory. 2) The more bumps inside a function, the more expensive it is to refactor as each bump represents a missing abstraction. 3) The larger each bump – that is, the more lines of code it spans – the harder it is to build up a mental model of the function. The nesting depth for what is considered a bump is  levels of conditionals.","name":"Bumpy Road Ahead","file":"src/Umbraco.Core/Services/ContentService.cs","change-level":"improvement","is-hotspot?":true,"line":3657,"what-changed":"CreateContentFromBlueprint is no longer above the threshold for logical blocks with deeply nested code","how-to-fix":"Bumpy Road implementations indicate a lack of encapsulation. Check out the detailed description of the [Bumpy Road code health issue](https://codescene.com/blog/bumpy-road-code-complexity-in-context/).\n\nA Bumpy Road often suggests that the function/method does too many things. The first refactoring step is to identify the different possible responsibilities of the function. Consider extracting those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring is the primary response.","change-type":"fixed"},{"name":"Overall Code Complexity","file":"src/Umbraco.Core/Services/ContentService.cs","change-type":"improved","change-level":"improvement","is-hotspot?":true,"why-it-occurs":"Overall Code Complexity is measured by the mean cyclomatic complexity across all functions in the file. The lower the number, the better.\n\nCyclomatic complexity is a function level metric that measures the number of logical branches (if-else, loops, etc.). Cyclomatic complexity is a rough complexity measure, but useful as a way of estimating the minimum number of unit tests you would need. As such, prefer functions with low cyclomatic complexity (2-3 branches).","how-to-fix":"You address the overall cyclomatic complexity by a) modularizing the code, and b) abstract away the complexity. Let's look at some examples:\n\nModularizing the Code: Do an X-Ray and inspect the local hotspots. Are there any complex conditional expressions? If yes, then do a [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring. Extract the conditional logic into a separate function and put a good name on that function. This clarifies the intent and makes the original function easier to read. Repeat until all complex conditional expressions have been simplified.\n\n","what-changed":"The mean cyclomatic complexity decreases from 4.14 to 4.10, threshold = 4"},{"name":"Code Duplication","file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"Duplicated code often leads to code that's harder to change since the same logical change has to be done in multiple functions. More duplication gives lower code health.","how-to-fix":"A certain degree of duplicated code might be acceptable. The problems start when it is the same behavior that is duplicated across the functions in the module, ie. a violation of the Don't Repeat Yourself (DRY) principle. DRY violations lead to code that is changed together in predictable patterns, which is both expensive and risky. DRY violations can be identified using CodeScene's X-Ray analysis to detect clusters of change coupled functions with high code similarity. [Read More](https://codescene.com/blog/software-revolution-part3/)\n\nOnce you have identified the similarities across functions, look to extract and encapsulate the concept that varies into its own function(s). These shared abstractions can then be re-used, which minimizes the amount of duplication and simplifies change.","what-changed":"The module no longer contains too many functions with similar structure"},{"name":"Primitive Obsession","file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs","change-type":"fixed","change-level":"improvement","is-hotspot?":false,"why-it-occurs":"Code that uses a high degree of built-in, primitives such as integers, strings, floats, lacks a domain language that encapsulates the validation and semantics of function arguments. Primitive Obsession has several consequences: 1) In a statically typed language, the compiler will detect less erroneous assignments. 2) Security impact since the possible value range of a variable/argument isn't retricted.\n\nIn this module, 100 % of all functions have primitive types as arguments.","how-to-fix":"Primitive Obsession indicates a missing domain language. Introduce data types that encapsulate the details and constraints of your domain. For example, instead of `int userId`, consider `User clicked`.","what-changed":"The ratio of primivite types in function arguments is no longer above the threshold"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2025-06-23T08:09:08.000Z","project-name":"Umbraco-CMS","repository":"https://github.com/umbraco/Umbraco-CMS.git"}}