Skip to content

Cyclomatic complexity #175

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

Merged
merged 11 commits into from
Feb 13, 2025
Merged

Cyclomatic complexity #175

merged 11 commits into from
Feb 13, 2025

Conversation

RubenHalman
Copy link
Member

@RubenHalman RubenHalman commented Feb 12, 2025

Rule Id Description Reference
Cyclomatic Complexity The number of loops and decision rules, plus the number of decisions. Use subflows to reduce the cyclomatic complexity within a single flow, ensuring maintainability and simplicity. tbd

This PR includes a new rule and some minor adjustments to the Flow Model, allowing for some simple metadata type preprocessing(Counting loops etc)

Todo

  • Fix Flow Tests? @junners I love how ESLint now prevents a push when tests are failing, but as a result, I commented out the one failing test that I have not been able to fix yet. See also a detailed comment in the PR.
  • Update docs

@RubenHalman RubenHalman added the new rule A new suggestion for a best practice to be included in the scanner label Feb 12, 2025
@junners
Copy link
Member

junners commented Feb 12, 2025

Eeeey as always this is good! My stuff is a WIP, this actually follows the McCabe counting system.

Mine was more like the number of paths you can take towards the end 😂

@RubenHalman
Copy link
Member Author

RubenHalman commented Feb 12, 2025

@junners One reason I have not proceeded with this rule is that I am unsure on what the default threshold should be. From my experience a lot of organizations are currently dealing with high cyclomatic complexity in Flows and I think we should start with a rather leniant threshold. Although it is fully configurable, I am very keen to learn what your opinion is on what could be an acceptable threshold

@junners
Copy link
Member

junners commented Feb 12, 2025

My rollout plan was to atleast make it a note level, then via sfdx/vsce collect usage stats. We won't fully know until we actually get some data

@junners
Copy link
Member

junners commented Feb 13, 2025

Just logged in to my personal machine. I'm looking at this rn

@junners
Copy link
Member

junners commented Feb 13, 2025

Kk i've fixed some of the changes 👍🏻 I'll add in some unit tests on cyclomatic complexity

@junners
Copy link
Member

junners commented Feb 13, 2025

@RubenHalman - do you think it's best to activate this upfront? Like add it in the defaultstore

Edit: Let's release this as note

@junners junners merged commit 2242627 into master Feb 13, 2025
3 checks passed
@junners junners deleted the cyclomatic-complexity branch February 13, 2025 05:23
@junners
Copy link
Member

junners commented Feb 13, 2025

I'll do a release in the next couple of days~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new rule A new suggestion for a best practice to be included in the scanner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants