Using AsciiArt to Analyse your SourceCode with Neo4j and OSS Tools

Who the hell is this guy?

What will he talk about?

What is a Graph Database ?

Property Graph Model

property graph model

What makes it special ?

Where can/should I use it ?

(Graphs)-[:LOVE]→(Whiteboards)

Ascii-Art Rocks

Ascii-Art Rocks

_                         )      ((   ))     (
(@)                      /|\      ))_((     /|\                        _
|-|`\                   / | \    (/\|/\)   / | \                      (@)
| | -------------------/--|-voV---\`|'/--Vov-|--\---------------------|-|
|-|                         '^`   (o o)  '^`                          | |
| |                               `\Y/'                               |-|
|-|          Welcome to the Mages Lair Multiple User Dungeon          | |
| |                    Welcome to the Addiction.                      |-|
|-|                                                                   | |
| |                                                                   |-|
|_|___________________________________________________________________| |
(@)               l   /\ /        ( (       \ /\   l                `\|-|
                  l /   V          \ \       V   \ l                  (@)
                  l/               _) )_          \I
                                   `\ /'
                                     `

Cypher

(Cypher)-[:USES]→(Ascii-Art)

Cypher Query - Example Geekout

Setup

Query

Geekout 2014 GraphGist

geekout2014

Interactive GraphGist Document WorldCup

Software Analytics - Approach

  1. look at one interesting aspect
  2. which insights would be cool?
  3. model it as a graph
  4. get data
  5. import into graph model
  6. enrich graph model with concepts / structure
  7. query for insights

(Code)-[:IS_A]→(Graph)

jQAssistant

jQAssistant

logo jqa small

Actively Looking for Contributions

http://github.com/buschmais/jqassistant

Modeling Source Code as a Graph

jqassistant model

Java software graph model : Nodes

Java software graph model: Relationships

Approach

  1. Scan your project with
    Plugins for Code (Java-ASM), Config, Metadata
  2. Import into Neo4j
  3. Enrich with declared technical and domain concepts
  4. On top of those concepts
  5. Software-Metrics queries
  6. Architectural-Rules queries

Query the Data

jqassistant query

Demo

Analyzing A Maven Repository

Rickard Öberg

This little nifty tool will allow you to import your local Maven repository information into a Neo4j graph, in particular dependencies between artifacts.

You can then take this graph and put it into a Neo4j server, and perform Cypher queries on it.

Or whatever else awesome you want to do.

mvn compile exec:java -Dexec.mainClass=com.github.rickardoberg.neomvn.Main \
  -Dexec.arguments="$HOME/.m2/repository"

https://github.com/rickardoberg/neomvn#example-queries

NeoMVN: Example Queries

Find all transitive dependencies of all artifacts with "org.neo4j" groups

Which version of JUnit is the most popular

Query a JVM Heapdump

  1. Get a heap-dump with jmap
    jmap -dump:format=b,file=dump.hprof <pid>
  2. Use jhat dump.hprof find the /oql endpoint
  3. run the OQL script to generate Cypher code
  4. Import into Neo4j
  5. Run arbitrary queries
  6. Visualize

Graph Domain Model

graph model deadlock

OQL to Generate Cypher

Visualization of a Deadlock Scenario

visualization deadlock

JVM heap analysis using Neo4j

Nat Pryce, James Richardson (Software Engineers, Sky)

Heap Model

neo4j heap

From Nat’s Graph Schema Modeling Approach

Talk at Accu 2014: Looking for Smoking Guns in a Haystack - using a graph database for JVM heap analysis

Using graphs for source code analysis

Raoul-Gabriel Urma (PhD in Computer Science, The University of Cambridge)

Did you know that the source code of software that you engineer every day can also be represented as graphs?

In this talk, we demonstrate how you can perform program analysis using Neo4j.

We describe a prototype that stores a graph representation of the source code of Java programs in Neo4j. We can then query the graph using Cypher and we’ll show various examples of possible queries such as “find me all recursive methods” and “find me all subtypes of a given type”.

Source Control, Issues, Social Coding

Example: Import Git Commit Logs into Neo4j

Blog Post

Visualization

git2neo2

Finally: Some Eye Candy

Isaac & Nash (Software Engineers at Leap Motion)

Let’s have a look: Demo Source

Questions ? Thank You!

/

#

Status of the presenation

Cypher queries execution