-
Notifications
You must be signed in to change notification settings - Fork 235
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
[Feature Request] Limiting template condition complexity #508
Comments
Love this feature request. Probably we can apply some version of cyclomatic complexity estimation. |
I'm not surprised |
Here's a simple estimation of cyclomatic complexity implemented in go https://github.com/fzipp/gocyclo/blob/master/gocyclo.go. It should be easy to port it to the Angular expression/template ASTs. |
If we want to test boolean expression complexity, this implementation seems to be fine: https://github.com/maddingo/checkstyle/blob/master/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/metrics/BooleanExpressionComplexityCheck.java |
We've got a payment process with conditions to reveal different steps of said process to push the user through it. An example of an *ngIf condition for revealing the Card entry step to the user:
This amount of condition complexity is dangerous because it's breakage can only be detected via E2E or Manual QA. During refactor another developer can completely break payments.
I think one way Codelyzer can help here is allowing us to limit the complexity of an
*ngIf
condition allowed in the view. The above example would throw that it's too complex and the condition needs to be moved into the Component class, of which can be unit tested:The text was updated successfully, but these errors were encountered: