clusterpedia
clusterpedia copied to clipboard
Decrease clusterpedia functions cyclomatic complexity
What would you like to be added?
Decrease clusterpedia functions cyclomatic complexity
Why is this needed?
I found some functions on clusterpedia is too long and not friendly to fresh developers.
I add gocyclo to gci linters and set the min-complexity to 15 and I found many functions cyclomatic complexity are very high.
Do we have plan to improve the code complexity.
/cc @Iceber
Hi @wuyingjun-lucky, Thanks for opening an issue! We will look into it as soon as possible.
Details
Instructions for interacting with me using comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.
@wuyingjun-lucky
This plugin only works with pull requests.
Details
Instructions for interacting with me using comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the gh-ci-bot repository.
@Iceber
Sometimes abstracting functions that are not reused or independent enough can lead to incoherent code, and it may be clearer to distinguish a set of logic by ordered line breaks and comments. I find that golang's function abstraction is probably more like c than python.
I'm not against abstracting functions, and it's good for functions that are too complex or that can be extracted to make the logic clearer.
The common if err
in golang seems to affect gocyclo
. Also, I think setting the min-complexity to 15 may be a bit stringent.
BTW, I saw some warnings that there are some linters that are deprecated.
golangci-lint run
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused.
This looks like it could be an good first issue, don't you think?
yes !
Sometimes abstracting functions that are not reused or independent enough can lead to incoherent code, and it may be clearer to distinguish a set of logic by ordered line breaks and comments.
Or we can make more comments to the complex functions. Some functions is hard .
Yes, comments are necessary, and clusterpedia lacks a lot of them, including function names, logic within functions, and field comments within clusterpedia-io/api.
We can add them and I will also add comments for some complex functions and optimize these complex functions as soon as possible.