1- // Candidates for Interface Segregation
1+ // Candidates for Interface Segregation
22
3- MATCH (type :Type )- [ : DECLARES ] -> (method :Method )- [ : INVOKES ] -> (dependentMethod :Method )<- [ : DECLARES ] - ( dependentType : Type )
4- MATCH (dependentType ) - [ : DECLARES ] -> ( declaredMethod : Method )
3+ MATCH (type :Type )- [ : DECLARES ] -> (method :Method )- [ : INVOKES ] -> (dependentMethod :Method )
4+ MATCH (dependentMethod ) < -[ : DECLARES ] - ( dependentType : Type )
55MATCH (dependentType )- [ : IMPLEMENTS * ] -> (superType :Type )- [ : DECLARES ] -> (inheritedMethod :Method )
6- WHERE type .fqn <> dependentType
6+ WHERE type .fqn <> dependentType . fqn
77 AND dependentMethod .name IS NOT NULL
88 AND inheritedMethod .name IS NOT NULL
99 AND dependentMethod .name <> '<init>' // ignore constructors
1010 AND inheritedMethod .name <> '<init>' // ignore constructors
11- WITH type
12- ,dependentType
11+ WITH type . fqn AS fullTypeName
12+ ,dependentType . fqn AS fullDependentTypeName
1313 ,collect (DISTINCT dependentMethod .name ) AS calledMethodNames
14- ,count (DISTINCT dependentMethod ) AS calledMethods
14+ ,count (DISTINCT dependentMethod ) AS calledMethods
1515 // Count the different signatures without the return type
1616 // of all declared methods including the inherited ones
1717 ,count (DISTINCT split (method .signature , ' ' )[1 ]) + count (DISTINCT split (inheritedMethod .signature , ' ' )[1 ]) AS declaredMethods
1818WHERE declaredMethods > calledMethods + 2
19- WITH dependentType
19+ WITH fullDependentTypeName
2020 ,declaredMethods
2121 ,calledMethodNames
2222 ,calledMethods
23- ,count (DISTINCT type . fqn ) AS callerTypes
24- RETURN dependentType . fqn , declaredMethods , calledMethodNames , calledMethods , callerTypes
25- ORDER BY callerTypes DESC , declaredMethods DESC , dependentType . fqn
23+ ,count (DISTINCT fullTypeName ) AS callerTypes
24+ RETURN fullDependentTypeName , declaredMethods , calledMethodNames , calledMethods , callerTypes
25+ ORDER BY callerTypes DESC , declaredMethods DESC , fullDependentTypeName
0 commit comments