|
2 | 2 |
|
3 | 3 | // Get the top level dependency between a Typescript module and the external modules it uses |
4 | 4 | MATCH (source:TS:Module)-[moduleDependency:DEPENDS_ON]->(target:ExternalModule) |
5 | | - WHERE NOT EXISTS {(target)-[:RESOLVES_TO]->(source)} |
| 5 | +// Exclude all targets where an ExternalModule was found that resolves to them |
| 6 | +// because those are covered in the fine grained weights for "ExternalModule"s. |
| 7 | + WHERE NOT EXISTS { (target)-[:RESOLVES_TO]->(source) } |
6 | 8 | OPTIONAL MATCH (source)-[resolvedModuleDependency:DEPENDS_ON]->(resolvedTarget:TS:Module)<-[:RESOLVES_TO]-(target) |
7 | 9 | WITH source |
8 | 10 | ,target |
@@ -43,15 +45,17 @@ OPTIONAL MATCH (source)-[ra:DEPENDS_ON]->(declaration)-[:RESOLVES_TO]->(abstract |
43 | 45 | // - "lowCouplingElement25PercentWeight" subtracts 75% of the weights for abstract types like Interfaces and Type aliases |
44 | 46 | // to compensate for their low coupling influence. Not included "high coupling" elements like Functions and Classes |
45 | 47 | // remain in the weight as they were. The same applies for "lowCouplingElement10PercentWeight" but with in a stronger manner. |
46 | | - SET moduleDependency.declarationCount = declarationCount |
47 | | - ,moduleDependency.abstractTypeCount = abstractTypeCount |
48 | | - ,moduleDependency.abstractTypeCardinality = abstractTypeCardinality |
49 | | - ,moduleDependency.lowCouplingElement25PercentWeight = toInteger(moduleDependency.cardinality - round(abstractTypeCardinality * 0.75)) |
50 | | - ,moduleDependency.lowCouplingElement10PercentWeight = toInteger(moduleDependency.cardinality - round(abstractTypeCardinality * 0.90)) |
| 48 | + SET moduleDependency.declarationCount = coalesce(declarationCount, 0) |
| 49 | + ,moduleDependency.abstractTypeCount = coalesce(abstractTypeCount, 0) |
| 50 | + ,moduleDependency.abstractTypeCardinality = coalesce(abstractTypeCardinality, 0) |
| 51 | + ,moduleDependency.lowCouplingElement25PercentWeight = |
| 52 | + toInteger(moduleDependency.cardinality - round(abstractTypeCardinality * 0.75)) |
| 53 | + ,moduleDependency.lowCouplingElement10PercentWeight = |
| 54 | + toInteger(moduleDependency.cardinality - round(abstractTypeCardinality * 0.90)) |
51 | 55 | // Set all new properties also to a resolved (direct) dependency relationship if it exists. |
52 | | - ,resolvedModuleDependency.declarationCount = declarationCount |
53 | | - ,resolvedModuleDependency.abstractTypeCount = abstractTypeCount |
54 | | - ,resolvedModuleDependency.abstractTypeCardinality = abstractTypeCardinality |
| 56 | + ,resolvedModuleDependency.declarationCount = coalesce(declarationCount, 0) |
| 57 | + ,resolvedModuleDependency.abstractTypeCount = coalesce(abstractTypeCount, 0) |
| 58 | + ,resolvedModuleDependency.abstractTypeCardinality = coalesce(abstractTypeCardinality, 0) |
55 | 59 | ,resolvedModuleDependency.lowCouplingElement25PercentWeight = toInteger(resolvedModuleDependency.cardinality - round(abstractTypeCardinality * 0.75)) |
56 | 60 | ,resolvedModuleDependency.lowCouplingElement10PercentWeight = toInteger(resolvedModuleDependency.cardinality - round(abstractTypeCardinality * 0.90)) |
57 | 61 | RETURN source.globalFqn AS sourceName |
|
0 commit comments