Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
>
>
>
Examples of errors detected by the V309…

Examples of errors detected by the V3093 diagnostic

V3093. The operator evaluates both operands. Perhaps a short-circuit operator should be used instead.


Accord.Net

V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. Accord.Math JaggedSingularValueDecompositionF.cs 461


public JaggedSingularValueDecompositionF(
         Single[][] value,
         bool computeLeftSingularVectors,
         bool computeRightSingularVectors,
         bool autoTranspose,
         bool inPlace)
{
  ....
  if ((k < nct) & (s[k] != 0.0))
  ....
}

Similar errors can be found in some other places:

  • V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. Accord.Math JaggedSingularValueDecompositionF.cs 510
  • V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. Accord.Math JaggedSingularValueDecompositionF.cs 595
  • V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. Accord.Math JaggedSingularValueDecomposition.cs 461
  • And 3 additional diagnostic messages.

Old NASA World Wind (C#)

V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. utils.cs 280


public static String GetDocumentSource(....)
{
  ....
  int iSize = 2048;
  byte[] bytedata = new byte[2048];
  int iBOMLength = 0;

  while (true)
  {
    iSize = memstream.Read(bytedata, 0, bytedata.Length);
    if (iSize > 0)
    {
      if (!IsUnicodeDetermined)
      {
        ....
        if ((bytedata[0] == 0xEF) &
            (bytedata[1] == 0xBB) &
            (bytedata[2] == 0xBF)) //UTF8
            {
              IsUTF8 = true;
              IsBOMPresent = true;
            }

        if (!IsUTF16LE & !IsUTF16BE & !IsUTF8)
         {
            if ((bytedata[1] == 0) &
                (bytedata[3] == 0) &
                (bytedata[5] == 0) &
                (bytedata[7] == 0))
                {
                  IsUTF16LE = true; //best guess
                }
          }
      ....
    }
  }
  ....
}

Similar errors can be found in some other places:

  • V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. utils.cs 291

NUnit

V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. nunit.framework-2.0 SubPathConstraint.cs 55


public class SubPathConstraint : PathConstraint
{
    protected override bool Matches(string actual)
    {
      return actual != null &
        IsSubPath(Canonicalize(expected), Canonicalize(actual));
    }
}

public abstract class PathConstraint : StringConstraint
{
    protected string Canonicalize(string path)
    {
        if (Path.DirectorySeparatorChar !=
            Path.AltDirectorySeparatorChar)
            path = path.Replace(Path.AltDirectorySeparatorChar,
                                Path.DirectorySeparatorChar);
        ....
    }
}

Azure PowerShell

V3093 The '|' operator evaluates both operands. Perhaps a short-circuit '||' operator should be used instead. PSKeyVaultCertificatePolicy.cs 114


internal CertificatePolicy ToCertificatePolicy()
{
  ....
  if (!string.IsNullOrWhiteSpace(SubjectName) ||
    DnsNames != null ||
    Ekus != null ||
    KeyUsage != null |        // <=
    ValidityInMonths.HasValue)
  {
    ....
  }
  ....
}

Chocolatey

V3093 [CWE-480] The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. Platform.cs 64


public static PlatformType get_platform()
{
  switch (Environment.OSVersion.Platform)
  {
    case PlatformID.MacOSX:
    {
      ....
    }
    case PlatformID.Unix:
    if(file_system.directory_exists("/Applications")
      & file_system.directory_exists("/System")
      & file_system.directory_exists("/Users")
      & file_system.directory_exists("/Volumes"))
      {
        return PlatformType.Mac;
      }
        else
          return PlatformType.Linux;
    default:
      return PlatformType.Windows;
  }
}

Open XML SDK

V3093 The '&' operator evaluates both operands. Perhaps a short-circuit '&&' operator should be used instead. UniqueAttributeValueConstraint.cs 60


public override ValidationErrorInfo ValidateCore(ValidationContext context)
{
    ....
    foreach (var e in root.Descendants(....))
    {
        if (e != element & e.GetType() == elementType) // <=
        {
            var eValue = e.ParsedState.Attributes[_attribute];

            if (eValue.HasValue && _comparer.Equals(....))
            {
                return true;
            }
        }
    }
    ....
}

close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I want to join the test
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si l'e-mail n'apparaît pas dans votre boîte de réception, recherchez-le dans l'un des dossiers suivants:

  • Promotion
  • Notifications
  • Spam