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

S2259: Reset constraints on calls in static methods #6100

Closed
martin-strecker-sonarsource opened this issue Sep 15, 2022 · 1 comment · Fixed by #6145
Closed

S2259: Reset constraints on calls in static methods #6100

martin-strecker-sonarsource opened this issue Sep 15, 2022 · 1 comment · Fixed by #6145
Assignees
Labels
Area: C# C# rules related issues. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Milestone

Comments

@martin-strecker-sonarsource
Copy link
Contributor

Same as calls with a this receiver (aka instance methods) reset field constraints, calls to static methods should also reset field constraints:

public class C
{
  static object field;
  static void M()
  {
    field = null; // learn about field
    OtherStaticMethod();
    field.ToString(); // Compliant
  }
}
@martin-strecker-sonarsource martin-strecker-sonarsource added Type: Improvement Area: CFG/SE CFG and SE related issues. Area: C# C# rules related issues. labels Sep 15, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added this to the 8.45 milestone Sep 15, 2022
@github-actions github-actions bot added this to Improvement in Backlog Sep 15, 2022
@pavel-mikula-sonarsource
Copy link
Contributor

These should reset static fields only. Static method cannot change instance fields

@pavel-mikula-sonarsource pavel-mikula-sonarsource removed this from the 8.46 milestone Sep 29, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource moved this from In progress to Review in progress in Best Kanban Sep 30, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules. and removed Area: CFG/SE CFG and SE related issues. labels Sep 30, 2022
@github-actions github-actions bot moved this from Improvement to CFG/SE FPs in Backlog Sep 30, 2022
@martin-strecker-sonarsource martin-strecker-sonarsource added Area: CFG/SE CFG and SE related issues. and removed Type: Improvement labels Sep 30, 2022
@github-actions github-actions bot moved this from Review in progress to In progress in Best Kanban Oct 3, 2022
@github-actions github-actions bot moved this from In progress to Review in progress in Best Kanban Oct 4, 2022
Backlog automation moved this from CFG/SE FPs to Done Oct 5, 2022
Best Kanban automation moved this from Review in progress to Validate Peach Oct 5, 2022
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. Area: CFG/SE CFG and SE related issues. Type: CFG/SE FPs Rule IS triggered when it shouldn't be for CFG and SE rules.
Projects
Best Kanban
  
Done
Backlog
  
Done
Development

Successfully merging a pull request may close this issue.

2 participants