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


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;
On our website we use a cookie to collect information of a technical nature.
If you do not agree, please leave the site. Learn More →
Do not show again