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

Modify rule S3776: Clarify the behavior of function nesting #4303

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rules/S3776/javascript/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ include::../intro.adoc[]

include::../why.adoc[]

Note that the calculation of cognitive complexity at function level deviates from the documented process. Given the functional nature of JavaScript, nesting functions is a prevalent practice, especially within frameworks like React.js. Consequently, the cognitive complexity of functions remains independent from one another. This means that the complexity of a nesting function does not increase with the complexity of nested functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I moved this explanation here so that it appears right after the sentence "The method of computation is fully detailed in the pdf linked in the resources." which is included by include::../why.adoc[].

=== What is the potential impact?

include::../impact.adoc[]
Expand All @@ -24,8 +26,6 @@ function greet(name) {

include::../how-with-null-safe.adoc[]

Note that the calculation of cognitive complexity deviates from the documented process when functions are nested. Given the functional nature of JavaScript, nesting functions is a prevalent practice, especially within frameworks like React.js. Consequently, the cognitive complexity of functions remains independent of each other.

=== Code examples

**Extraction of a complex condition in a new function.**
Expand Down