skywire icon indicating copy to clipboard operation
skywire copied to clipboard

add `gocyclo` to CI checks

Open 0pcom opened this issue 1 year ago • 0 comments

The go report card for skywire shows 100% in every category except gocyclo

It would be worthwhile to include the results of the gocyclo checks in the CI pipeline ; with additional makefile directive which corresponds to it's use.

The current gocyclo results are as follows:

gocyclo 96%

Gocyclo calculates cyclomatic complexities of functions in Go source code. The cyclomatic complexity of a function is calculated according to the following rules: 1 is the base complexity of a function +1 for each 'if', 'for', 'case', '&&' or '||' Go Report Card warns on functions with cyclomatic complexity > 15.

cmd/skywire-cli/commands/visor/top.go Line 229: warning: cyclomatic complexity 64 of function eventLoop() is high (> 15) (gocyclo) Line 94: warning: cyclomatic complexity 23 of function parseArgs() is high (> 15) (gocyclo) Line 411: warning: cyclomatic complexity 16 of function run() is high (> 15) (gocyclo) pkg/visor/hypervisor.go Line 624: warning: cyclomatic complexity 38 of function (*Hypervisor).putApp() is high (> 15) (gocyclo) pkg/visor/init.go Line 890: warning: cyclomatic complexity 17 of function getRouteSetupHooks() is high (> 15) (gocyclo) Line 1411: warning: cyclomatic complexity 16 of function initDmsgpty() is high (> 15) (gocyclo) cmd/skywire-cli/commands/rewards/ui.go Line 241: warning: cyclomatic complexity 114 of function server() is high (> 15) (gocyclo) cmd/skywire-cli/commands/log/st.go Line 48: warning: cyclomatic complexity 42 of function makeTree() is high (> 15) (gocyclo) pkg/visor/visorconfig/config.go Line 143: warning: cyclomatic complexity 20 of function MakeDefaultConfig() is high (> 15) (gocyclo) internal/vpn/client.go Line 345: warning: cyclomatic complexity 19 of function (*Client).serveConn() is high (> 15) (gocyclo) pkg/visor/cmd.go Line 60: warning: cyclomatic complexity 19 of function init() is high (> 15) (gocyclo) pkg/router/router.go Line 487: warning: cyclomatic complexity 16 of function (*router).saveRouteGroupRules() is high (> 15) (gocyclo)

Actionability

the results of the gocyclo test indicates areas where the code may be improved to reduce overall cyclomatic complexities of functions. They should not be considered breaking errors, but the results of these tests should be more visible in the CI pipeline so that they may be addressed in the future.

0pcom avatar Sep 01 '24 21:09 0pcom