|
1
|
|
package com.depanalyzer.core.graph |
|
2
|
|
|
|
3
|
|
class DependencyGraph( |
|
4
|
|
rootNodes: List<DependencyNode> = emptyList() |
|
5
|
|
) { |
|
6
|
|
|
|
7
|
|
private val nodeIndex: MutableMap<String, DependencyNode> = mutableMapOf() |
|
8
|
|
|
|
9
|
|
init { |
|
10
|
|
rootNodes.forEach { node -> |
|
11
|
1
1. <init> : removed call to com/depanalyzer/core/graph/DependencyGraph::indexNode → KILLED
|
indexNode(node) |
|
12
|
|
} |
|
13
|
|
} |
|
14
|
|
|
|
15
|
|
private fun indexNode(node: DependencyNode) { |
|
16
|
|
nodeIndex[node.id] = node |
|
17
|
|
node.children.forEach { child -> |
|
18
|
1
1. indexNode : removed call to com/depanalyzer/core/graph/DependencyGraph::indexNode → SURVIVED
|
indexNode(child) |
|
19
|
|
} |
|
20
|
|
} |
|
21
|
|
|
|
22
|
|
private fun calculateMaxDepth(node: DependencyNode): Int { |
|
23
|
1
1. calculateMaxDepth : negated conditional → NO_COVERAGE
|
if (node.children.isEmpty()) return 0 |
|
24
|
6
1. calculateMaxDepth : changed conditional boundary → NO_COVERAGE
2. calculateMaxDepth : negated conditional → NO_COVERAGE
3. calculateMaxDepth : replaced int return with 0 for com/depanalyzer/core/graph/DependencyGraph::calculateMaxDepth → NO_COVERAGE
4. calculateMaxDepth : negated conditional → NO_COVERAGE
5. calculateMaxDepth : Replaced integer addition with subtraction → NO_COVERAGE
6. calculateMaxDepth : negated conditional → NO_COVERAGE
|
return 1 + node.children.maxOf { calculateMaxDepth(it) } |
|
25
|
|
} |
|
26
|
|
|
|
27
|
1
1. getAllNodes : replaced return value with Collections.emptyList for com/depanalyzer/core/graph/DependencyGraph::getAllNodes → KILLED
|
fun getAllNodes(): List<DependencyNode> = nodeIndex.values.toList() |
|
28
|
|
|
|
29
|
|
fun getAllVulnerableNodes(): List<DependencyNode> { |
|
30
|
1
1. getAllVulnerableNodes : replaced return value with Collections.emptyList for com/depanalyzer/core/graph/DependencyGraph::getAllVulnerableNodes → KILLED
|
return nodeIndex.values.filter { it.isVulnerable() } |
|
31
|
|
} |
|
32
|
|
|
|
33
|
|
private fun detectCycle(node: DependencyNode, visited: MutableSet<String>): Boolean { |
|
34
|
1
1. detectCycle : negated conditional → NO_COVERAGE
|
if (visited.contains(node.id)) { |
|
35
|
1
1. detectCycle : replaced boolean return with false for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
return true |
|
36
|
|
} |
|
37
|
|
visited.add(node.id) |
|
38
|
|
|
|
39
|
1
1. detectCycle : negated conditional → NO_COVERAGE
|
for (child in node.children) { |
|
40
|
1
1. detectCycle : negated conditional → NO_COVERAGE
|
if (detectCycle(child, visited.toMutableSet())) { |
|
41
|
1
1. detectCycle : replaced boolean return with false for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
return true |
|
42
|
|
} |
|
43
|
|
} |
|
44
|
|
|
|
45
|
1
1. detectCycle : replaced boolean return with true for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
return false |
|
46
|
|
} |
|
47
|
|
|
|
48
|
|
} |
| | Mutations |
| 11 |
|
1.1 Location : <init> Killed by : com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:detects cycles in dependency graph()] removed call to com/depanalyzer/core/graph/DependencyGraph::indexNode → KILLED
|
| 18 |
|
1.1 Location : indexNode Killed by : none removed call to com/depanalyzer/core/graph/DependencyGraph::indexNode → SURVIVED
Covering tests
Covered by tests:
- com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:detects cycles in dependency graph()]
- com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:builds graph with direct and transitive dependencies()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:handles circular references without infinite loops()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:classifies direct vulnerabilities correctly()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:deduplicates semantically identical chains()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:resolves 4-level chain correctly()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:handles diamond dependency with multiple paths()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:chains include all necessary information for reporting()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:marks shortest paths correctly()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:resolves multiple paths to same vulnerable library()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:resolves 3-level chain correctly()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:resolves 2-level chain correctly()]
- com.depanalyzer.core.graph.ChainResolverTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.ChainResolverTest]/[method:handles multiple CVEs in single node()]
|
| 23 |
|
1.1 Location : calculateMaxDepth Killed by : none negated conditional → NO_COVERAGE
|
| 24 |
|
1.1 Location : calculateMaxDepth Killed by : none changed conditional boundary → NO_COVERAGE
2.2 Location : calculateMaxDepth Killed by : none negated conditional → NO_COVERAGE
3.3 Location : calculateMaxDepth Killed by : none replaced int return with 0 for com/depanalyzer/core/graph/DependencyGraph::calculateMaxDepth → NO_COVERAGE
4.4 Location : calculateMaxDepth Killed by : none negated conditional → NO_COVERAGE
5.5 Location : calculateMaxDepth Killed by : none Replaced integer addition with subtraction → NO_COVERAGE
6.6 Location : calculateMaxDepth Killed by : none negated conditional → NO_COVERAGE
|
| 27 |
|
1.1 Location : getAllNodes Killed by : com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:detects cycles in dependency graph()] replaced return value with Collections.emptyList for com/depanalyzer/core/graph/DependencyGraph::getAllNodes → KILLED
|
| 30 |
|
1.1 Location : getAllVulnerableNodes Killed by : com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:identifies all vulnerable nodes()] replaced return value with Collections.emptyList for com/depanalyzer/core/graph/DependencyGraph::getAllVulnerableNodes → KILLED
|
| 34 |
|
1.1 Location : detectCycle Killed by : none negated conditional → NO_COVERAGE
|
| 35 |
|
1.1 Location : detectCycle Killed by : none replaced boolean return with false for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
| 39 |
|
1.1 Location : detectCycle Killed by : none negated conditional → NO_COVERAGE
|
| 40 |
|
1.1 Location : detectCycle Killed by : none negated conditional → NO_COVERAGE
|
| 41 |
|
1.1 Location : detectCycle Killed by : none replaced boolean return with false for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
| 45 |
|
1.1 Location : detectCycle Killed by : none replaced boolean return with true for com/depanalyzer/core/graph/DependencyGraph::detectCycle → NO_COVERAGE
|
| 56 |
|
1.1 Location : getAllVulnerableNodes Killed by : com.depanalyzer.core.graph.DependencyGraphTest.[engine:junit-jupiter]/[class:com.depanalyzer.core.graph.DependencyGraphTest]/[method:identifies all vulnerable nodes()] negated conditional → KILLED
|