All Projects → glato → emerge

glato / emerge

Licence: MIT License
emerge is a source code analysis tool and dependency visualizer that can be used to gather insights about source code structure, metrics, dependencies and complexity of software projects. After scanning the source code of a project it provides you an interactive web interface to explore and analyze your project by using graph structures.

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to emerge

Objc Dependency Visualizer
Objective-C and Swift dependency visualizer. It's tool that helps to visualize current state of your project. It's really easy to see how tight your classes are coupled.
Stars: ✭ 1,738 (+1348.33%)
Mutual labels:  dependency-graph, d3js, swift-dependencies-visualizer
Neo4jd3
Neo4j graph visualization using D3.js
Stars: ✭ 843 (+602.5%)
Mutual labels:  graph-visualization, d3js
govizz
No description or website provided.
Stars: ✭ 19 (-84.17%)
Mutual labels:  dependency-graph, dependencies
Ngd
View the dependencies tree of you Angular application
Stars: ✭ 570 (+375%)
Mutual labels:  dependency-graph, dependencies
Dependency Cruiser
Validate and visualize dependencies. Your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.
Stars: ✭ 2,326 (+1838.33%)
Mutual labels:  dependency-graph, dependencies
Module Linker
browse modules by clicking directly on "import" statements on GitHub ⛺
Stars: ✭ 229 (+90.83%)
Mutual labels:  dependency-graph, dependencies
Ort
A suite of tools to assist with reviewing Open Source Software dependencies.
Stars: ✭ 446 (+271.67%)
Mutual labels:  dependency-graph, dependencies
Dephell
📦 🔥 Python project management. Manage packages: convert between formats, lock, install, resolve, isolate, test, build graph, show outdated, audit. Manage venvs, build package, bump version.
Stars: ✭ 1,730 (+1341.67%)
Mutual labels:  dependency-graph, dependencies
metahelm
Install dependency graphs of Kubernetes Helm Charts
Stars: ✭ 70 (-41.67%)
Mutual labels:  dependency-graph, dependencies
jonga
Jonga: Python function call graph visualization
Stars: ✭ 39 (-67.5%)
Mutual labels:  dependency-graph, code-visualization
gotopus
Gotopus is a minimalistic tool that runs arbitrary commands concurrently.
Stars: ✭ 17 (-85.83%)
Mutual labels:  dependency-graph
Track-Stargazers
Have fun tracking your project's stargazers
Stars: ✭ 38 (-68.33%)
Mutual labels:  d3js
hardhat-dependency-compiler
📦 Compile Solidity sources directly from NPM dependencies
Stars: ✭ 19 (-84.17%)
Mutual labels:  dependencies
babel-collect-imports
Recursively collect all the internal and external dependencies from an entry point
Stars: ✭ 33 (-72.5%)
Mutual labels:  dependencies
billboard
🎤 Lyrics/associated NLP data for Billboard's Top 100, 1950-2015.
Stars: ✭ 53 (-55.83%)
Mutual labels:  d3js
webtrees-pedigree-chart
SVG based pedigree chart module for webtrees genealogy application.
Stars: ✭ 24 (-80%)
Mutual labels:  d3js
turkeyvisited
Mark the cities you have visited in Turkey and share the map!
Stars: ✭ 82 (-31.67%)
Mutual labels:  d3js
ngmodule-viz
Visualize the dependencies between the NgModules in your Angular 2+ application
Stars: ✭ 35 (-70.83%)
Mutual labels:  dependency-graph
rcvis
Understandable visualizations for Ranked-Choice Voting elections: sankey, bargraphs, tabular formats, and automatically-generated videos with text-to-speech using AWS Polly.
Stars: ✭ 13 (-89.17%)
Mutual labels:  d3js
streamformatics
Real-time species-typing visualisation for nanopore data.
Stars: ✭ 13 (-89.17%)
Mutual labels:  d3js

emerge

GitHub license GitHub tag version Python version Code size Repo size

emerge (or emerge-viz) is a code analysis tool to gather insights about source code structure, metrics, dependencies and complexity of software projects. You can use it to scan the source code of a project, calculate metric results and statistics, map the source code to graph structures (e.g. a dependency graph or a filesystem graph), export the results in other file formats and even create an interactive web application for further exploration. emerge currently has scanning support for the following languages: C, C++, Groovy, Java, JavaScript, TypeScript, Kotlin, ObjC, Ruby, Swift, Python. The structure, coloring and clustering is calculated and based on the idea of combining a force-directed graph simulation and Louvain modularity. emerge is mainly written in Python 3 and is tested on macOS, linux and modern web browsers (i.e. latest Safari, Chrome, Firefox, Edge).

Goals of this project

emerge (/ɪˈməːdʒ/)

  • to appear by coming out of something or out from behind something
  • to become known, especially as a result of examining something or asking questions about it

 

The main goal of this project is to create a free/ open source tool, that can easily be used by anyone with interest in software development, architecture, metrics and visualization to gather more insights about those topics. It should facilitate/ support getting a better understanding of a given software project by using an exploratory approach.

 

The following features are currently supported by emerge

  • File scan support for the following languages: C, C++, Groovy, Java, JavaScript, TypeScript, Kotlin, ObjC, Ruby, Swift, Python
  • Basic entity scan/extraction (e.g. classes) for the following languages: Groovy, Java, Kotlin, Swift
  • Basic implementation of the following software metrics: SLOC, Number of Methods, Fan-In/Fan-Out, Modularity (Louvain)
  • Logging support with configurable log levels
  • Configuration support based on YAML syntax to configure multiple/specific analyses
  • Create a language/project configuration directly from an included configuration template
  • Export of scan results/ metrics/ statistics for the following formats/ outputs
    • Code dependency, inheritance, complete and filesystem graph (enriched with scan results/metrics)
    • GraphML
    • Graphviz DOT format
    • JavaScript format suited for a D3 force graph simulation
    • Interactive HTML/ web application for interactive, exploratory analysis and data visualization of your project based on graph structures
      • HTML app is based on Bootstrap
      • Force-directed graph simulation by D3
      • The node colors are based on Louvain modularity with a bit of post-processing to make the graph coloring more deterministic and stable
      • Fast full-screen UI rendering on HTML canvas
      • Visualization of files, entities and given metrics
      • dark mode support
      • Reactive visual live search of files/ entities (e.g. classes)
      • Selection and highlighting of individual nodes
      • Concave hull visualization of single clusters
      • Display of cluster metrics to facilitate comparability
      • Interactivity given by translation, zooming, dragging and hovering over nodes
    • Tabular console output
    • Tabular file output
    • JSON file output

 

How to install and use emerge as a user

Basically there are two ways to install emerge. If you're familiar with pip (a virtual environment by using pyenv, virtualenv and virtualenvwrapper is recommended, but not needed) you can simply install the latest version of emerge with the following few steps.

1️⃣ ~ Install emerge with pip

pip install emerge-viz

and then simply execute it like this

(emerge) user@host ~ % emerge
usage: emerge [-h] [-c YAMLCONFIG] [-v] [-d] [-e] [-a LANGUAGE]

🔎 Welcome to emerge 1.0.0 (2021-12-04 20:40:34)

options:
  -h, --help            show this help message and exit
  -c YAMLCONFIG, --config YAMLCONFIG
                        set yaml config file
  -v, --verbose         set logging level to INFO
  -d, --debug           set logging level to DEBUG
  -e, --error           set logging level to ERROR
  -a LANGUAGE, --add-config LANGUAGE
                        add a new config from a template, where LANGUAGE is one of [JAVA, SWIFT, C, CPP, GROOVY, JAVASCRIPT,
                        TYPESCRIPT, KOTLIN, OBJC, RUBY, PY]

2️⃣ ~ Create and adjust project configuration

You can create a simple project config adhoc from the command line and then simply adjust the necessary source/export paths

(emerge) user@host tmp % pwd
/Users/grzegorz.lato/tmp
(emerge) user@host tmp % emerge -a java
✅ created config file from template: /Users/user1/tmp/java-template.yaml

and then simply adjust the necessary paths (analyses/source_directory and export/directory):

(emerge) user@host tmp % cat java-template.yaml 
---
project_name: java_project_example
loglevel: info
analyses:
- analysis_name: full java check
  source_directory: /Users/user1/emerge/project/source
  only_permit_languages:
  - java
  only_permit_file_extensions:
  - .java
  file_scan:
  - number_of_methods
  - source_lines_of_code
  - dependency_graph
  - fan_in_out
  - louvain_modularity
  entity_scan:
  - dependency_graph
  - source_lines_of_code
  - number_of_methods
  - fan_in_out
  - louvain_modularity
  export:
  - directory: /Users/user1/emerge/project/export
  - graphml
  - dot
  - json
  - tabular_file
  - tabular_console_overall
  - d3
(emerge) grzegorz.lato@C02DN06QMD6V tmp %

3️⃣ ~ Start a scan

After this you can simply start a scan by

(emerge) grzegorz.lato@C02DN06QMD6V tmp % emerge -c java-template.yaml
2021-12-04 21:18:15   analysis I 👉 starting to analyze java_project_example
2021-12-04 21:18:15   analysis I ⏩ performing analysis 1/1: full java check
2021-12-04 21:18:15   analysis I 👉 starting to create filesystem graph in full java check
2021-12-04 21:18:15   analysis I ⏩ starting scan at directory: ...
...
...
...
2021-12-04 21:18:27   analysis I ✅ all your generated/exported data can be found here: /Users/user1/tmp/java
2021-12-04 21:18:27   analysis I ✅ copy the following path to your browser and start your web app: 👉 file:///Users/user1/tmp/java/html/emerge.html
2021-12-04 21:18:27   analysis I ✅ total runtime of analysis: 00:00:10 + 154 ms

4️⃣ ~ Start your web app

Now just copy the above mentioned file:// path to any modern web browser and interactively expore your configured codebase 😉

 

How to install and use emerge from source (e.g. for development)

You can clone this repository and install it by following this instruction:

1️⃣ ~ Clone this repository

git clone https://github.com/glato/emerge.git

2️⃣.1️⃣ ~ (macOS) Install the graphviz package first

brew install graphviz

2️⃣.2️⃣ ~ (macOS) Create a virtual environment

Check of you have the latest Python 3 installed on your macOS. I recommend installing/using Python 3 from Homebrew. Create a Python 3 virtual environment (optionally within the project structure)

cd emerge
pip3 install virtualenv
virtualenv -p python3 venv

2️⃣ ~ (ubuntu) Create a virtual environment

Install required packages and create a Python 3 virtual environment (optionally within the project structure)

apt-get install python3-venv python3-dev graphviz graphviz-dev
cd emerge
python3 -m venv venv

3️⃣ ~ Before using/working with the tool, activate the virtual environment

source venv/bin/activate

4️⃣ ~ (macOS) Install all dependencies

Install all required dependencies for the project with pip

pip install -r requirements.txt

4️⃣ ~ (ubuntu) Install all dependencies

Install the wheel package, after that install all required dependencies for the project with pip

pip install wheel
pip install -r requirements.txt

5️⃣ ~ Running unit tests from the command line

python emerge/tests/run_tests.py

6️⃣ ~ Running emerge as a standalone tool

(emerge) user@host emerge % python emerge.py 
usage: emerge.py [-h] [-c YAMLCONFIG] [-v] [-d] [-e] [-a LANGUAGE]

🔎 Welcome to emerge 1.0.0 (2021-12-04 20:40:34)

options:
  -h, --help            show this help message and exit
  -c YAMLCONFIG, --config YAMLCONFIG
                        set yaml config file
  -v, --verbose         set logging level to INFO
  -d, --debug           set logging level to DEBUG
  -e, --error           set logging level to ERROR
  -a LANGUAGE, --add-config LANGUAGE
                        add a new config from a template, where LANGUAGE is one of [JAVA, SWIFT, C, CPP, GROOVY, JAVASCRIPT,
                        TYPESCRIPT, KOTLIN, OBJC, RUBY, PY]

7️⃣ ~ You're ready to go

Let's quickly try to run emerge on its own codebase

python emerge.py -c configs/emerge.yaml

This should produce a similar output:

...   analysis I 👉 starting to analyze emerge
...   analysis I ⏩ performing analysis 1/1: self-check
...   analysis I 👉 starting to create filesystem graph in self-check
...   analysis I ⏩ starting scan at directory: .
...   ...
...   analysis I 👉 the following statistics were collected in self-check
+-------------------------------------+-------------------+
|                      statistic name | value             |
+-------------------------------------+-------------------+
|                    scanning_runtime | 00:00:00 + 61 ms  |
|                       scanned_files | 32                |
|                       skipped_files | 176               |
|                        parsing_hits | 313               |
|                      parsing_misses | 141               |
|              extracted_file_results | 32                |
|       file_results_creation_runtime | 00:00:00 + 538 ms |
|    number-of-methods-metric-runtime | 00:00:00 + 4 ms   |
| source-lines-of-code-metric-runtime | 00:00:00 + 11 ms  |
|   louvain-modularity-metric-runtime | 00:00:00 + 161 ms |
|           fan-in-out-metric-runtime | 00:00:00 + 4 ms   |
|                       total_runtime | 00:00:00 + 786 ms |
+-------------------------------------+-------------------+
...   analysis I 👉 the following overall metrics were collected in self-check
+----------------------------------------------+----------------------------+
|                                  metric name | value                      |
+----------------------------------------------+----------------------------+
|                avg-number-of-methods-in-file | 13.0                       |
|                             avg-sloc-in-file | 151.41                     |
|                          total-sloc-in-files | 4845                       |
|         louvain-communities-dependency-graph | 3                          |
|          louvain-modularity-dependency-graph | 0.21                       |
| louvain-biggest-communities-dependency-graph | 0.49, 0.46, 0.05, 0.0, 0.0 |
|                  avg-fan-in-dependency-graph | 5.55                       |
|                 avg-fan-out-dependency-graph | 5.55                       |
|                  max-fan-in-dependency-graph | 29                         |
|             max-fan-in-name-dependency-graph | typing                     |
|                 max-fan-out-dependency-graph | 19                         |
|            max-fan-out-name-dependency-graph | emerge/appear.py           |
+----------------------------------------------+----------------------------+
...   analysis I ✅ all your generated/exported data can be found here: /Users/user1/tmp/python
...   analysis I ✅ copy the following path to your browser and start your web app: 👉 file:///Users/user1/tmp/python/html/emerge.html
...   analysis I ✅ total runtime of analysis: 00:00:00 + 786 ms

8️⃣ ~ Start your web app

Now just copy the above mentioned file:// path to any modern web browser and interactively expore the emerge codebase 😉

8️⃣.1️⃣ ~ Currently emerge offers the following keyboard shortcuts in the interactive web app:

  • ℹ️ Hovering over a node and pressing ⬆️ + s to select and highlight or deselect a specific node
  • ℹ️ Resetting the currently active node selection by pressing ⬆️ + r
  • ℹ️ Fading all unselected nodes to have a more highlighted visualization of you currenty selected nodes by pressing ⬆️ + f

And now let's make this more interesting ...

 

Further configuration (using emerge on other projects)

If you wand to use emerge on other projects, you can simple copy or customize one of the existing configuration templates from the emerge/configs directory.

9️⃣ ~ Scan a real project

For a quick run, it should be enough to adjust source_directory, directory in export.

---
project_name: c-example-project
loglevel: info
analyses:
- analysis_name: check_c_files
  source_directory: /Users/user1/emerge/project/source/github/linux-5.8.5/crypto
  only_permit_languages:
  - c
  only_permit_file_extensions:
  - .c
  - .h
  ignore_dependencies_containing:
  - string.h
  file_scan:
  - number_of_methods
  - source_lines_of_code
  - dependency_graph
  - louvain_modularity
  - fan_in_out
  export:
  - directory: /Users/user1/emerge/project/export
  - graphml
  - dot
  - json
  - tabular_file
  - tabular_console_overall
  - d3

1️⃣0️⃣ ~ Run emerge with a specific yaml configuration

After customizing a present config (e.g. config/c-template.yaml) or creating your own, just run emerge again with this new config

python emerge.py -c configs/c-template.yaml

After the scan, your scan output (including your interactive web app) can be found at the directory that you created and set in the config parameter export -> directory, as seen in the logs above.

A full YAML configuration that contains both file and entity scan has the following format:

---
project_name: java_project_example
loglevel: info
analyses:
- analysis_name: check_java_files_and_classes
  source_directory: /Users/user1/emerge/project/source
  only_permit_languages:
  - java
  only_permit_file_extensions:
  - .java
  ignore_dependencies_containing:
  - java.util
  file_scan:
  - number_of_methods
  - source_lines_of_code
  - dependency_graph
  - fan_in_out
  - louvain_modularity
  entity_scan:
  - dependency_graph
  - source_lines_of_code
  - number_of_methods
  - fan_in_out
  - louvain_modularity
  export:
  - directory: /Users/user1/emerge/project/export
  - graphml
  - dot
  - json
  - tabular_file
  - tabular_console_overall
  - d3

The yaml configuration is basically defined at the following levels:

project level

key value/ description
project_name a project name for all analyses, scans and exports
loglevel set a loglevel: error (silent, only errors), info (includes error) gives you basic logs about control flow, debug (includes info) will produce a lot of debug logs
analyses an array of analyses that can be configured individually, thus a project can contain one to many analyses.

analysis level

key value/ description
analysis_name a specific analysis name
source_directory the source directory where the recursive file scan should start
ignore_files_containing exclude file names from the scan that contain the given substrings
ignore_directories_containing exclude directory names from the scan that contain the given substrings
only_permit_languages possible values include: java, kotlin, objc, swift, ruby, groovy, javascript, c - explicitly prevents any other language from scanning besides the one you set here
only_permit_file_extensions explicitly permit the following file extensions you set here, e.g. .java
ignore_dependencies_containing ignore every dependency included in this list of substrings, e.g. java.util
import_aliases define import aliases, i.e. replace substrings within a full dependency path, e.g. - "@foo": src/foo will replace any @foo alias by src/foo
file_scan perform a file scan, contains the metrics that should be applied on every source file
entity_scan perform an entity scan, contains the metrics that should be applied on every entity (e.g. on every class)
export contains any export formats that should be create as output

file_scan metrics

key value/ description
dependency_graph create a dependency graph structure based on source files, additional metrics will be added to the graph nodes
source_lines_of_code apply a source lines of code metric to every file, create an overall metric
number_of_methods apply a number of methods metric to every file, create an overall metric
fan_in_out apply a fan in/ fan out graph metric to every file, create an overall metric
louvain_modularity apply a louvain modularity metric to every file, create an overall metric

entity_scan metrics

key value/ description
dependency_graph create a dependency graph structure based on extracted entities from files, additional metrics will be added to the graph nodes
inheritance_graph create an inheritance graph structure based on extracted entities from files, additional metrics will be added to the graph nodes
complete_graph create a complete graph structure (union of dependency/ inheritance graph) based on extracted entities from files, additional metrics will be added to the graph nodes
source_lines_of_code apply a source lines of code metric to every entity, create an overall metric
number_of_methods apply a number of methods metric to every entity, create an overall metric
fan_in_out apply a fan in/ fan out graph metric to every entity, create an overall metric
louvain_modularity apply a louvain modularity metric to every entity, create an overall metric

export configuration

key value/ description
directory the output directory for all specified export formats
graphml create a graphML file that contains the graph structure and metric results mapped to the nodes of the graph
tabular_file create a tabular formatted text file that contains every metric and statistic result
tabular_console print a tabular formatted output to console that contains every metric and statistic result
tabular_console_overall print a tabular formatted output to console that contains only overall metric and statistic results
json create a JSON file that contains every metric and statistic result
dot create a DOT file that contains the graph structure and metric results mapped to the nodes of the graph
d3 create a Bootstrap/D3 web application in the subfolder force-graph-html for further visual and interactive/ exploratory analysis

Supported scan types and file extensions

Emerge supports the following file extensions and scan types per language, whereas a file_scan simply calculates metrics and maps nodes within graph structures to scanned files and an entity_scan tries to extract more fine-grained entities from files e.g. classes or structs.

File extension Language parser Files Entities
.java Java
.swift Swift
.c / .h C
.cpp / .h C++
.groovy Groovy
.js / .jsx JavaScript
.ts / .tsx TypeScript
.k Kotlin
.m / .h Objective-C
.rb Ruby
.py Python

Further development

  • Disclaimer: The current version is not yet stable, probably still has some 🐞 and is probably not yet suited for productive usage.
  • Parsing of further entity types for more languages is planned for further development. Contributions are very welcome.
  • Everyone is invited to contribute to this project, whether the contribution is related with development, testing, bug reporting or any other support. I would appreciate any help. See Contributing and Credits for further details.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].