{"results":{"result":{"added-files":{"code-health":6.730739321068276,"old-code-health":0.0,"files":[{"file":"src/Umbraco.Cms.Api.Management/Controllers/Document/PatchDocumentController.cs","loc":64,"code-health":10.0},{"file":"src/Umbraco.Cms.Api.Management/Controllers/Document/PatchDocumentControllerBase.cs","loc":27,"code-health":10.0},{"file":"src/Umbraco.Cms.Api.Management/Factories/IDocumentEditingPresentationFactory.cs","loc":13,"old-loc":0,"code-health":10.0},{"file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","loc":1439,"code-health":4.528657539281287},{"file":"src/Umbraco.Cms.Api.Management/Patchers/DocumentPatcher.cs","loc":86,"code-health":9.663736664415227},{"file":"src/Umbraco.Cms.Api.Management/Patching/PatchEngine.cs","loc":101,"code-health":10.0},{"file":"src/Umbraco.Cms.Api.Management/Patching/PatchPathParser.cs","loc":140,"code-health":9.240656298427343},{"file":"src/Umbraco.Cms.Api.Management/Patching/PatchPathResolver.cs","loc":131,"code-health":9.378351454178384},{"file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchEngineTests.cs","loc":427,"code-health":8.545379580978913},{"file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchPathParserTests.cs","loc":182,"code-health":9.096655465156704},{"file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchPathResolverTests.cs","loc":129,"code-health":9.387218218812514}]},"external-review-url":"https://github.com/umbraco/Umbraco-CMS/pull/22104","old-code-health":8.796686607239556,"modified-files":{"code-health":8.909718307175602,"old-code-health":8.796686607239556,"files":[{"file":"src/Umbraco.Cms.Api.Management/Factories/DocumentEditingPresentationFactory.cs","loc":123,"old-loc":30,"code-health":10.0,"old-code-health":10.0},{"file":"src/Umbraco.Core/Services/ContentEditingService.cs","loc":293,"old-loc":293,"code-health":8.56135850160195,"old-code-health":8.56135850160195},{"file":"src/Umbraco.Cms.Api.Management/DependencyInjection/DocumentBuilderExtensions.cs","loc":30,"old-loc":28,"code-health":10.0,"old-code-health":10.0},{"file":"tests/Umbraco.Tests.Integration/ManagementApi/ManagementApiTest.cs","loc":184,"old-loc":175,"code-health":9.096655465156704,"old-code-health":9.096655465156704},{"file":"src/Umbraco.Cms.Api.Management/DependencyInjection/JsonBuilderExtensions.cs","loc":16,"old-loc":13,"code-health":10.0,"old-code-health":10.0},{"file":"src/Umbraco.Cms.Api.Management/DependencyInjection/UmbracoBuilderExtensions.cs","loc":99,"old-loc":95,"code-health":9.54361322135008,"old-code-health":9.56532928377569},{"file":"src/Umbraco.Cms.Api.Management/Services/JsonPatchService.cs","loc":19,"old-loc":19,"code-health":10.0,"old-code-health":10.0},{"file":"src/Umbraco.Infrastructure/Serialization/JsonBlockValueConverter.cs","loc":236,"old-loc":236,"code-health":7.664719178478142,"old-code-health":7.664719178478142},{"file":"tests/Umbraco.Tests.UnitTests/Umbraco.Core/PropertyEditors/ColorPickerPropertyValueEditorTests.cs","loc":58,"old-loc":59,"code-health":10.0,"old-code-health":10.0},{"file":"src/Umbraco.Cms.Api.Management/Controllers/Document/UpdateDocumentControllerBase.cs","loc":28,"old-loc":26,"code-health":10.0,"old-code-health":10.0}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"22104","analysis-time":"2026-04-08T08:09:00Z","negative-impact-count":17,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":0,"commits":["1496282b6e03e87bf2fb47f994496af455136388","90f55f3d10e20fe8cb9b6a2273731274366f394f","6e246f1ad1c87df62a5a806b69113970afdd48ba","ab7514ebcb1fac1caf2558a273a04b394fb37e93","cfc1bd919d07e3cd931e893366206ddc51e34287","6a31bc256e1a6bf62f1c067f82c89a6a6297d7f0","f27f536f77083571c843d4a731d74b73d9daefd6","1bff7a3b54962d65a954fc3dcf1bf57e64293e18","9d2b26f1ffb1b772489bea36e3155bf85395b7f9","07a1c0187f572f1f2c86c21637362854fe46a774","24eff6063a8a6cb8be69f7b6ea63e0997d9ed515","f6159801f05ba689c66f3336ebec4c1f22bcc01c","1a03c1219ec7ed52ca2141ab342c0f86f7bb3820","83a60bd09c832dd7737650548755821bf6f7e2c9","746cecedc1d5dacdb5768ceb56c949339c372305","4501d21429d9468b5f9ec31ace59f9b8186562c0","9e9fde6ac6ca2460181cca4d2004224805bb224a","cbec75925d42f3343d839de5c4a1704e3e6178ce","c2f1eee9e391330b05e26aacb54fd030160d1d1b","6e00a16f16a664c6bc71bb9c67d8eea8d1b55d29","7a9847b3e5ec9d49b27690d14a8e98bf78f811eb","19ba6dee1ab78e09d9c7af8a8605f8329c7ec468","632954a30b8a2d550123fe4ad3673c766514fa92","59175dda004099bf255312c454a30a958b697cb1","54a2edb25751a424206e932fab1a07d6fcbc1138","2127de8ae6c9d1c3ac64226731e3037dbc6245cf","5eedb379e58920cffce0bd74e8d849936493ea88","03a743c165c0b5adeb09fd34f67c1bcc09004ab7","b7321f9dd6d32d5684b7538e8de29ab61cfc183f","8806113171f63905175ab487144a5524b382a330","da1cacc8665a2c4fe8bd708439df7ab58cc75067","c398646a2fdf125d115b1aef7f768529a7aeff37","c2b01b82b5ce7bdfb6256f506b5c3df22412b17a","1cacb390759110b10aeefea8e0f63b23cf6123c4","39c266c27c9be309031c3901f3523a0ad97406a1","ba217678003972bffec42d7d79bc27ebce1b5974","202595119065547386a5b01c97f97dd3d54e82bc","33f1ef19041ef046411552537740ee6590eff7ab","7e1111fa0305d6c260b794bc903f7b799012c8b0","e8c55ad948bb9ed3a0b029a64ab7c64cebad12e8","93a439b060e1a003f52be8ec787568e33d50f398","cf5043c69ab96d57713462b9fec7dcec54b871ca"],"is-negative-review":true,"negative-findings":{"number-of-types":9,"number-of-files-touched":8,"findings":[{"why-it-occurs":"This module has 1373 lines of code (comments stripped away). This puts the module at risk of evolving into a Brain Class. Brain Classes are problematic since changes become more complex over time, harder to test, and challenging to refactor. Act now to prevent future maintenance issues.","name":"Lines of Code in a Single File","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"what-changed":"This module has 1373 lines of code, improve code health by reducing it to 1000","how-to-fix":"Look for opportunities to modularize the design. This is done by identifying groups of functions that represent different responsibilities and/or operate on different data. Once you have identified the different responsibilities, then use refactorings like [EXTRACT CLASS](https://refactoring.com/catalog/extractClass.html).","change-type":"introduced"},{"why-it-occurs":"Cohesion is a measure of how well the elements in a file belong together. CodeScene measures cohesion using the LCOM4 metric (Lack of Cohesion Measure). With LCOM4, the functions inside a module are related if a) they access the same data members, or b) they call each other. High Cohesion is desirable as it means that all functions are related and likely to represent the same responsibility. Low Cohesion is problematic since it means that the module contains multiple behaviors. Low Cohesion leads to code that's harder to understand, requires more tests, and very often become a coordination magnet for developers.","name":"Low Cohesion","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":[{"diff":"diff --git a/low_cohesion_example.js b/low_cohesion_example.js\nindex 1ae56cf85b..209fc02c73 100644\n--- a/low_cohesion_example.js\n+++ b/low_cohesion_example.js\n@@ -2,8 +2,10 @@\n \n var userLayer = connectUsers(myConnectionProperties);\n \n-var chessEngine = startEngine(gameProperties);\n+// [Refactoring: moved the data related to chess to a new chessGame.js module]\n \n+// The module contains login related functionality that forms one behaviour: all\n+// code is related since it either a) uses the same data, or b) calls the same functions.\n export function login(newUser) {\n   val authenticated = userLayer.authenticate(newUser);\n   traceLoginFor(authenticated);\n@@ -19,11 +21,6 @@ function traceLogin(user) {\n    // ...some code...\n }\n \n-// playChess seems like a very unrelated responsibility.\n-// Should it really be within the same module?\n-\n-export function playChess(loggedInUser) {\n-   var board = chessEngine.newBoard();\n-\n-   return newGameOn(board, loggedInUser);\n-}\n+// [Refactoring: moved playChess to a new chessGame.js module\n+// As a result of this refactoring, the module maintains a\n+// single behavior where all code and data is related: high cohesion.]\n","language":"c#","improvement-type":"Low Cohesion"}],"change-level":"warning","is-hotspot?":false,"what-changed":"This module has at least 15 different responsibilities amongst its 19 functions, threshold = 3","how-to-fix":"Look to modularize the code by splitting the file into more cohesive units; functions that belong together should still be located together. A common refactoring is [EXTRACT CLASS](https://refactoring.com/catalog/extractClass.html).","change-type":"introduced"},{"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.","name":"Code Duplication","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":125,"what-changed":"The module contains 12 functions with similar structure: PatchDocument_BlockList_AddBlock_AppendsToExistingBlockList,PatchDocument_BlockList_SingleBlock_UpdatesSingleProperty,PatchDocument_DeeplyNestedBlocks_AddsBlockToNestedBlockList,PatchDocument_DeeplyNestedBlocks_InsertsBlockAtSpecificPosition and 8 more functions","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.","change-type":"introduced"},{"name":"Overall Function Size","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","change-type":"introduced","change-level":"warning","is-hotspot?":false,"what-changed":"The median function size in this module is 57.0 LOC, threshold = 50.0","refactoring-examples":null},{"method":"CreateDeeplyNestedBlockDocument","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the C# language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":1211,"what-changed":"CreateDeeplyNestedBlockDocument has 307 lines, threshold = 70","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","change-type":"introduced"},{"method":"PatchDocument_BlockList_AddBlock_AppendsToExistingBlockList","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the C# language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":993,"what-changed":"PatchDocument_BlockList_AddBlock_AppendsToExistingBlockList has 169 lines, threshold = 70","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","change-type":"introduced"},{"method":"PatchDocument_BlockList_SingleBlock_UpdatesSingleProperty","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the C# language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"tests/Umbraco.Tests.Integration/ManagementApi/Document/PatchDocumentControllerTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":784,"what-changed":"PatchDocument_BlockList_SingleBlock_UpdatesSingleProperty has 166 lines, threshold = 70","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","change-type":"introduced"},{"method":"ApplyPatchAsync","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":"src/Umbraco.Cms.Api.Management/Patchers/DocumentPatcher.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":35,"what-changed":"ApplyPatchAsync has a cyclomatic complexity of 12, 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"},{"method":"AddUmbracoManagementApi","why-it-occurs":"Overly long functions make the code harder to read. The recommended maximum function length for the C# language is 70 lines of code. Severity: Brain Method - Complex Method - Long Method.","name":"Large Method","file":"src/Umbraco.Cms.Api.Management/DependencyInjection/UmbracoBuilderExtensions.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":25,"what-changed":"AddUmbracoManagementApi increases from 78 to 82 lines of code, threshold = 70","how-to-fix":"We recommend to be careful here -- just splitting long functions don't necessarily make the code easier to read. Instead, look for natural chunks inside the functions that expresses a specific task or concern. Often, such concerns are indicated by a Code Comment followed by an if-statement. Use the [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring to encapsulate that concern.","change-type":"degraded"},{"method":"Parse","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":"src/Umbraco.Cms.Api.Management/Patching/PatchPathParser.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":34,"what-changed":"Parse has a cyclomatic complexity of 16, 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"},{"method":"Parse","why-it-occurs":"A complex conditional is an expression inside a branch such as an <code>if</code>-statmeent which consists of multiple, logical operations. Example: <code>if (x.started() && y.running())</code>.Complex conditionals make the code even harder to read, and contribute to the Complex Method code smell. Encapsulate them.","name":"Complex Conditional","file":"src/Umbraco.Cms.Api.Management/Patching/PatchPathParser.cs","refactoring-examples":[{"diff":"diff --git a/complex_conditional.js b/complex_conditional.js\nindex c43da09584..94259ce874 100644\n--- a/complex_conditional.js\n+++ b/complex_conditional.js\n@@ -1,16 +1,34 @@\n function messageReceived(message, timeReceived) {\n-   // Ignore all messages which aren't from known customers:\n-   if (!message.sender &&\n-       customers.getId(message.name) == null) {\n+   // Refactoring #1: encapsulate the business rule in a\n+   // function. A clear name replaces the need for the comment:\n+   if (!knownCustomer(message)) {\n      log('spam received -- ignoring');\n      return;\n    }\n \n-  // Provide an auto-reply when outside business hours:\n-  if ((timeReceived.getHours() > 17) ||\n-      (timeReceived.getHours() < 8)) {\n+  // Refactoring #2: encapsulate the business rule.\n+  // Again, note how a clear function name replaces the\n+  // need for a code comment:\n+  if (outsideBusinessHours(timeReceived)) {\n     return autoReplyTo(message);\n   }\n \n   pingAgentFor(message);\n+}\n+\n+function outsideBusinessHours(timeReceived) {\n+  // Refactoring #3: replace magic numbers with\n+  // symbols that communicate with the code reader:\n+  const closingHour = 17;\n+  const openingHour = 8;\n+\n+  const hours = timeReceived.getHours();\n+\n+  // Refactoring #4: simple conditional rules can\n+  // be further clarified by introducing a variable:\n+  const afterClosing = hours > closingHour;\n+  const beforeOpening = hours < openingHour;\n+\n+  // Yeah -- look how clear the business rule is now!\n+  return afterClosing || beforeOpening;\n }\n\\ No newline at end of file\n","language":"c#","improvement-type":"Complex Conditional"}],"change-level":"warning","is-hotspot?":false,"line":62,"what-changed":"Parse has 1 complex conditionals with 2 branches, threshold = 2","how-to-fix":"Apply the [DECOMPOSE CONDITIONAL](https://refactoring.com/catalog/decomposeConditional.html) refactoring so that the complex conditional is encapsulated in a separate function with a good name that captures the business rule. Optionally, for simple expressions, introduce a new variable which holds the result of the complex conditional.","change-type":"introduced"},{"method":"Parse","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.Cms.Api.Management/Patching/PatchPathParser.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":34,"what-changed":"Parse has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function","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":"introduced"},{"method":"Resolve","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":"src/Umbraco.Cms.Api.Management/Patching/PatchPathResolver.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":17,"what-changed":"Resolve has a cyclomatic complexity of 17, 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"},{"method":"MatchesAllConditions","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.Cms.Api.Management/Patching/PatchPathResolver.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":132,"what-changed":"MatchesAllConditions has 2 blocks with nested conditional logic. Any nesting of 2 or deeper is considered. Threshold is 2 blocks per function","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":"introduced"},{"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.","name":"Code Duplication","file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchEngineTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":13,"what-changed":"The module contains 14 functions with similar structure: Add_InsertAtIndex_InsertsElement,Add_NewObjectProperty_AddsProperty,Remove_ArrayElementByFilter_RemovesElement,Remove_ArrayElementByIndex_RemovesElement and 10 more functions","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.","change-type":"introduced"},{"why-it-occurs":"Measures the number of lines with consecutive assert statements in a unit test. The more consecutive assert statements, the lower the code health. The threshold for the C# language is 4 consecutive lines of assert statements.","name":"Large Assertion Blocks","file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchPathParserTests.cs","refactoring-examples":[{"diff":"diff --git a/large_assertion_block_example.js b/large_assertion_block_example.js\nindex a518da697a..d25c43e013 100644\n--- a/large_assertion_block_example.js\n+++ b/large_assertion_block_example.js\n@@ -1,9 +1,11 @@\n test('T-1000 automatically repairs when damaged', () => {\n     robT1000.heal();\n \n-    assert.equal(100, robT1000.cpuCapacity);\n-    assert.isOk(robT1000.ramCheckPasses;\n-    assert.isOK(robT1000.diskAccessible);\n-    assert.equal(100, robT1000.vision);\n-    assert.equal(CONSTANTS.FUNCTIONAL, robT1000.equipment);\n+    // Replace the low-level assertions with a custom assert that lets\n+    // us communicate in the language of our domain. Also encapsulates\n+    // the criteria so that we only have one place to change if/when\n+    // more properties are added.\n+    // Most test frameworks and assertion libraries have support for\n+    // custom asserts.\n+    assert.fullyOperational(robT1000);\n }\n","language":"c#","improvement-type":"Large Assertion Blocks"}],"change-level":"warning","is-hotspot?":false,"line":29,"what-changed":"The test suite contains 6 assertion blocks with at least 4 assertions, threshold = 4","how-to-fix":"Consider to encapsulate the assertions (i.e. test criteria) in a custom assert statement. This simplifies the test by letting you communicate the test criteria in the language of your domain.  We also recommend to consider the granularity of the tests; sometimes a single test tests too many things; extracting smaller tests often help to simplify the test criteria. Finally, large assertion blocks can also signal missing functionality in the code under test: instead of fetching and comparing individual properties of an object, maybe that class should encapsulate what equality means in an Equals() method?","change-type":"introduced"},{"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.","name":"Code Duplication","file":"tests/Umbraco.Tests.UnitTests/Umbraco.Cms.Api.Management/Patching/PatchPathResolverTests.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":10,"what-changed":"The module contains 6 functions with similar structure: Resolve_FilterWithBooleanFalseValue_MatchesElement,Resolve_FilterWithBooleanValue_MatchesElement,Resolve_FilterWithDecimalValue_MatchesElement,Resolve_FilterWithMixedStringAndNumericConditions_MatchesElement and 2 more functions","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.","change-type":"introduced"}]},"positive-impact-count":0,"repo":"Umbraco-CMS","code-health":7.349398452810121,"version":"3.0","authors":["Sven Geusens"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2026-04-08T08:09:00.000Z","project-name":"Umbraco-CMS","repository":"https://github.com/umbraco/Umbraco-CMS.git"}}