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

Fix FP S3800 (function-return-type): Exceptions for React components #4549

Closed
ericmorand-sonarsource opened this issue Feb 2, 2024 · 2 comments
Labels
jira-import_24-04-2024 The issue have been imported in jira on 24-04-2024 mmf-2934 https://sonarsource.atlassian.net/browse/MMF-2934

Comments

@ericmorand-sonarsource
Copy link
Contributor

ericmorand-sonarsource commented Feb 2, 2024

Add an exception for React components:

  • ignore when returning null or false

This issue was extracted from #4527 to not delay the sanitation fix.

@ericmorand-sonarsource ericmorand-sonarsource added the mmf-2934 https://sonarsource.atlassian.net/browse/MMF-2934 label Feb 2, 2024
@ericmorand-sonarsource
Copy link
Contributor Author

I was not able to reproduce the first issue (React components, ignore when returning null or false): based on my testings with the current state of SonarJS, the S3800 rule never triggers when either the render method of a React Component or a React FunctionComponent returns false conditionally. Typically, the following code is compliant according to S3800:

export const MyComponent = ({flag}) => {
    if (flag) {
        return <>5</>;
    }

    return false;
};

I'll try to get more information about the edge case from the developer who dismissed the rule because of conditionally returning false.

@ericmorand-sonarsource ericmorand-sonarsource changed the title Fix FP S3800 (function-return-type): Exceptions for React components Fix FP S3800 (function-return-type): Exceptions for React components Feb 2, 2024
@Wohops Wohops added the jira-import_24-04-2024 The issue have been imported in jira on 24-04-2024 label Apr 24, 2024
@Wohops Wohops closed this as completed Apr 24, 2024
@Wohops
Copy link
Contributor

Wohops commented Apr 24, 2024

Migrated to Jira. New ticket number: JS-31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-import_24-04-2024 The issue have been imported in jira on 24-04-2024 mmf-2934 https://sonarsource.atlassian.net/browse/MMF-2934
Projects
None yet
Development

No branches or pull requests

2 participants