dirk mahler - yes, we scan! análise de software usando jqassistant e neo4jj - #oowbr #javaonebr

25
by Yes We Scan! Software Analysis Using jQAssistant And Neo4j JavaOne Latin America São Paulo 2016 Dirk Mahler

Upload: oracle-latinoamerica

Post on 15-Jan-2017

28 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

by

Yes We Scan! Software Analysis Using

jQAssistant And Neo4j

JavaOne Latin AmericaSão Paulo 2016

Dirk Mahler

Page 2: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

2

AGENDA

Black Boxes Called Artifacts jQAssistant Software As A Graph Let’s Explore Libraries!

Page 3: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

Black Boxes Called Artifacts

Yes We Scan!Software Analysis Using jQAssistant And Neo4j

3

Page 4: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

4

Artifact Result of a build/integration processes Black Box – What does it hide?

Let‘s open it!

Person.java

@Entitypublic class Person {private String name;

}

pom.xml

<dependency><groupId>org.eclipse.persistence</groupId><artifactId>persistence-api</artifactId><version>2.1.0</version>

</dependency>

person.sql

create table PERSON (id number, name varchar(255)

model.jar

/com/acme/model/Person.class/META-INF/persistence.xml

acme.war

/index.xhtml/WEB-INF/lib/model.jar

Page 5: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

5

The Idea

Scan software structures

Store in a database

Execute queries Explore

Add high level concepts

Find constraint violations

Create reports

Database

Page 6: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

jQAssistant

Yes We Scan!Software Analysis Using jQAssistant And Neo4j

6

Page 7: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

7

http://jQAssistant.org

Open Source: GPLv3

Current release: 1.1.3 initiated: 03/2013 first stable release: 04/2015

Neo4j Community Edition http://neo4j.org embedded, no installation necessary

Page 8: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

8

Command Line/

Maven

Scan

Analyze

Report

Plugins

Plugins

Plugins

Page 9: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

9

Getting Started – Command Line

unzip jqassistant.distribution-1.x.x.zip cd jqassistant.distribution-1.x.x/bin

jqassistant.sh scan –f model.jar jqassistant.sh scan –f acme.war jqassistant.sh scan –f acme.ear jqassistant.sh scan –u http://somewhere.com/acme.ear jqassistant.sh scan –u maven:repository::http://host/releases

jqassistant.sh scan –u rdbms:schema::jdbc:oracle:thin:user/secret@host:1521:sid

jqassistant.sh server http://localhost:7474

Page 10: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

10

Getting Started – Maven Project

<build><plugins><plugin>

<groupId>com.buschmais.jqassistant.scm</groupId><artifactId>jqassistant-maven-plugin</artifactId><version>1.x.x</version>

</plugin></plugins>

</build>

mvn install jqassistant:scan mvn jqassistant:server

http://localhost:7474

Page 11: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

11

Available scanner plugins

Plugin API is public

*.class

RDBMS Schema

GitJaCoCo

FindBugsCheckStyle

LiquibaseJAR, WAR, EARZIP

application.xmlweb.xml

MANIFEST.MF /META-INF/services/*

beans.xml

pom.xml surefire-reports.xml

GZ

*.properties

*.xsd

M2 Repository

*.yaml

Page 12: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

Software As A Graph

Yes We Scan!Software Analysis Using jQAssistant And Neo4j

12

Page 13: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

13

All we need is… Nodes Labels Properties Relationships

Modeling is just… Taking a pen Drawing the structures on a whiteboard (i.e. the database)

We don‘t need… Foreign keys Tables and schemas Knowledge in graph theory

Type

EXTENDS

fqn:com.acme.model.Person

Page 14: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

CONTAINS

Package

name:com

CONTAINS

Package

name:acme

CONTAINS

Package

name:model

Class

Type

CONTAINS

fqn:com.acme.model.PersonAnnotation ANNOTATED_BYType

OF_TYPE

fqn:javax.persistence.Entity

REQUIRES

Field

DECLARES

name:name

Type

OF_TYPE

fqn:int

REQUIRES

Maven

CONTAINS

fileName: /META-INF/maven/com.acme.model/pom.xml

Pom

Java

CONTAINS

Archive

fileName:model.jar

Artifact

Web Application

fileName:acme.warArchive

ArtifactCONTAINS

group:org.eclipse.persistencename:persistence-api

version: 2.1.0

Artifact

scope:compileDECLARES_DEPENDENCY

Page 15: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

15

TypeType

Class

EXTENDS

Explore an application using queries Which class extends from another class?

Let‘s convert this to ASCII art… () as nodes

-[]-> as directed relationships

Page 16: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

16

TypeType

Class

EXTENDS

Explore an application using queries Which class extends from another class?

Let‘s convert this to ASCII art… () as nodes

-[]-> as directed relationships

()-[]->()

Page 17: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

17

C2Type

C1Type

Class

EXTENDS

Explore an application using queries Which class extends from another class?

Let‘s convert this to ASCII art… () as nodes

-[]-> as directed relationships

(c1)-[]->(c2)

Page 18: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

18

C2Type

C1Type

Class

EXTENDS

Explore an application using queries Which class extends from another class?

Let‘s convert this to ASCII art… () as nodes

-[]-> as directed relationships

(c1)-[:EXTENDS]->(c2)

Page 19: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

19

Explore an application using queries Which class extends from another class?

Let‘s convert this to ASCII art… () as nodes

-[]-> as directed relationships

(c1:Class)-[:EXTENDS]->(c2:Type)

C2Type

C1Type

Class

EXTENDS

Page 20: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

20

Explore an application using queries Which class extends from another class?

Pattern matching is the core principle of Cypher

MATCH(c1:Class)-[:EXTENDS]->(c2:Type)

RETURNc1.fqn, c2.fqn

C2Type

C1Type

Class

EXTENDS

Page 21: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

Let’s Explore Libraries!

Yes We Scan!Software Analysis Using jQAssistant And Neo4j

21

Page 22: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

22

Examples Artifacts and Maven descriptors API changes between releases

Declared deprecations Thrown exceptions Anti-Patterns Structural problems (metrics) Declared members

Depth of inheritance hierarchies

Cyclomatic complexity

Fan In/Fan Out of classes and packages

Package Cycles

Page 23: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

Live Demo

Yes We Scan!Software Analysis Using jQAssistant And Neo4j

23

https://jqassistant.org/yes-we-scan-exploring-libraries/

Page 24: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

24

Holistic and extensible view on code structures Graph data model

Plugin architecture

Flexible exploration of structures using queries Expressive query language - Cypher

Powerful searches beyond IDE capabilities

Individual metrics and visualization

Page 25: Dirk Mahler - Yes, we scan! Análise de software usando JQAssistant e Neo4jj - #oowBR #JavaOneBR

Web: jqassistant.org

Twitter: @jqassistant

Google Group: jQAssistant

Stackoverflow Tag: jQAssistant

Thank You! – Questions?

by