loov / goda

Go Dependency Analysis toolkit
MIT License
1.37k stars 45 forks source link

what is loc ? #75

Closed SkybuckFlying closed 4 months ago

SkybuckFlying commented 4 months ago

V:\go-vite\release v2.14>goda cut ./...:all github.com/vitelabs/go-vite/v2/cmd/gvite in:0 pkgs:12 size:53.7KB loc:1692 github.com/vitelabs/go-vite/v2/ledger/test_tools in:0 pkgs:2 size:4.3KB loc:144 github.com/vitelabs/go-vite/v2/cmd/updater_consensus in:0 pkgs:1 size:0.8KB loc:37 github.com/vitelabs/go-vite/v2/cmd/printer/vote in:0 pkgs:1 size:2.7KB loc:86

SkybuckFlying commented 4 months ago

Also what is in ?:

github.com/pkg/errors in:24 pkgs:1 size:12.8KB loc:461 github.com/vitelabs/go-vite/v2/interfaces in:30 pkgs:1 size:7.8KB loc:226 github.com/vitelabs/go-vite/v2/interfaces/core in:37 pkgs:1 size:26.0KB loc:901 github.com/vitelabs/go-vite/v2/log15 in:45 pkgs:4 size:77.1KB loc:2558 github.com/vitelabs/go-vite/v2/common/types in:58 pkgs:1 size:19.0KB loc:645

egonelbre commented 4 months ago

It's in is the number of incoming edges -- i.e. how many other packages import the specific package. loc is the lines of code. So roughly you can translate it as "You need modify in packages and replace the loc codes" to remove that specific dependency.

egonelbre commented 4 months ago

If you run goda cut --help then it'll show more details in what's being formatted:

cut <expr>:
        Print information about indirect-dependencies.
        It shows packages whose removal would remove the most indirect dependencies.

        See "help expr" for further information about expressions.
        See "help format" for further information about formatting.
  -exclude string
        package expr to exclude from output
  -f string
        info formatting (default "{{.ID}}\tin:{{.InDegree}}\tpkgs:{{.Cut.PackageCount}}\tsize:{{.Cut.AllFiles.Size}}\tloc:{{.Cut.Go.Lines}}")
  -noalign
        disable aligning tabs
  -std
        print std packages

And then you can continue with goda help format to get more details:

Formatting allows to add useful information about packages.

Formatting uses -f flag for specifying the output of each package.
goda uses https://pkg.go.dev/text/template for templating and it allows
for extensive formatting.

Each package node in goda has information about the package itself,
and its statistics. Additionally there is a summary of downstream
and upstream statistics:

    type Node struct {
        *Package

        ImportsNodes []*Node

        Stat Stat // Stats about the current node.
        Up   Stat // Stats about upstream nodes.
        Down Stat // Stats about downstream nodes.
...