|
9 | 9 | ,target |
10 | 10 | ,moduleDependency |
11 | 11 | ,moduleDependency.cardinality AS targetModuleCardinality |
12 | | - |
13 | 12 | // Get optional external (e.g. type) declarations that the external module (target) provides and the source module uses |
14 | 13 | OPTIONAL MATCH (source)-[elementDependency:DEPENDS_ON|EXPORTS]->(elementType:TS)<-[:EXPORTS]-(target) |
15 | 14 | WITH source |
@@ -40,13 +39,18 @@ OPTIONAL MATCH (source)-[abstractDependency:DEPENDS_ON|EXPORTS]->(abstractType:T |
40 | 39 | // - "lowCouplingElement25PercentWeight" subtracts 75% of the weights for abstract types like Interfaces and Type aliases |
41 | 40 | // to compensate for their low coupling influence. Not included "high coupling" elements like Functions and Classes |
42 | 41 | // remain in the weight as they were. The same applies for "lowCouplingElement10PercentWeight" but with in a stronger manner. |
| 42 | +// If there are no declarations and therefore the elementTypeCardinality is zero then the original targetModuleCardinality is used. |
43 | 43 | SET moduleDependency.declarationCount = elementTypeCount |
44 | 44 | ,moduleDependency.abstractTypeCount = abstractTypeCount |
45 | 45 | ,moduleDependency.abstractTypeCardinality = abstractTypeCardinality |
46 | | - ,moduleDependency.lowCouplingElement25PercentWeight = |
47 | | - toInteger(elementTypeCardinality - round(abstractTypeCardinality * 0.75)) |
48 | | - ,moduleDependency.lowCouplingElement10PercentWeight = |
49 | | - toInteger(elementTypeCardinality - round(abstractTypeCardinality * 0.90)) |
| 46 | + ,moduleDependency.lowCouplingElement25PercentWeight = toInteger( |
| 47 | + coalesce(nullif(elementTypeCardinality, 0), targetModuleCardinality) - |
| 48 | + round(abstractTypeCardinality * 0.75) |
| 49 | + ) |
| 50 | + ,moduleDependency.lowCouplingElement10PercentWeight = toInteger( |
| 51 | + coalesce(nullif(elementTypeCardinality, 0), targetModuleCardinality) - |
| 52 | + round(abstractTypeCardinality * 0.90) |
| 53 | + ) |
50 | 54 | RETURN source.globalFqn AS sourceName |
51 | 55 | ,target.globalFqn AS targetName |
52 | 56 | ,elementTypeCount |
|
0 commit comments