These are notes for some jQAssistant / Neo4j / Cypher demos
mvn jqassistant:server
Commit
Class
:DECLARES
List types with the most methods
MATCH
(t:Type)-[:DECLARES]->(m:Method)
RETURN t.fqn as Typ, COUNT(m) as Methods
ORDER BY Methods DESC
Find static, mutable fields
MATCH (c:Class)-[:DECLARES]->(f:Field)<-[w:WRITES]-(m:Method)
WHERE
EXISTS(f.static) AND NOT EXISTS(f.final)
RETURN
c.name as InClass,
m.name as theMethod,
w.lineNumber as writesInLine,
f.name as toStaticField
Find recursive calls
MATCH
(c:Class)-[:DECLARES]->(m:Method)-[:INVOKES*1..5]->(m)
RETURN c, m
Find recursive calls to the database
MATCH
(m:Method)-[:INVOKES*]->(m)-[:INVOKES]->(dbMethod:Method),
(dbMethod)<-[:DECLARES]-(dbClass:Class)
WHERE dbClass.name ENDS WITH "Database"
RETURN m, dbMethod, dbClass
Aggregate measures to business subdomains
MATCH
(t:Type)-[:BELONGS_TO]->(s:Subdomain),
(t)-[:HAS_CHANGE]->(ch:Change)
RETURN
s.name as ASubdomain,
COUNT(DISTINCT t) as Types,
COUNT(DISTINCT ch) as Changes
ORDER BY Types DESC
Aggregate many measures to business subdomains
MATCH
(t:Type)-[:BELONGS_TO]->(s:Subdomain),
(t)-[:HAS_CHANGE]->(ch:Change),
(t)-[:HAS_MEASURE]->(co:Coverage)
OPTIONAL MATCH
(t)-[:HAS_BUG]->(b:BugInstance)
RETURN
s.name as ASubdomain,
COUNT(DISTINCT t) as Types,
COUNT(DISTINCT ch) as Changes,
AVG(co.ratio) as Coverage,
COUNT(DISTINCT b) as Bugs,
SUM(DISTINCT t.lastMethodLineNumber) as Lines
ORDER BY Coverage ASC, Bugs DESC