This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
feat(rome_js_analyze): new lint rule noExcessiveComplexity
#4657
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
✅ Deploy Preview for docs-rometools ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
github-actions
bot
added
A-Linter
Area: linter
A-Project
Area: project configuration and loading
A-Diagnostic
Area: errors and diagnostics
labels
Jul 4, 2023
denbezrukov
reviewed
Jul 5, 2023
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
ematipico
reviewed
Jul 5, 2023
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 is a fantastic contribution; thank you! 🚀
I left some suggestions, let me know what you think.
We should add some testing case where we test function expressions:
var fn = function() {
// lot of complexity in here
}
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
denbezrukov
reviewed
Jul 5, 2023
crates/rome_js_analyze/src/analyzers/nursery/no_excessive_complexity.rs
Outdated
Show resolved
Hide resolved
arendjr
force-pushed
the
cognitive-complexity
branch
from
July 5, 2023 14:35
7865746
to
25a2b60
Compare
Alright, I think I've gone through all the comments here. Please let me know your thoughts! |
ematipico
approved these changes
Jul 6, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
A-Diagnostic
Area: errors and diagnostics
A-Linter
Area: linter
A-Parser
Area: parser
A-Project
Area: project configuration and loading
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
As briefly discussed, this PR introduces a rule for calculating the cognitive complexity of functions based on a paper from SonarSource: https://www.sonarsource.com/docs/CognitiveComplexity.pdf
Test Plan
Tests are included in the PR, but given the complexity of the rule, I will admit the coverage might need a bit more work still.