Skip to content

Commit

Permalink
fix(ui): resolve sonar complexity warning
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Jan 23, 2025
1 parent e48d550 commit cb2d25c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions webapp/src/services/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,8 @@ export const buildModificationDate = (
return duration.locale(language.substring(0, 2) === "fr" ? "fr" : "en").humanize();
};

export const countAllChildrens = (tree: VariantTree): number => {
if (tree.children.length > 0) {
return tree.children.map((elm) => 1 + countAllChildrens(elm)).reduce((acc, curr) => acc + curr);
}
return 0;
};
export const countDescendants = (tree: VariantTree): number =>
tree.children.length ? tree.children.reduce((sum, child) => sum + 1 + countDescendants(child), 0) : 0;

export const findNodeInTree = (studyId: string, tree: VariantTree): VariantTree | undefined => {
if (studyId === tree.node.id) {
Expand Down

0 comments on commit cb2d25c

Please sign in to comment.