Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yahoojapan/lcom4go
Compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.
https://github.com/yahoojapan/lcom4go
go golang lcom4 metrics
Last synced: 12 days ago
JSON representation
Compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.
- Host: GitHub
- URL: https://github.com/yahoojapan/lcom4go
- Owner: yahoojapan
- License: mit
- Created: 2022-04-08T00:41:48.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-13T07:05:01.000Z (about 1 year ago)
- Last Synced: 2024-11-14T00:34:04.245Z (about 1 month ago)
- Topics: go, golang, lcom4, metrics
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 21
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - lcom4go
README
# LCOM4go
LCOM4go is a tool to compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.# Install
```
$ go install --ldflags "-s -w" --trimpath github.com/yahoojapan/lcom4go/cmd/lcom4@latest
```# Usage
### Directory use installed binary (recommended)```
$ $(go env GOPATH)/bin/lcom4 ./...
...$ $(go env GOPATH)/bin/lcom4 net/http
...
```### Through the go vet
```
$ go vet -vettool=$(go env GOPATH)/bin/lcom4 ./...
...$ go vet -vettool=$(go env GOPATH)/bin/lcom4 net/http
...
```# LCOM4 definition
https://objectscriptquality.com/docs/metrics/lack-cohesion-methods-lcom4# Examples
The lcom4 of `s0` is 1 because both `method1` and `method2` use `s0.m`.
```
type s0 struct {
m int
}func (a s0) method1() int {
return a.m
}
func (a s0) method2() int {
return -a.m
}
```The lcom4 of `s1` is 2 because `method3` uses `a.n` which is not used by `method1` and `method2`.
```
type s1 struct {
m int
n int
}func (a s1) method1() int {
return a.m
}
func (a s1) method2() int {
return -a.m
}
func (a s1) method3() int {
return -a.n
}
```# Running the tests
```
go test ./...
```# License
This software is released under the MIT License, see the license file.
# References
* https://www.aivosto.com/project/help/pm-oo-cohesion.html#LCOM4
* https://kenchon.github.io/cohesive-code
* https://objectscriptquality.com/docs/metrics/lack-cohesion-methods-lcom4
* https://github.com/FujiHaruka/eslint-plugin-lcom
* https://metacpan.org/release/JOENIO/Analizo-1.20.3/source/lib/Analizo/Metric/LackOfCohesionOfMethods.pm
* https://github.com/potfur/lcom
* http://www.isys.uni-klu.ac.at/PDF/1995-0043-MHBM.pdf
* https://github.com/cleuton/jqana