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

Rule 5.1.1 Avoid too long functions, no more than 30 lines (non-empty, non-comment) #335

Closed
kentr0w opened this issue Sep 29, 2020 · 0 comments · Fixed by #341
Closed

Rule 5.1.1 Avoid too long functions, no more than 30 lines (non-empty, non-comment) #335

kentr0w opened this issue Sep 29, 2020 · 0 comments · Fixed by #341
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@kentr0w
Copy link
Collaborator

kentr0w commented Sep 29, 2020

The function should be able to be displayed on one screen and only implement one certain logic. Too long function often means that the function is too complicated and can be split or be more primitive.

Exception: Some functions that implement complex algorithms may exceed 30 lines due to the aggregation and comprehensiveness. Linter warnings for such functions can be suppressed.

Even if a long function works very well right now, once someone else modifies it, new problems or bugs may appear due to the complex logic. It is recommended to split such functions into several separated functions that are shorter and easier to manage, so that others can read and modify the code properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants