Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Delete all Summary 2.0 components that has a reference to deleted component #14126

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

mlqn
Copy link
Contributor

@mlqn mlqn commented Nov 21, 2024

Description

Delete all Summary 2.0 components that has a reference to deleted component

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

@github-actions github-actions bot added solution/studio/designer Issues related to the Altinn Studio Designer solution. backend labels Nov 21, 2024
mlqn added 4 commits November 27, 2024 13:42
…elete-all-summary-20-components-that-has-a-reference-to-deleted-element-component-page-or-layout-set
@github-actions github-actions bot added the quality/testing Tests that are missing, needs to be created or could be improved. label Nov 29, 2024
string layout = TestDataHelper.GetFileFromRepo(org, app, developer, $"App/ui/{layoutSetName}/layouts/{layoutName}.json");
JsonNode layoutWithDeletedComponent = JsonNode.Parse(layout);
JsonArray layoutArray = layoutWithDeletedComponent["data"]["layout"] as JsonArray;
layoutArray.RemoveAt(0);

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning test

Variable
layoutArray
may be null at this access because of
this
assignment.
Copy link

codecov bot commented Nov 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.36%. Comparing base (c71f649) to head (1920a7b).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14126   +/-   ##
=======================================
  Coverage   95.36%   95.36%           
=======================================
  Files        1797     1797           
  Lines       23367    23367           
  Branches     2703     2703           
=======================================
  Hits        22284    22284           
  Misses        836      836           
  Partials      247      247           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 41 to 45
foreach (JsonNode component in layoutArray)
{
string deletedId = component["id"]?.GetValue<string>();
deletedIds.Add(new Reference("component", notification.LayoutSetName, deletedId));
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Select Note

This foreach loop immediately
maps its iteration variable to another variable
- consider mapping the sequence explicitly using '.Select(...)'.
@@ -20,54 +20,35 @@
notification.EditingContext.Repo,
notification.EditingContext.Developer);

string[] layoutSetNames = altinnAppGitRepository.GetLayoutSetNames();
LayoutSets layoutSets = await altinnAppGitRepository.GetLayoutSetsFile(cancellationToken);

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This assignment to
layoutSets
is useless, since its value is never read.
Comment on lines +44 to +48
foreach (JsonNode component in layoutArray)
{
string deletedId = component["id"]?.GetValue<string>();
referencesToDelete.Add(new Reference("component", notification.LayoutSetName, deletedId));
}

Check notice

Code scanning / CodeQL

Missed opportunity to use Select Note

This foreach loop immediately
maps its iteration variable to another variable
- consider mapping the sequence explicitly using '.Select(...)'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend quality/testing Tests that are missing, needs to be created or could be improved. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant