Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

feat(rome_js_analyze): new lint rule noExcessiveComplexity #4657

Merged
merged 23 commits into from
Jul 6, 2023

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Jul 4, 2023

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.

@netlify
Copy link

netlify bot commented Jul 4, 2023

Deploy Preview for docs-rometools ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit efcc413
🔍 Latest deploy log https://app.netlify.com/sites/docs-rometools/deploys/64a5c238cf4d120008d9a7d7
😎 Deploy Preview https://deploy-preview-4657--docs-rometools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions 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
Copy link
Contributor

@ematipico ematipico left a 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
}

@github-actions github-actions bot added the A-Parser Area: parser label Jul 5, 2023
@arendjr
Copy link
Contributor Author

arendjr commented Jul 5, 2023

Alright, I think I've gone through all the comments here. Please let me know your thoughts!

@ematipico ematipico merged commit 8f46efb into rome:main Jul 6, 2023
18 checks passed
@arendjr arendjr deleted the cognitive-complexity branch July 6, 2023 10:34
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants