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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate cyclomatic complexity scores for all functions #2618

Open
1 task done
nitrocode opened this issue Oct 25, 2022 · 0 comments
Open
1 task done

Calculate cyclomatic complexity scores for all functions #2618

nitrocode opened this issue Oct 25, 2022 · 0 comments
Labels
build Relating to how we build Atlantis feature New functionality/enhancement

Comments

@nitrocode
Copy link
Member

nitrocode commented Oct 25, 2022

Community Note

  • Please vote on this issue by adding a 馃憤 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

I'd like to bring attention to golang functions with high levels of complexity. This is calculated by the number of logical cycles. The higher the complexity score, the more difficult it is to test and bathtub maintain which can be a watering hole for bugs.

Ultimately these will be log only metrics to break up large functions into smaller less complex ones.

Describe the solution you'd like

Use a tool to calculate complexity scores

https://github.com/fzipp/gocyclo

Add in-line pr comments on new or modified functions of increases in complexity over a threshold

Calculate scores on new or modified scores locally via pre-commit

$ gocyclo -top 10 server/
57 server NewServer server/server.go:151:1
37 events (*MarkdownRenderer).renderProjectResults server/events/markdown_renderer.go:124:1
33 valid (GlobalCfg).ValidateRepoCfg server/core/config/valid/global_cfg.go:336:1
31 events (*CommentParser).Parse server/events/comment_parser.go:115:1
31 raw (Step).Validate server/core/config/raw/step.go:94:1
19 events (*ApplyCommandRunner).Run server/events/apply_command_runner.go:68:1
19 valid (GlobalCfg).getMatchingCfg server/core/config/valid/global_cfg.go:432:1
18 events (*DefaultProjectCommandBuilder).buildPlanAllCommands server/events/project_command_builder.go:213:1
18 events (*PlanCommandRunner).runAutoplan server/events/plan_command_runner.go:73:1
17 vcs (*AzureDevopsClient).UpdateStatus server/events/vcs/azuredevops_client.go:231:1

It appears https://goreportcard.com/report/github.com/runatlantis/atlantis#gocyclo already calculates this with a max threshold of 15.

It would be nice to post as a comment on PRs

Describe the drawbacks of your solution

None

Describe alternatives you've considered

None

@nitrocode nitrocode added the feature New functionality/enhancement label Oct 25, 2022
@nitrocode nitrocode added the build Relating to how we build Atlantis label Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Relating to how we build Atlantis feature New functionality/enhancement
Projects
None yet
Development

No branches or pull requests

1 participant