Chio
Chio (chan) exports metrics of a specific module for checking it's stability and flexibility.
What can it does
Main idea from Clean Architecture book Chapter 14.
Summarization go here.
Three metrics we care about:
- Abstractness (A):
This metric has the range [0, 1]. A value of 0 implies that the module has no abstract classes at all. A value of 1 implies that the module contains nothing but abstract classes.
- Instability (I):
This metric has the range [0, 1]. I = 0 indicates a maximally stable module. I = 1 indicates a maximally unstable module.
- Distance (D):
There is a place, where A and I have a balance, it's called
The Main Sequence
.
This metric has the range [0, 1]. D = 0 implies that the module lies in that place, and on the other side (D = 1) means far from balance line, locates in Zone of Pain
or Zone of Uselessness
.
Example output metrics extracted from boogeyman repo
+--------------------------+-------+----------+----------+-------+--------+--------------+-------------+----------+
| MODULE PATH | FILES | CONCRETE | ABSTRACT | FANIN | FANOUT | ABSTRACTNESS | INSTABILITY | DISTANCE |
+--------------------------+-------+----------+----------+-------+--------+--------------+-------------+----------+
| /domain/ | 9 | 5 | 2 | 12 | 15 | 0.286 | 0.556 | 0.159 |
| /gateway/repository/ | 4 | 2 | 0 | 1 | 6 | 0.000 | 0.857 | 0.143 |
| /gateway/service/ | 1 | 0 | 1 | 1 | 1 | 1.000 | 0.500 | 0.500 |
| /infrastructure/service/ | 8 | 4 | 0 | 1 | 26 | 0.000 | 0.963 | 0.037 |
| /usecase/interactor/ | 1 | 1 | 0 | 1 | 4 | 0.000 | 0.800 | 0.200 |
| /usecase/presenter/ | 1 | 0 | 1 | 2 | 1 | 1.000 | 0.333 | 0.333 |
| /usecase/repository/ | 2 | 0 | 2 | 5 | 2 | 1.000 | 0.286 | 0.286 |
| /controller/ | 1 | 1 | 0 | 0 | 4 | 0.000 | 1.000 | 0.000 |
+--------------------------+-------+----------+----------+-------+--------+--------------+-------------+----------+
Usage
In case exec file you downloaded's name is chio
.
Sample full params command
$ ./chio -l go -p ./ -d 1
Type -h
to get help. Return value be like
Usage of ./bin/chio-darwin-64:
-d string
dir as module, default n-depth (n) (default "n")
-l string
language(s): go (default "go")
-p string
path to module (default ".")
TODO list
Support language(s)
Load module strategies
- n-depth Directory level (group files in same dir as a module)
- 1-depth Directory level (WIP)
Run on local
Chio development environment requires:
- Golang (1.9.2 or higher). Install go here.
- dep (Go dependency management tool). Install go here.
Run by go
$ go run main.go
or check Makefile for building bin on your local.
Contribution
All contributions will be welcome in this project.
License
The MIT License (MIT). Please see LICENSE for more information.