CompreGo is a tool for calculating comprehensibility of Go projects. Developers can use the tool to measure the comprehensibility of a project and identify which fragments need to be refactored for improving comprehensibility.
These instructions will get you a copy of the project up and running on your local machine for development or testing purposes.
Golang must be installed (>= v1.15.7). To install golang in ubuntu, run-
sudo apt-get install golang
At first, download the project and navigate to the source files
cd CompreGo/comprego
Build the project with
go build
CompreGo calculates the following comprehensibility metrics:
- Too Long Files
- Too Long Methods
- Nesting Depth
- Lack of Cohesive Comments
- Duplicate Comments
To find these metrics, run-
./comprego -d project-directory
- “-TLF”: View list of too long files
- “-TLM”: View list of too long methods
- “-ND”: View list of deeply nested methods
- “-LCC”: View list of non-cohesive comments
- “-DC”: View list of duplicate comments
- “-ALL”: View details of all the five metrics
For example-
./comprego -d project-directory/ -TLM
The default thresholds for TLF, TLM and ND are 750, 75 and 5 respectively. However, each project and its maintainers are different and thus thresholds may need to be changed. For this reason, CompreGo has a provision for customizing these thresholds. These thresholds can be changed by adding the following arguments while running the tool:–
- “-lf number”: Set customized threshold for Too Long Files
- “-lm number”: Set customized threshold for Too Long Methods
- “-nd number”: Set customized threshold for Nesting Depth
Where, number represents the customized threshold value.