Buy me a coffeeBuy me a coffee

Cyclop is a Go linter that calculates cyclomatic complexities of functions or packages in Go source code.

You can use it as a standalone application or using golangci-lint. I suggest to use the second one (it’s more handy).

The default configuration looks like this:

    # the maximal code complexity to report
    max-complexity: 10
    # the maximal average package complexity. If it's higher than 0.0 (float) the check is enabled (default 0.0)
    package-average: 0.0
    # should ignore tests (default false)
    skip-tests: false

Of course, don’t forget to enable the linter.

    - cyclop

I found it very helpful when the function’s lenght starts to grow. Setting some hard limits may be helpful to avoid creating ‘monsters’ in your code.