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

Ignore React FC for #Cognitive Complexity #226

Closed
papuruth opened this issue Jun 17, 2021 · 5 comments
Closed

Ignore React FC for #Cognitive Complexity #226

papuruth opened this issue Jun 17, 2021 · 5 comments

Comments

@papuruth
Copy link

I want to report a bug.
I have upgraded eslint-plugin-sonarjs to latest version i.e., 0.8.0-125, but still I'm receiving error for cognitive complexity on React FC. An screenshot has been attached.
image

Reproducer

// minimal reproducer if relevant
const RenderContent = (props) => {
  const responsive = {
    // some code here
  };
 // Component code continues
}

Expected behavior
React FC should be ignored from this rule.

eslint-plugin-sonarjs version: 0.8.0-125

eslint version: 6.6.0

Node.js version: 12.16.1

Rule key: S3776

@vilchik-elena
Copy link
Contributor

To be clear, React function components are not completely ignored, only there own complexity is counted (excluding nested functions). So I can't tell if you have FP looking at such reproducer.

@papuruth
Copy link
Author

But in my use case, I see that even the nested functions are being counted. Shouldn't the FCs behave like Class Components?

@vilchik-elena
Copy link
Contributor

@papuruth As I said already for FC "there own complexity is counted (excluding nested functions)". If you observe different behaviour please post full reproducer.

@vilchik-elena
Copy link
Contributor

FYI there is one fix on the way (#245) so may be that was your problem

@vilchik-elena
Copy link
Contributor

closing the issue as no answer from the reporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants