Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
/ lcom4go Public archive

Compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.

License

Notifications You must be signed in to change notification settings

yahoojapan/lcom4go

Repository files navigation

LCOM4go

LCOM4go is a tool to compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.

⚠️ This project is archived and no longer maintained.


📌 Notice

This project has been archived as of August 2025.
We no longer maintain it.

Why?

LCOM4go was created to measure code readability using the LCOM4 (Lack of Cohesion of Methods) metric.
However, as AI-based code generation becomes the standard, traditional readability metrics have become less meaningful.

Instead, we are shifting our focus toward:

  • AI-friendliness – Is the code easy for LLMs to understand and modify?
  • Prompt-based regeneration – Can the code be reliably edited via prompts?
  • Next-gen maintainability – Beyond cohesion, toward metrics like “promptability” or “regenerability”

In a world where code is generated, not written by hand,
maintainability must also evolve.


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

About

Compute LCOM4, Lack of Cohesion of Methods metrics ver.4, for golang projects.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages