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): Make the exception of returning "this" work #4251

Closed
yassin-kammoun-sonarsource opened this issue Oct 9, 2023 · 0 comments · Fixed by #4320
Assignees
Labels
type: false positive Issue is reported when it should NOT be
Milestone

Comments

@yassin-kammoun-sonarsource
Copy link
Contributor

The rule reports functions with multiple return statements of different types. Also, it is supposed to make exceptions to functions whose one of its return statements returns this. However, the exception is not working, and a false positive is raised on the following snippet:

String.prototype.foo = function()
{
    if (this.length == 10)
        return this.substring(5);
    
    return this;
}

Reported in https://community.sonarsource.com/t/javascript-s3800-fp-when-working-on-prototype-function/102118

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: false positive Issue is reported when it should NOT be
Projects
None yet
2 participants