Examples of errors detected by the V3063 diagnostic


V3063. A part of conditional expression is always true/false if it is evaluated.


Xamarin.Forms

V3063 A part of conditional expression is always true: exception == null. Xamarin.Forms.Xaml ApplyPropertiesVisitor.cs 280


static BindableProperty
GetBindableProperty(Type elementType,
                               string localName,
                               IXmlLineInfo lineInfo,
                               bool throwOnError = false)
{
  ....
  Exception exception = null;
  if (exception == null && bindableFieldInfo == null)
  {
    exception = new XamlParseException(
      string.Format("BindableProperty {0} not found on {1}",
      localName + "Property", elementType.Name), lineInfo);
  }
  ....
}

Accord.Net

V3063 A part of conditional expression is always false: i < low. Accord.Math JaggedEigenvalueDecompositionF.cs 571


private void hqr2()
{
  ....
  int low = 0;
  ....
  for (int i = 0; i < nn; i++)
  {
    if (i < low | i > high)
      ....
  }
  ....
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always false: i < low. Accord.Math JaggedEigenvalueDecompositionF.cs 972
  • V3063 A part of conditional expression is always false: i < low. Accord.Math JaggedEigenvalueDecomposition.cs 571
  • V3063 A part of conditional expression is always false: i < low. Accord.Math JaggedEigenvalueDecomposition.cs 972
  • And 1 additional diagnostic messages.

Old NASA World Wind (C#)

V3063 A part of conditional expression is always false: currentSurfaceImage == null. SurfaceTile.cs 1069


private bool checkSurfaceImageChange()
{
  ....
  SurfaceImage currentSurfaceImage =
  m_ParentWorldSurfaceRenderer.SurfaceImages[i] as SurfaceImage;

  if(currentSurfaceImage.LastUpdate > m_LastUpdate ||
     currentSurfaceImage.Opacity !=
     currentSurfaceImage.ParentRenderable.Opacity)
  {
    if(currentSurfaceImage == null               || // <=
       currentSurfaceImage.ImageTexture == null  ||
       currentSurfaceImage.ImageTexture.Disposed ||
      !currentSurfaceImage.Enabled || ....)
       {
         continue;
       }
       else
       {
         return true;
       }
  }
  ....
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always true: iWildIndex==-1. GPSTrackerPlugin.APRS.cs 87
  • V3063 A part of conditional expression is always true: iWildIndex==-1. GPSTrackerPlugin.NMEA.cs 169
  • V3063 A part of conditional expression is always false: newvalue == null. SchemaTypes.cs 860

Unity3D

V3063 A part of conditional expression is always false: connId < 0. UnityEngine.Networking ConnectionArray.cs 59


public NetworkConnection Get(int connId)
{
  if (connId < 0)
  {
    return m_LocalConnections[Mathf.Abs(connId) - 1];
  }

  if (connId < 0 || connId > m_Connections.Count) // <=
  {
    ....
    return null;
  }

  return m_Connections[connId];
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always true: currentTest != null. UnityTestTools TestRunner.cs 237
  • V3063 A part of conditional expression is always false: connId < 0. UnityEngine.Networking ConnectionArray.cs 86
  • V3063 A part of conditional expression is always true: m_IsServer. UnityEngine.Networking NetworkIdentity.cs 53

GitExtensions

V3063 A part of conditional expression is always true if it is evaluated: button.Enabled. GitUI FormStash.cs 301


private void toolStripButton(...)
{
  var button = (ToolStripButton)sender;
  if (!button.Enabled)
  {
    StashMessage.ReadOnly = true;
  }
  else if (button.Enabled && button.Checked) // <=
  {
    StashMessage.ReadOnly = false;
  }
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always false if it is evaluated: string.IsNullOrEmpty(_mergetool). GitUI FormResolveConflicts.cs 482

Unity C# reference source code

V3063 CWE-571 A part of conditional expression is always true if it is evaluated: pageSize <= 1000. UNETInterface.cs 584


public override bool IsValid()
{
  ....
  return base.IsValid()
    && (pageSize >= 1 || pageSize <= 1000)
    && totalFilters <= 10;
}

AWS SDK for .NET

V3063 [CWE-571] A part of conditional expression is always true if it is evaluated: string.IsNullOrEmpty(inferredIndexName). AWSSDK.DynamoDBv2.PCL ContextInternal.cs 802


private static string GetQueryIndexName(....)
{
  ....
  string inferredIndexName = null;
  if (string.IsNullOrEmpty(specifiedIndexName) &&
      indexNames.Count == 1)
  {
    inferredIndexName = indexNames[0];
  }
  else if (indexNames.Contains(specifiedIndexName,
                               StringComparer.Ordinal))
  {
    inferredIndexName = specifiedIndexName;
  }
  else if (string.IsNullOrEmpty(inferredIndexName) &&  // <=
           indexNames.Count > 0)
    throw new InvalidOperationException("Local Secondary Index range
      key conditions are used but no index could be inferred from
      model. Specified index name = " + specifiedIndexName);
  ....
}


Bugs Found

Checked Projects
344
Collected Errors
12 970