Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
>
Examples of errors detected by the V306…

Examples of errors detected by the V3062 diagnostic

V3062. An object is used as an argument to its own method. Consider checking the first actual argument of the 'Foo' method.


Accord.Net

V3062 An object 'observations' is used as an argument to its own method. Consider checking the first actual argument of the 'WeightedMean' method. Accord.Statistics InverseGaussianDistribution.cs 325


public static double WeightedMean(this double[] values,
                                       double[] weights)
{
  ....
}

public override void Fit(double[] observations,
                         double[] weights,
                         IFittingOptions options)
{
  ....
  mean = observations.WeightedMean(observations);
  ....
}

AWS SDK for .NET

V3062 An object 'attributeName' is used as an argument to its own method. Consider checking the first actual argument of the 'Contains' method. AWSSDK.MobileAnalytics.Net45 CustomEvent.cs 261


public string GetAttribute(string attributeName)
{
  if(string.IsNullOrEmpty(attributeName))
  {
    throw new ArgumentNullException("attributeName");
  }
  string ret = null;
  lock(_lock)
  {
    if(attributeName.Contains(attributeName))  // <=
      ret = _attributes[attributeName];
  }
  return ret;
}

.NET 7

V3062 An object 'DiagnosticLocation' is used as an argument to its own method. Consider checking the first actual argument of the 'Equals' method. LibraryImportGenerator.cs 43


public bool Equals(IncrementalStubGenerationContext? other)
{
  return    other is not null
         && StubEnvironment.AreCompilationSettingsEqual(Environment,
                                                        other.Environment)
         && SignatureContext.Equals(other.SignatureContext)
         && ContainingSyntaxContext.Equals(other.ContainingSyntaxContext)
         && StubMethodSyntaxTemplate.Equals(other.StubMethodSyntaxTemplate)
         && LibraryImportData.Equals(other.LibraryImportData)
         && DiagnosticLocation.Equals(DiagnosticLocation)     // <=
         && ForwardedAttributes.SequenceEqual(
              other.ForwardedAttributes,
              (IEqualityComparer<AttributeSyntax>)
                SyntaxEquivalentComparer.Instance)
        && GeneratorFactoryKey.Equals(other.GeneratorFactoryKey)
        && Diagnostics.SequenceEqual(other.Diagnostics);
}

Similar errors can be found in some other places:

  • V3062 An object 'DiagnosticLocation' is used as an argument to its own method. Consider checking the first actual argument of the 'Equals' method. JSImportGenerator.cs 42
  • V3062 An object 'DiagnosticLocation' is used as an argument to its own method. Consider checking the first actual argument of the 'Equals' method. JSExportGenerator.cs 37

nopCommerce

V3062 An object 'other' is used as an argument to its own method. Consider checking the first actual argument of the 'Equals' method. ImportManager.cs 3392


public partial class CategoryKey
{
  ....

  public bool Equals(CategoryKey y)
  {
    if (y == null)
      return false;

    if (Category != null && y.Category != null)
      return Category.Id == y.Category.Id;

    if (....)
    {
      return false;
    }

    return Key.Equals(y.Key);
  }

  public override bool Equals(object obj)
  {
    var other = obj as CategoryKey;
    return other?.Equals(other) ?? false;        // <=
  }
}