Skip to content

Simplify creating content from a blueprint programmatically#19528

Merged
lauraneto merged 11 commits into
mainfrom
v16/bugfix/19352-creating-content-from-blueprints-programatically
Jun 24, 2025
Merged

Simplify creating content from a blueprint programmatically#19528
lauraneto merged 11 commits into
mainfrom
v16/bugfix/19352-creating-content-from-blueprints-programatically

Update tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Service…

4c0feed
Select commit
Loading
Failed to load commit list.
CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main) failed Jun 23, 2025 in 58s

CodeScene PR Check

Quality Gate Failed

Code Health Improved (1 files improve in Code Health)

Gates Failed
Enforce advisory code health rules (2 files with Complex Method, String Heavy Function Arguments)

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Reason for failure
Enforce advisory code health rules Violations Code Health Impact
ContentBlueprintEditingServiceTests.GetScaffold.cs 1 advisory rule 10.00 → 9.69 Suppress
DataTypeBuilder.cs 1 advisory rule 9.64 → 9.39 Suppress
View Improvements
File Code Health Impact Categories Improved
ContentService.cs no change Bumpy Road Ahead, Overall Code Complexity
ElementSwitchValidatorTests.cs 8.82 → 9.69 Code Duplication, Primitive Obsession

Quality Gate Profile: Clean Code Collective
Want more control? Customize Code Health rules or catch issues early with our IDE extension and CLI tool.

Details

🚩 Declining Code Health (highest to lowest):

  • String Heavy Function Arguments ContentBlueprintEditingServiceTests.GetScaffold.cs
  • Complex Method DataTypeBuilder.cs: CreateSimpleElementDataType

✅ Improving Code Health:

  • Overall Code Complexity ContentService.cs 🔥
  • Bumpy Road Ahead ContentService.cs: CreateContentFromBlueprint 🔥
  • Code Duplication ElementSwitchValidatorTests.cs
  • Primitive Obsession ElementSwitchValidatorTests.cs

Annotations

Check notice on line 3681 in src/Umbraco.Core/Services/ContentService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Bumpy Road Ahead

CreateContentFromBlueprint is no longer above the threshold for logical blocks with deeply nested code. The Bumpy Road code smell is a function that contains multiple chunks of nested conditional logic. The deeper the nesting and the more bumps, the lower the code health.

Check notice on line 1 in src/Umbraco.Core/Services/ContentService.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Overall Code Complexity

The mean cyclomatic complexity decreases from 4.14 to 4.10, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.

Check warning on line 205 in tests/Umbraco.Tests.Common/Builders/DataTypeBuilder.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: Complex Method

CreateSimpleElementDataType has a cyclomatic complexity of 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.

Check notice on line 1 in tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Code Duplication

The module no longer contains too many functions with similar structure

Check notice on line 1 in tests/Umbraco.Tests.Integration/Umbraco.Core/Services/ElementSwitchValidatorTests.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

✅ No longer an issue: Primitive Obsession

The ratio of primivite types in function arguments is no longer above the threshold

Check warning on line 1 in tests/Umbraco.Tests.Integration/Umbraco.Infrastructure/Services/ContentBlueprintEditingServiceTests.GetScaffold.cs

See this annotation in the file changed.

@codescene-delta-analysis codescene-delta-analysis / CodeScene Cloud Delta Analysis (main)

❌ New issue: String Heavy Function Arguments

In this module, 40.0% of all arguments to its 9 functions are strings. The threshold for string arguments is 39.0%. The functions in this file have a high ratio of strings as arguments. Avoid adding more.