{"results":{"result":{"added-files":{"code-health":7.325861446783724,"old-code-health":0.0,"files":[{"file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentTypeEditingServiceTests.ChangeTypes.cs","loc":395,"code-health":7.325861446783724}]},"external-review-url":"https://github.com/umbraco/Umbraco-CMS/pull/22223","old-code-health":6.322407848130312,"modified-files":{"code-health":6.552032427765379,"old-code-health":6.322407848130312,"files":[{"file":"src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs","loc":1140,"old-loc":1105,"code-health":6.6250938381303826,"old-code-health":6.3428605361519885},{"file":"src/Umbraco.Core/Cache/Refreshers/Implement/ContentTypeCacheRefresher.cs","loc":164,"old-loc":160,"code-health":9.165459089768378,"old-code-health":9.165459089768378},{"file":"src/Umbraco.PublishedCache.HybridCache/NotificationHandlers/CacheRefreshingNotificationHandler.cs","loc":120,"old-loc":118,"code-health":9.387218218812514,"old-code-health":9.387218218812514},{"file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentTypeEditingServiceTests.Update.cs","loc":1190,"old-loc":1189,"code-health":4.89863564332771,"old-code-health":4.901110662793598},{"file":"tests/Umbraco.Tests.UnitTests/Umbraco.Core/Extensions/ContentTypeChangeExtensionsTests.cs","loc":113,"old-loc":28,"code-health":10.0,"old-code-health":10.0},{"file":"src/Umbraco.Core/Models/ContentTypeCompositionBase.cs","loc":256,"old-loc":244,"code-health":9.387218218812514,"old-code-health":9.387218218812514}]},"removed-files":{"code-health":0.0,"old-code-health":0.0,"files":[]},"external-review-id":"22223","analysis-time":"2026-03-27T07:38:56Z","negative-impact-count":5,"suppressions":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"affected-hotspots":0,"commits":["9963cd3a58dff6251dbc1e5d30ffe8ce2cf5b3f2","e58b27ae37a45c9d4fe3e018d82a163720f99982","d92052ee827f9de8fe7f9e9fe8c124dac14927ef","d4a3142c21b0b11a943fe2bd17838f3647d0ffe4","dff706d47292a3dfbbafd24f54d449f0b72e214b","868d14b65aec5528a6cca2b807b79aa5187ae996","da7d4b85adb776de2c1b36224357282bf7c77de5","0ff26aba4abda96c2f857e33dcb28ad4790c221f","64073823b466cd4d71a9b5d9bff9caa15e5b0695"],"is-negative-review":true,"negative-findings":{"number-of-types":5,"number-of-files-touched":3,"findings":[{"method":"ComposeContentTypeChanges","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.Core/Services/ContentTypeServiceBase{TRepository,TItem}.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":343,"what-changed":"ComposeContentTypeChanges increases in cyclomatic complexity from 14 to 20, 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":"degraded"},{"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/Umbraco.Core/Services/ContentTypeEditingServiceTests.ChangeTypes.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":15,"what-changed":"The module contains 7 functions with similar structure: Add_Property_Emits_PropertyAdded,Change_Alias_Emits_AliasChanged,Change_ContentType_Variation_Emits_VariationChanged_And_RefreshMain,Multiple_Structural_Changes_Emit_Combined_Flags and 3 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.Integration/Umbraco.Core/Services/ContentTypeEditingServiceTests.ChangeTypes.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":346,"what-changed":"The test suite contains 4 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":"Just like duplicated logic in application code is problematic, duplicated test criteria lead to code that's hard to maintain. Duplicated assertion blocks usually indicate a missing abstraction or a test suite that attempts to test too many things inside the same module.","name":"Duplicated Assertion Blocks","file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentTypeEditingServiceTests.ChangeTypes.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":346,"what-changed":"The test suite contains 13 functions with duplicated assertion blocks (Add_Composition_Emits_CompositionAdded,Add_Property_Emits_PropertyAdded,Change_Alias_Emits_AliasChanged,Change_ContentType_Variation_Emits_VariationChanged_And_RefreshMain and 9 more functions), threshold = 2","how-to-fix":"Consider to encapsulate the duplicated assertions (i.e. test criteria) in a custom assert statement that you can then re-use. We also recommend to consider the granularity of the tests; sometimes a single test tests too many things; extracting smaller tests can usually help you get rid of the duplication.","change-type":"introduced"},{"method":"Can_Move_Properties_To_Another_Container","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/Umbraco.Core/Services/ContentTypeEditingServiceTests.Update.cs","refactoring-examples":null,"change-level":"warning","is-hotspot?":false,"line":571,"what-changed":"Can_Move_Properties_To_Another_Container increases from 95 to 96 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"}]},"positive-impact-count":3,"repo":"Umbraco-CMS","code-health":6.6425186511260215,"version":"3.0","authors":["kjac","Kenn Jacobsen"],"directives":{"added":[],"removed":[]},"positive-findings":{"number-of-types":3,"number-of-files-touched":2,"findings":[{"method":"ComposeContentTypeChanges","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/ContentTypeServiceBase{TRepository,TItem}.cs","change-level":"improvement","is-hotspot?":false,"line":343,"what-changed":"ComposeContentTypeChanges decreases from 3 to 2 logical blocks with deeply nested code, 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":"improved"},{"method":"ComposeContentTypeChanges","why-it-occurs":"Deep nested logic means that you have control structures like if-statements or loops inside other control structures. Deep nested logic increases the cognitive load on the programmer reading the code. The human working memory has a maximum capacity of 3-4 items; beyond that threshold, we struggle with keeping things in our head. Consequently, deep nested logic has a strong correlation to defects and accounts for roughly 20% of all programming mistakes.\n\nCodeScene measures the maximum nesting depth inside each function. The deeper the nesting, the lower the code health. The threshold for the C# language is  levels of nesting.","name":"Deep, Nested Complexity","file":"src/Umbraco.Core/Services/ContentTypeServiceBase{TRepository,TItem}.cs","change-level":"improvement","is-hotspot?":false,"line":343,"what-changed":"ComposeContentTypeChanges is no longer above the threshold for nested complexity depth","how-to-fix":"Occassionally, it's possible to get rid of the nested logic by [Replacing Conditionals with Guard Clauses](https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html).\n\nAnother viable strategy is to identify smaller building blocks inside the nested chunks of logic and extract those responsibilities into smaller, cohesive, and well-named functions. The [EXTRACT FUNCTION](https://refactoring.com/catalog/extractFunction.html) refactoring explains the steps.","change-type":"fixed"},{"name":"Code Duplication","file":"tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ContentTypeEditingServiceTests.Update.cs","change-type":"improved","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":"reduced similar code in: Can_Update_Alias,Can_Update_Variation"}]},"notices":{"number-of-types":0,"number-of-files-touched":0,"findings":[]},"external-review-provider":"GitHub"},"analysistime":"2026-03-27T07:38:56.000Z","project-name":"Umbraco-CMS","repository":"https://github.com/umbraco/Umbraco-CMS.git"}}