Unicorn with delicious cookie
Мы используем куки, чтобы пользоваться сайтом было удобно.
Хорошо
to the top
>
>
>
Примеры ошибок, обнаруженных с...

Примеры ошибок, обнаруженных с помощью диагностики V3062

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;        // <=
  }
}