Golangci-lint: gocyclo min-complexity should be max-complexity

Created on 21 Jan 2019  路  11Comments  路  Source: golangci/golangci-lint

The value used to configure gocyclo is a maximum allowed complexity threshold. min-complexity is a bit confusing.

golangci-lint has version 1.12.5 built from 609de32 on 2018-12-23T09:42:24Z
config docs stale

Most helpful comment

This is interesting what is the purpose of min-complexity? you want the code to have a minimal complexity?

Anyone using this?

All 11 comments

hi!
interesting note, you are right. We can support both options for backwards compatibility and suggest only max-complexity for new users

I can only see min-complexity in the code: https://github.com/golangci/golangci-lint/blob/master/pkg/config/config.go#L132. @jirfag is this an undocumented configuration option?

@mbana are you talking about max-complexity? it isn't implemented yet

@jirfag yes.
OK, thanks for confirming.

This is interesting what is the purpose of min-complexity? you want the code to have a minimal complexity?

Anyone using this?

This seems broken, when I'm using running gocyclo -over 10 ./backend I get several files with up to 15 in complexity. When I then run golangci-lint run --config backend/.golangci.yml ./backend/... with enable-all: true set in .golangci.yml it does not report any error at all.

I found the issue. MinComplexity is default 0 and not 10 as stated in the default config. min-complexity needs to be set in order for this linter to be enabled.

So it appears to be 30 that's default. It actually states 30 in a comment but then the value itself is different which I found confusion for an example configuration.

# minimal code complexity to report, 30 by default (but we recommend 10-20)
    min-complexity: 10

I am bit confused as well by this setting. Is it the minimal value at which the code is considered too complex or something else. If my understanding is correct, don't you think it should be called max-complexity?

A minimal repository demonstrating the effects of different values would be very useful at this point.

Thanks.

@mbana yes, it is the minimal value at which the code is considered too complex. It's the same as --over in gocyclo

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DarthHater picture DarthHater  路  4Comments

moolibdensplk picture moolibdensplk  路  4Comments

bacongobbler picture bacongobbler  路  4Comments

kipply picture kipply  路  4Comments

KeepMasterBranch picture KeepMasterBranch  路  3Comments