Skip to content

Commit

Permalink
Refactor use if-else instead of ternary when calling methods, remove …
Browse files Browse the repository at this point in the history
…unused list of flattened nodes when checking for the number of excluded ones #901
  • Loading branch information
NearW committed Sep 3, 2020
1 parent bc9dbe6 commit 3836bda
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions visualization/app/codeCharta/util/nodeDecorator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use strict"
import * as d3 from "d3"
import { HierarchyNode, hierarchy } from "d3"
import { hierarchy, HierarchyNode } from "d3"
import {
AttributeTypes,
AttributeTypeValue,
BlacklistItem,
BlacklistType,
CCFile,
CodeMapNode,
EdgeMetricCount,
EdgeMetricData,
KeyValuePair,
AttributeTypes,
AttributeTypeValue,
BlacklistType,
NodeMetricData,
EdgeMetricData
NodeMetricData
} from "../codeCharta.model"
import { CodeMapHelper } from "./codeMapHelper"
import ignore from "ignore"
Expand Down Expand Up @@ -53,18 +53,18 @@ export class NodeDecorator {

public static doesExclusionResultInEmptyMap(map: CodeMapNode, blacklist: BlacklistItem[]): boolean {
let excludedNodes = 0
const flattened = ignore()
const excluded = ignore()

for (const item of blacklist) {
const path = CodeMapHelper.transformPath(item.path)
item.type === BlacklistType.flatten ? flattened.add(path) : excluded.add(path)
if (item.type === BlacklistType.exclude) {
excluded.add(path)
}
}

const tree = hierarchy(map)
const desc = tree.descendants()

desc.map(node => {
tree.descendants().map(node => {
const path = CodeMapHelper.transformPath(node.data.path)
if (excluded.ignores(path) && CodeMapHelper.isLeaf(node.data)) {
excludedNodes++
Expand Down

0 comments on commit 3836bda

Please sign in to comment.