-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Update: support class fields in the complexity
rule (refs #14857)
#14957
Conversation
I believe this can be done better with It's also quite possible that the rule could be entirely refactored to use only the code path analysis info when calculating the complexity as well, but that would require extensive testing. |
b851e2b
to
7f86df8
Compare
Updated the code to use the new code path analysis, and I think this looks better now. |
Agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I think adding the class field name would be a great enhancement but not necessary for this first pass.
* to the enclosing function's complexity, but their own complexity should be evaluated. | ||
*/ | ||
if ( | ||
codePath.origin !== "function" && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This came in handy! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very! This could have been done in other ways, but it wouldn't look as nice and simple - it would be always difficult to trace what's happening when the initializer is a function.
closing-reopening to see if that will fix the EasyCLA check. |
All checks are green now, so merging. |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
refs #14857, fixes #14591 (comment)
What changes did you make? (Give an overview)
Update the
complexity
rule to supports class fields, in a way that the rule now treats them as functions:Is there anything you'd like reviewers to focus on?
getFunctionNameWithKind
later as an enhancement.