Skip to content

Commit 6ccee6c

Browse files
committed
Add visibility reports for Typescript
1 parent 3c1f899 commit 6ccee6c

5 files changed

+512
-2
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Global relative visibility statistics for elements for Typescript
2+
3+
MATCH (project:Directory)<-[:HAS_ROOT]-(:Project)-[:CONTAINS]->(module:TS:Module)
4+
MATCH (module)-[:DECLARES]->(anyElement:TS)
5+
OPTIONAL MATCH (module)-[:EXPORTS]->(exportedElement:TS)
6+
WITH project.absoluteFileName AS projectPath
7+
,module
8+
,COUNT(DISTINCT exportedElement) AS exportedElements
9+
,COUNT(DISTINCT anyElement) AS allElements
10+
WITH projectPath
11+
,module
12+
,exportedElements
13+
,allElements
14+
,toFloat(exportedElements) / allElements AS relativeVisibility
15+
WITH projectPath
16+
,SUM(exportedElements) AS exported
17+
,SUM(allElements) AS all
18+
,AVG(relativeVisibility) AS average
19+
,MIN(relativeVisibility) AS min
20+
,MAX(relativeVisibility) AS max
21+
,percentileCont(relativeVisibility, 0.25) AS percentile25
22+
,percentileCont(relativeVisibility, 0.5) AS percentile50
23+
,percentileCont(relativeVisibility, 0.75) AS percentile75
24+
,percentileCont(relativeVisibility, 0.90) AS percentile90
25+
,percentileCont(relativeVisibility, 0.95) AS percentile95
26+
,percentileCont(relativeVisibility, 0.99) AS percentile99
27+
RETURN projectPath
28+
,all
29+
,exported
30+
,min
31+
,max
32+
,average
33+
,percentile25
34+
,percentile50
35+
,percentile75
36+
,percentile90
37+
,percentile95
38+
,percentile99
39+
ORDER BY projectPath
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Relative visibility: exported elements to all elements per module
2+
3+
MATCH (project:Directory)<-[:HAS_ROOT]-(:Project)-[:CONTAINS]->(module:TS:Module)
4+
MATCH (module)-[:DECLARES]->(moduleElement:TS)
5+
// Check if element is not only declared but also exported.
6+
// Only EXPORTS refers to re-exported elements.
7+
OPTIONAL MATCH (module)-[export:EXPORTS]->(moduleElement)
8+
WITH project.absoluteFileName AS projectPath
9+
,module
10+
,count(DISTINCT export) AS exportedElements
11+
,count(DISTINCT moduleElement) AS allElements
12+
WITH projectPath
13+
,module
14+
,exportedElements
15+
,allElements
16+
,toFloat(exportedElements) / allElements AS relativeVisibility
17+
RETURN projectPath
18+
,replace(module.fileName, './', '') AS modulePath
19+
,module.name AS moduleName
20+
,exportedElements
21+
,allElements
22+
,relativeVisibility
23+
ORDER BY relativeVisibility DESC, allElements DESC, projectPath ASC, moduleName ASC

jupyter/VisibilityMetricsJava.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"id": "2f0eabc4",
77
"metadata": {},
88
"source": [
9-
"# Visibility Metrics\n",
9+
"# Visibility Metrics for Java\n",
1010
"<br> \n",
1111
"\n",
1212
"### References\n",
@@ -436,7 +436,7 @@
436436
"pygments_lexer": "ipython3",
437437
"version": "3.11.4"
438438
},
439-
"title": "Object Oriented Design Quality Metrics for Java with Neo4j"
439+
"title": "Visibility Metrics for Java"
440440
},
441441
"nbformat": 4,
442442
"nbformat_minor": 5

0 commit comments

Comments
 (0)