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 S1226: Variables that are passed as an argument to a method should be considered as read #2249

Closed
valhristov opened this issue Jan 28, 2019 · 1 comment
Assignees
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Milestone

Comments

@valhristov
Copy link
Contributor

valhristov commented Jan 28, 2019

The following code snippet should not raise an issue:

...
catch (Exception e)
{
    while (e != null)
    {
        list.Add(FormatMessage(e));
        e = e.InnerException;
    }
}

Originally posted by @rymeskar in #630 (comment)

Tip: the rule considers a variable read only if it appears on the right hand side of an assignment.

@andrei-epure-sonarsource
Copy link
Contributor

Could not reproduce, I added reproducing tests in #2372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Type: False Positive Rule IS triggered when it shouldn't be.
Projects
None yet
Development

No branches or pull requests

3 participants