Skip to content

S3966: Raise issue on different location for using statements. #7358

Open
@mary-georgiou-sonarsource

Description

Requires MMF-2568 to be implementable.

S3966 currently covers two main categories of double disposal.
1.

    public void DisposedTwice()
   {
       var d = new Disposable();
       d.Dispose();
       d.Dispose(); // Noncompliant {{Resource 'd' has already been disposed explicitly or implicitly through a using statement. Please remove the redundant disposal.}}
   }
  public void Disposed_UsingStatement()
  {
      using (var d = new Disposable()) // Noncompliant {{Resource 'd = new Disposable()' has already been disposed explicitly or implicitly through a using statement. Please remove the redundant disposal.}}
      {
          d.Dispose();
      }
  }

The issue would be clearer for the user if in the case of Using statement, we'd raise in d.Dispose (as primary or secondary location).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Area: CFG/SECFG and SE related issues.Type: UXImprove any kind of user experience

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions