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 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);
  }
  ....
}

ML.NET

V3063 A part of conditional expression is always false if it is evaluated: type == IntArrayType.Dense. IntArray.cs 129


public static IntArray New(...., IntArrayType type, IntArrayBits bitsPerItem)
{
  ....
  Contracts.CheckParam(type == IntArrayType.Current ||
                       type == IntArrayType.Repeat ||
                       type == IntArrayType.Segmented, nameof(type));

  if (type == IntArrayType.Dense || bitsPerItem == IntArrayBits.Bits0)
  {
    ....
  }
  else if (type == IntArrayType.Sparse)
    return new DeltaSparseIntArray(length, bitsPerItem);
  ....
  return null;
}

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);
  ....
}

.NET Core Libraries (CoreFX)

V3063 A part of conditional expression is always true if it is evaluated: _rangelist.Count > 0. RegexCharClass.cs 523


public void AddRange(char first, char last)
{
  _rangelist.Add(new SingleRange(first, last)); // <=
  if (....
      && _rangelist.Count > 0  // <=
      && ....)
    ....
}

OpenCvSharp

V3063 A part of conditional expression is always false if it is evaluated: data == null. Mat.cs 3539


private void CheckArgumentsForConvert(....)
{
  ....
  if (data == null)
    throw new ArgumentNullException(nameof(data));

  MatType t = Type();
  if (data == null || (data.Length * dataDimension)      // <=
      (data.Length * dataDimension) % t.Channels != 0)
   ....
}

RunUO

V3063 A part of conditional expression is always true if it is evaluated: m_Serial <= 0x7FFFFFFF. Serial.cs 83


public bool IsItem
{
  get
  {
    return ( m_Serial >= 0x40000000 && m_Serial <= 0x7FFFFFFF );
  }
}

RavenDB

V3063 A part of conditional expression is always true if it is evaluated: Attributes != null. LicenseStatus.cs(28) Raven.Server


public LicenseType Type
{
  get
  {
    if (ErrorMessage != null)
      return LicenseType.Invalid;

    if (Attributes == null)
      return LicenseType.None;

    if (Attributes != null &&                             // <=
        Attributes.TryGetValue("type", out object type) &&
        type is int
    )
    {
      var typeAsInt = (int)type;
      if (Enum.IsDefined(typeof(LicenseType), typeAsInt))
        return (LicenseType)typeAsInt;
    }

    return LicenseType.Community;
  }
}

RavenDB

V3063 A part of conditional expression is always true if it is evaluated: isMethod. QueryParser.cs(1797) Raven.Server


private bool Operator(OperatorField fieldOption, out QueryExpression op)
{
  ....
  switch (match)
  {
    ....
    case "(":
      var isMethod = Method(field, out var method); // <=
      op = method;

      if (
        isMethod &&
        Operator(OperatorField.Optional, out var methodOperator)
      )
      {
        ....
      }

      return isMethod;
    ....
  }
}

private bool Method(FieldExpression field, out MethodExpression op)
{
  var args = ReadMethodArguments();

  op = new MethodExpression(field.FieldValue, args);
  return true;
}

RavenDB

V3063 A part of conditional expression is always false if it is evaluated: m_curEdgeBlock != null. DotNetHeapDumpGraphReader.cs(803) Raven.Debug


private Address GetNextEdge()
{
  if (m_curEdgeBlock == null || m_curEdgeBlock.Count <= m_curEdgeIdx)
  {
    m_curEdgeBlock = null;
    if (m_edgeBlocks.Count == 0)
    {
      throw new ApplicationException(
        "Error not enough edge data.  Giving up on heap dump."
      );
    }

    var nextEdgeBlock = m_edgeBlocks.Dequeue();
    if (
      m_curEdgeBlock != null &&                       // <=
      nextEdgeBlock.Index != m_curEdgeBlock.Index + 1
    )
    {
      throw new ApplicationException(
        "Error expected Node Index " + (m_curEdgeBlock.Index + 1) +
        " Got " + nextEdgeBlock.Index + " Giving up on heap dump."
      );
    }

    m_curEdgeBlock = nextEdgeBlock;
    m_curEdgeIdx = 0;
  }
  return m_curEdgeBlock.Values(m_curEdgeIdx++).Target;
}

OpenRA

V3063 A part of conditional expression is always true if it is evaluated: cancelButton != null. ConfirmationDialogs.cs 78


public static void ButtonPrompt(....)
{
  ....
  var cancelButton = prompt.GetOrNull<ButtonWidget>(
    "CANCEL_BUTTON"
  );
  ....

  if (onCancel != null && cancelButton != null)
  {
    cancelButton.Visible = true;
    cancelButton.Bounds.Y += headerHeight;
    cancelButton.OnClick = () =>
    {
      Ui.CloseWindow();
      if (onCancel != null)
        onCancel();
    };

    if (!string.IsNullOrEmpty(cancelText) && cancelButton != null)
      cancelButton.GetText = () => cancelText;
  }
  ....
}

OpenRA

V3063 A part of conditional expression is always true if it is evaluated: terrainGeometryTrait != null. MapEditorLogic.cs 35


public class MapEditorLogic : ChromeLogic
{
  public MapEditorLogic(....)
  {
    var editorViewport = widget
                         .Get<EditorViewportControllerWidget>("MAP_EDITOR");

    var gridButton = widget.GetOrNull<ButtonWidget>("GRID_BUTTON");
    var terrainGeometryTrait = world.WorldActor
                                  .Trait<TerrainGeometryOverlay>();

    if (gridButton != null && terrainGeometryTrait != null) // <=
    {
      ....
    }

    var copypasteButton = widget.GetOrNull<ButtonWidget>("COPYPASTE_BUTTON");
    if (copypasteButton != null)
    {
      ....
    }

    var copyFilterDropdown = widget.Get<DropDownButtonWidget>(....);
    copyFilterDropdown.OnMouseDown = _ =>
    {
      copyFilterDropdown.RemovePanel();
      copyFilterDropdown.AttachPanel(CreateCategoriesPanel());
    };

    var coordinateLabel = widget.GetOrNull<LabelWidget>("COORDINATE_LABEL");
    if (coordinateLabel != null)
    {
      ....
    }

    ....
  }
  ....
}

public sealed class Actor : ....
{
  ....
  public T Trait<T>()
  {
    return World.TraitDict.Get<T>(this);
  }
  ....
}

class TraitDictionary
{
  ....
  public T Get<T>(Actor actor)
  {
    CheckDestroyed(actor);
    return InnerGet<T>().Get(actor); // InnerGet<T> returns TraitContainer<T>
  }
  ....
}

class TraitContainer<T> : ITraitContainer
{
  ....
  public T Get(Actor actor)
  {
    var result = GetOrDefault(actor);
    if (result == null)
      throw new InvalidOperationException(....);
    return result;
  }
  ....
}

EFCore

V3063 A part of conditional expression is always true if it is evaluated: targetType != null. EFCore InternalEntityTypeBuilder.cs 3370


public virtual InternalEntityTypeBuilder? GetTargetEntityTypeBuilder(....)
{
  ....
  var memberType = navigation.MemberInfo?.GetMemberType();

  if (memberType != null)
  {
    targetType = memberType.TryGetSequenceType() ?? memberType;

    if (   targetType != null                                           // <=
        && targetEntityType.Name == Metadata.Model
                                            .GetDisplayName(targetType))
    {
      targetEntityType = new TypeIdentity(targetType, Metadata.Model);
    }
  }
  ....
}

Ryujinx

V3063 A part of conditional expression is always true if it is evaluated: value >= 0. NumberFormatter.cs 96


public static string FormatUint(uint value)
{
    if (value <= MaxDecimal && value >= 0)
    {
        return value.ToString(CultureInfo.InvariantCulture) + "u";
    }
    ....
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always false if it is evaluated: flush. TextureManager.cs 942
  • V3063 A part of conditional expression is always false if it is evaluated: backendDisconnected. SoundIoHardwareDeviceDriver.cs 68
  • V3063 A part of conditional expression is always true if it is evaluated: info != null. SynchronizationManager.cs 132

PeachPie

V3063 A part of conditional expression is always true if it is evaluated: num <= long.MaxValue % 16. Conversions.cs 994


internal static NumberInfo IsNumber(....)
{
  ....
  int num = AlphaNumericToDigit(c);

  // unexpected character:
  if (num <= 15)
  {
    if (l == -1)
    {
      if (   longValue < long.MaxValue / 16
          || (   longValue == long.MaxValue / 16
              && num <= long.MaxValue % 16))         // <=
      {
        ....
      }
      ....
    }
    ....
  }
  ....
}

LINQ to DB

V3063 A part of conditional expression is always true if it is evaluated: field.Field.CreateFormat != null. BasicSqlBuilder.cs 1255


protected virtual void BuildCreateTableStatement(....)
{
  ....
  if (field.Field.CreateFormat != null)
  {
    if (field.Field.CreateFormat != null && field.Identity.Length == 0)
    {
      ....
    }
  }
  ....
}

Bitwarden

V3063 A part of conditional expression is always false if it is evaluated: globalSettings.SelfHosted. PremiumRequestModel.cs 23


public bool Validate(GlobalSettings globalSettings)
{
  if(!(License == null && !globalSettings.SelfHosted) ||
     (License != null && globalSettings.SelfHosted))          // <=
  {
    return false;
  }
  return globalSettings.SelfHosted || !string.IsNullOrWhiteSpace(Country);
}

Similar errors can be found in some other places:

  • V3063 A part of conditional expression is always false if it is evaluated: License != null. PremiumRequestModel.cs 23

Bitwarden

V3063 A part of conditional expression is always false if it is evaluated: sponsorship.SponsorshipLapsedDate.HasValue. OrganizationSponsorshipService.cs 308


internal async Task DoRemoveSponsorshipAsync(
  Organization sponsoredOrganization,
  OrganizationSponsorship sponsorship = null)
{
  ....
  sponsorship.SponsoredOrganizationId = null;
  sponsorship.FriendlyName = null;
  sponsorship.OfferedToEmail = null;
  sponsorship.PlanSponsorshipType = null;
  sponsorship.TimesRenewedWithoutValidation = 0;
  sponsorship.SponsorshipLapsedDate = null;               // <=

  if (sponsorship.CloudSponsor || sponsorship.SponsorshipLapsedDate.HasValue)
  {
    await _organizationSponsorshipRepository.DeleteAsync(sponsorship);
  }
  else
  {
    await _organizationSponsorshipRepository.UpsertAsync(sponsorship);
  }
}

Entity Framework Core

V3063 A part of conditional expression is always true if it is evaluated: !string.IsNullOrEmpty(databaseModel.DatabaseName). RelationalScaffoldingModelFactory.cs 169


protected virtual ModelBuilder VisitDatabaseModel(....)
{
  ....
  if (!string.IsNullOrEmpty(databaseModel.DatabaseName)) // <=
  {
    modelBuilder.Model.SetDatabaseName(
           !_options.UseDatabaseNames
        && !string.IsNullOrEmpty(databaseModel.DatabaseName) // <=
      ? _candidateNamingService.GenerateCandidateIdentifier(....)
      : databaseModel.DatabaseName
    );
  }
  ....
}

Entity Framework Core

V3063 A part of conditional expression is always true if it is evaluated: TryGetPartitionKeyProperty(entityType, out var partitionKeyProperty). CosmosQueryableMethodTranslatingExpressionVisitor.cs 105


public override Expression Visit(Expression expression)
{
  ....
  if (   TryGetPartitionKeyProperty(entityType,
                                    out var partitionKeyProperty)
      && entityTypePrimaryKeyProperties.SequenceEqual(queryProperties)
      && (partitionKeyProperty == null || ....)
      && ....)
  {
    var propertyParameterList = queryProperties.Zip(....);

    var readItemExpression = new ReadItemExpression(entityType,
                                                    propertyParameterList);

    return ....;
  }
  ....
}

static bool TryGetPartitionKeyProperty(IEntityType entityType,
                                       out IProperty partitionKeyProperty)
{
  var partitionKeyPropertyName = entityType.GetPartitionKeyPropertyName();
  if (partitionKeyPropertyName is null)
  {
    partitionKeyProperty = null;
    return true;
  }

  partitionKeyProperty = entityType.FindProperty(partitionKeyPropertyName);
  return true;
}