Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decrease clusterpedia functions cyclomatic complexity #348

Open
wuyingjun-lucky opened this issue Sep 8, 2022 · 8 comments
Open

Decrease clusterpedia functions cyclomatic complexity #348

wuyingjun-lucky opened this issue Sep 8, 2022 · 8 comments
Labels
kind/feature New feature

Comments

@wuyingjun-lucky
Copy link
Member

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.
image
Do we have plan to improve the code complexity.

/cc @Iceber

@wuyingjun-lucky wuyingjun-lucky added the kind/feature New feature label Sep 8, 2022
@clusterpedia-bot
Copy link

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.

@clusterpedia-bot
Copy link

@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.

@wuyingjun-lucky
Copy link
Member Author

@Iceber

@Iceber
Copy link
Member

Iceber commented Sep 8, 2022

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.

@Iceber
Copy link
Member

Iceber commented Sep 8, 2022

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?

@wuyingjun-lucky
Copy link
Member Author

yes !

@wuyingjun-lucky
Copy link
Member Author

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 .

@Iceber
Copy link
Member

Iceber commented Sep 8, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature
Projects
None yet
Development

No branches or pull requests

3 participants