Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
Examples of errors detected by the V313…

Examples of errors detected by the V3137 diagnostic

V3137. The variable is assigned but is not used by the end of the function.


Roslyn Analyzers

V3137 The 'sourceOrigins' variable is assigned but is not used by the end of the function. TaintedDataAnalysis.TaintedDataOperationVisitor.cs 328


public override TaintedDataAbstractValue VisitArrayInitializer(
  IArrayInitializerOperation operation,
  object argument)
{
  HashSet<SymbolAccess> sourceOrigins = null;
  ....
  if (baseAbstractValue.Kind == TaintedDataAbstractValueKind.Tainted)
  {
     sourceOrigins = new HashSet<SymbolAccess>(....);
  }
  ....
}

Azure PowerShell

V3137 The 'apiVersionSetId' variable is assigned but is not used by the end of the function. GetAzureApiManagementApiVersionSet.cs 69


public String ApiVersionSetId { get; set; }
....
public override void ExecuteApiManagementCmdlet()
{
  ....
  string apiVersionSetId;

  if (ParameterSetName.Equals(ContextParameterSet))
  {
    ....
    apiVersionSetId = ApiVersionSetId;
  }
  else
  {
    apiVersionSetId = ....;
  }

  if (string.IsNullOrEmpty(ApiVersionSetId))  // <=
  {
    WriteObject(....);
  }
  else
  {
    WriteObject(Client.GetApiVersionSet(...., ApiVersionSetId))  // <=
  }
}

Similar errors can be found in some other places:

  • V3137 The 'cacheId' variable is assigned but is not used by the end of the function. RemoveAzureApiManagementCache.cs 94

Telerik UI for UWP

V3137 The 'leftMargin' variable is assigned but is not used by the end of the function. DragDrop.cs 87


internal static void StartDrag(....)
{
  ....
  if (frameworkElementSource != null)
  {
    leftMargin = frameworkElementSource.Margin.Left;    // <=
    topMargin = frameworkElementSource.Margin.Top;      // <=
  }
  if (dragDropElement == null ||
     !dragDropElement.CanStartDrag(trigger, initializeContext))
  {
    return;
  }

  var context = dragDropElement
               .DragStarting(trigger, initializeContext);

  if (context == null)
  {
    return;
  }

  var startDragPosition = e.GetCurrentPoint(context.DragSurface.RootElement)
                           .Position;
  var relativeStartDragPosition = e.GetCurrentPoint(uiDragDropElement)
                                   .Position;
  var dragPositionMode = DragDrop.GetDragPositionMode(uiDragDropElement);

  AddOperation(new DragDropOperation(context,
                                     dragDropElement,
                                     dragPositionMode,
                                     e.Pointer,
                                     startDragPosition,
                                     relativeStartDragPosition));
}

Similar errors can be found in some other places:

  • V3137 The 'topMargin' variable is assigned but is not used by the end of the function. DragDrop.cs 88
  • V3137 The 'currentColumnLength' variable is assigned but is not used by the end of the function. WrapLayout.cs 824

LINQ to DB

V3137 The 'version' variable is assigned but is not used by the end of the function. Query.cs 408


public void TryAdd(IDataContext dataContext, Query<T> query, QueryFlags flags)
{
  QueryCacheEntry[] cache;
  int version;
  lock (_syncCache)
  {
    cache   = _cache;
    version = _version;
  }
  ....
  lock(_syncCash)
  {
    ....
    var versionsDiff = _version - version;
    ....
    _cache   = newCache;
    _indexes = newPriorities;
    version  = _version;
  }
}

Similar errors can be found in some other places:

  • V3137 The 'leftContext' variable is assigned but is not used by the end of the function. ExpressionBuilder.SqlBuilder.cs 1989

Umbraco

V3137 The 'username' variable is assigned but is not used by the end of the function. MemberManager.cs 87


public async Task<bool> IsMemberAuthorizedAsync(....)
{
  ....
  if (IsLoggedIn() == false)
  {
    allowAction = false;
  }
  else
  {
    string username;
    ....
    username = currentMember.UserName;
    IList<string> allowTypesList = allowTypes as IList<string> ??
                                              allowTypes.ToList();
    if (allowTypesList.Any(allowType => allowType != string.Empty))
    {
      allowAction = allowTypesList.Select(x => x.ToLowerInvariant())
                                                .Contains(currentMember
                                                .MemberTypeAlias
                                                .ToLowerInvariant());
    }

    if (allowAction && allowMembers.Any())
    {
      allowAction = allowMembers.Contains(memberId);
    }
    ....
  }
  return allowAction;
}

MonoGame

V3137 The 'relativeVelocity' variable is assigned but is not used by the end of the function. MonoGame.Framework.DesktopGL(netstandard2.0) Cue.cs 266


public void Apply3D(AudioListener listener, AudioEmitter emitter)

{
  ....
  lock (_engine.UpdateLock)
  {
    ....
    // Calculate doppler effect.
    var relativeVelocity = emitter.Velocity - listener.Velocity;
    relativeVelocity *= emitter.DopplerScale;
  }
}

MonoGame

V3137 The 'len' variable is assigned but is not used by the end of the function. MonoGame.Framework.DesktopGL(netstandard2.0) ConstantBuffer.cs 91


private void SetData(int offset, int rows, int columns, object data)
{
  ....
  if(....)
  {
    ....
  }
  else if (rows == 1 || (rows == 4 && columns == 4))
  {
    // take care of shader compiler optimization
    int len = rows * columns * elementSize;
    if (_buffer.Length - offset > len)
      len = _buffer.Length - offset;    //  <=
    Buffer.BlockCopy(data as Array,
                     0,
                     _buffer,
                     offset,
                     rows*columns*elementSize);
  }
  ....
}

Unity C# reference source code

V3137 The 'maxDist' variable is assigned but is not used by the end of the function. TreeAOImporter.cs 142


static int CountIntersections(....)
{
  ....
  int hitLength = s_RayCastHits.Length;
  float maxDist = 0;
  if (hitLength > 0)
    maxDist = s_RayCastHits[s_RayCastHits.Length - 1].distance;

  physicsScene.Raycast(....);
  if (s_RayCastHits.Length > 0)
  {
    float len = length - s_RayCastHits[0].distance;
    if (len > maxDist)
    {
      maxDist = len;                                 // <=
    }
  }

  return hitLength + s_RayCastHits.Length;
}

AWS SDK for .NET

V3137 The 'platform' variable is assigned but is not used by the end of the function. InternalSDKUtils.netstandard.cs 70


private static string GetXamarinInformation()
{
  var xamarinDevice = Type.GetType("Xamarin.Forms.Device, Xamarin.Forms.Core");
  if (xamarinDevice == null)
  {
    return null;
  }

  var runtime = xamarinDevice.GetProperty("RuntimePlatform")
                            ?.GetValue(null)
                            ?.ToString() ?? "";

  var idiom = xamarinDevice.GetProperty("Idiom")
                          ?.GetValue(null)
                          ?.ToString() ?? "";

  var platform = runtime + idiom;                    // <=

  if (string.IsNullOrEmpty(platform))
  {
    platform = UnknownPlatform;
  }

  return string.Format(CultureInfo.InvariantCulture,
                       "Xamarin_{0}",
                       "Xamarin");                   // <=
}

Power-Fx

V3137 [CWE-563] The 'fullType' variable is assigned but is not used by the end of the function. DType.cs 1350


public DType Add(DName name, DType type)
{
    AssertValid();
    Contracts.Assert(IsAggregate);
    Contracts.Assert(name.IsValid);
    type.AssertValid();

    var fullType = this;
    if (IsLazyType)
    {
        fullType = LazyTypeProvider.GetExpandedType(IsTable);
    }

    Contracts.Assert(!TypeTree.Contains(name));
    var tree = TypeTree.SetItem(name, type);
    var newType = new DType(Kind, tree, AssociatedDataSources,
                                        DisplayNameProvider);

    return newType;
}

Starlight

V3137 The 'obj' variable is assigned but is not used by the end of the function. VertexShakeB.cs 44


void ON_TEXT_CHANGED(Object obj)
{
    if (obj = m_TextComponent)
        hasTextChanged = true;
}

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 do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam