go-kys

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2021 License: MIT

README

Actions Status codecov Go Reference

Go knowledge yield summary

Project demo

asciicast

Table of Contents

Glossary

Weighted Micro Function Points (WMFP) - a modern software sizing algorithm

Project description

Evaluation of WMFP metrics in human-minutes for given Golang code. Implemented in Go.

Project developed for the course Software Systems Analysis and Design (SSAD) at Innopolis University in F21 semester.

Importance

Software metrics help to estimate the size, price, or time consumption of software. There are no known open source solutions for counting the WMFP metrics, especially for Go. Thus, having a free alternative to proprietary software can be in demand.

Features

  • Count WMFP metric for a given golang source file
  • Ability to choose multiple files explicitly to count total metrics for them
  • Possibility to pick a folder and have all matching files summarized in metrics score
  • Recursive mode of scanning a folder

Installation

$ go install github.com/bragov4ik/go-kys/cmd/gokys@latest

CLI Usage

Default path to config file is config.xml

$ cd $HOME/go/bin
$ ./gokys -c <PATH_TO_CONFIG> a.go           # calculates for file
$ ./gokys -c <PATH_TO_CONFIG> .              # calculates for project
$ ./gokys -c <PATH_TO_CONFIG> a.go b.go c.go # calculates for multiple files

How it works

The algorithm calculates multiple metrics and combines them in order to get a result. The metrics are described below.

Cyclomatic Complexity

The Cyclomatic Complexity indicates the complexity of a program's flow.

This program calculates the complexities of each function by counting independent paths. It starts with the initial value of 1 and each time program encounters one of the if, for, case, ||, && statements it increases the value by corresponding to the statement's weight specified in the configuration file.

Halstead Complexity

Calculation of Halstead Complexity can be found here. The formula for Volume is used, as it seems more appropriate for the WMFP.

Comments Complexity

Measures the amount of effort spent on writing program comments. It calculates the number of words written in comments and multiplies by a weight specified in the configuration file.

Code Structure Complexity

Measures the amount of effort spent on the program structure such as separating code into classes, functions, and interfaces. It starts with the initial value of 0 and each time program encounters structure declaration, function declaration, or interface declaration it increases the value by the declaration's weight specified in the configuration file.

Arithmetic Intricacy

Measures the complexity of arithmetic calculations across the program. It starts with initial value of 0 and each time program encounters one of the + - * / % += -= *= /= %= ++ -- operators it increases value by operator's weight specified in configuration file.

Inline Data

Measures the amount of effort spent on embedding hard-coded data. It starts with the initial value of 0 and each time program encounters basic or composite literal it increases value by literal's weight specified in the configuration file

Summing Up

The program sums up all the above metrics to calculate total effort in human-minutes.

Contribution

To contribute to the project fork the repository and make a PR.

Important Note

Since there is no comprehensive description of the work of WMFP in open sources, some metrics were not implemented and some were implemented using our vision and understanding of these metrics.

RUP artifact

Link

Authors

  • Kirill Ivanov
  • Anatoliy Baskakov
  • Iskander Bakhtiyarov
  • Ivan Rybin

Directories

Path Synopsis
cmd
pkg
arithmetic
Package arithmetic calculates time spend on writing arithmetic expressions.
Package arithmetic calculates time spend on writing arithmetic expressions.
codestruct
Package with metric which checks general code structure.
Package with metric which checks general code structure.
comments
Package with metric which checks comment complexity
Package with metric which checks comment complexity
cyclocomp
Checks cyclo complexity of code using metric
Checks cyclo complexity of code using metric
halstead
Package with [Halstead complexity measures](https://en.wikipedia.org/wiki/Halstead_complexity_measures)
Package with [Halstead complexity measures](https://en.wikipedia.org/wiki/Halstead_complexity_measures)
inline
Metric for inline data complexity measurement
Metric for inline data complexity measurement
wmfp
Package with [wmfp](https://en.wikipedia.org/wiki/Weighted_Micro_Function_Points) metric calculator.
Package with [wmfp](https://en.wikipedia.org/wiki/Weighted_Micro_Function_Points) metric calculator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL