Примеры ошибок, обнаруженных с помощью диагностики V3010


V3010. The return value of function 'Foo' is required to be utilized.


Umbraco

V3010 The return value of function 'ToArray' is required to be utilized. TemplateRepositoryTest.cs 570


public void Can_Get_Children_At_Root()
{
  ....
  using (var repository = CreateRepository(unitOfWork))
  {
    CreateHierarchy(repository, unitOfWork).ToArray();

    // Act
    var children = repository.GetChildren(-1);

    // Assert
    Assert.AreEqual(1, children.Count());
    Assert.AreEqual(1, children.DistinctBy(x => x.Id).Count());
  }
  ....
}

SharpDevelop

V3010 The return value of function 'Insert' is required to be utilized. InPlaceEditor.cs 166


....
public string Text { get; set; }
....
protected override void OnKeyUp(KeyEventArgs e)
{
  ....
  editor.Text.Insert(editor.CaretIndex, Environment.NewLine);
  ....
}

SharpDevelop

V3010 The return value of function 'Union' is required to be utilized. MappingBase.cs 274


public IEnumerable<PropertyMapping>
GetMappingForTable(SSDL.EntityType.EntityType table)
{
  var value = GetSpecificMappingForTable(table);
  var baseMapping = BaseMapping;
  if (baseMapping != null)
    value.Union(baseMapping.GetMappingForTable(table));
  return value;
}

Similar errors can be found in some other places:

  • V3010 The return value of function 'OrderBy' is required to be utilized. CodeCoverageMethodElement.cs 124

Space Engineers

V3010 The return value of function 'Format' is required to be utilized. Sandbox.Game MyEntity3DSoundEmitter.cs 72


public void Init(string cueName)
{
  ....
  if (m_arcade.Hash    == MyStringHash.NullOrEmpty &&
      m_realistic.Hash == MyStringHash.NullOrEmpty)
    MySandboxGame.Log.WriteLine(string.Format(
      "Could not find any sound for '{0}'", cueName));
  else
  {
    if (m_arcade.IsNull)
      string.Format(                                       // <=
        "Could not find arcade sound for '{0}'", cueName);
    if (m_realistic.IsNull)
      string.Format(                                       // <=
        "Could not find realistic sound for '{0}'", cueName);
  }
}

Similar errors can be found in some other places:

  • V3010 The return value of function 'Format' is required to be utilized. Sandbox.Game MyEntity3DSoundEmitter.cs 74

Old NASA World Wind (C#)

V3010 The return value of function 'Combine' is required to be utilized. ConfigurationLoader.cs 943


private static void addExtendedInformation(....)
{
 ....
 if(toolBarImage.Length > 0 &&
    !Path.IsPathRooted(toolBarImage))
      Path.Combine(...., toolBarImage);    // <=
 ....
}

Similar errors can be found in some other places:

  • V3010 The return value of function 'Combine' is required to be utilized. ConfigurationLoader.cs 1361
  • V3010 The return value of function 'Combine' is required to be utilized. ConfigurationLoader.cs 1566
  • V3010 The return value of function 'Combine' is required to be utilized. ConfigurationLoader.cs 1687
  • And 1 additional diagnostic messages.

Mono

V3010 The return value of function 'ToString' is required to be utilized. ColumnTypeConverter.cs 91


public override object ConvertTo(.... object value,
                                 Type destinationType)
{
  ....
  if (destinationType == typeof(string)) {
    if (value == null) {
      return String.Empty;
    }
    else {
      value.ToString(); // <=
    }
  }
  ....
}

GitExtensions

V3010 The return value of function 'IsCardLayout' is required to be utilized. GitUI RevisionGrid.cs 2847


private void SetRevisionsLayout()
{
  IsCardLayout(); // <=
  ....
}

private bool IsCardLayout()
{
  return _layout == RevisionGridLayout.Card
   || _layout == RevisionGridLayout.CardWithGraph
   || _layout == RevisionGridLayout.LargeCard
   || _layout == RevisionGridLayout.LargeCardWithGraph;
}

PowerShell

V3010 The return value of function 'Concat' is required to be utilized. System.Management.Automation Parser.cs 4973


private CatchClauseAst CatchBlockRule(....
  ref List<TypeConstraintAst> errorAsts)
{
  ....
  if (errorAsts == null)
  {
    errorAsts = exceptionTypes;
  }
  else
  {
    errorAsts.Concat(exceptionTypes); // <=
  }
  ....
}

Orchard CMS

V3010 The return value of function 'Except' is required to be utilized. AdminController.cs 140


public ActionResult Preview(string themeId, string returnUrl) {
  ....
  if (_extensionManager.AvailableExtensions()
    ....
  } else {
    var alreadyEnabledFeatures = GetEnabledFeatures();
    ....
    alreadyEnabledFeatures.Except(new[] { themeId });
    TempData[AlreadyEnabledFeatures] = alreadyEnabledFeatures;
  }
  ....
}

Media Portal 2

V3010 The return value of function 'Contains' is required to be utilized. MovieFanArtHandler.cs 147


private SynchronizedCollection<Guid> _checkCache = ....;
private void ExtractFanArt(....)
{
  ....
  if (!MovieMetadataExtractor.SkipFanArtDownload)
    OnlineMatcherService.Instance.DownloadMovieFanArt(
      collectionMediaItemId.Value, collectionInfo, forceFanart);
    _checkCache.Contains(collectionMediaItemId.Value);     // <=
  ....
}

'Contains' function doesn't change '_checkCache' collection and return true if element contains in collection.


PascalABC.NET

V3010 The return value of function 'OrderBy' is required to be utilized. ICSharpCode.SharpDevelop RefactoringService.cs 86


static IEnumerable<ITreeNode<IClass>> FindDerivedClassesTree
(
  ....
)
{
  ....
  var result = new List<TreeNode<IClass>>();
  ....
  result.OrderBy(node => node.Content.FullyQualifiedName); // <=
  return result;
}

Similar errors can be found in some other places:

  • V3010 The return value of function 'ToString' is required to be utilized. CodeCompletion SymTable.cs 2145

Unity C# reference source code

V3010 CWE-252 The return value of function 'Concat' is required to be utilized. AnimationRecording.cs 455


static public UndoPropertyModification[] Process(....)
{
  ....
  discardedModifications.Concat(discardedRotationModifications);
  return discardedModifications.ToArray();
}

OpenCvSharp

V3010 The return value of function 'ToString' is required to be utilized. ImgProcTest.cs 80


public static RectanglesIntersectTypes
RotatedRectangleIntersection(RotatedRect rect1,
                             RotatedRect rect2,
                             out Point2f[] intersectingRegion)
{
  using (var intersectingRegionVec = new VectorOfPoint2f())
  {
    int ret = NativeMethods
                .imgproc_rotatedRectangleIntersection_vector(
                         rect1, rect2, intersectingRegionVec.CvPtr);
    intersectingRegion = intersectingRegionVec.ToArray();
    return (RectanglesIntersectTypes) ret;
  }
}

public void RotatedRectangleIntersectionVector()
{
  var rr1 = new RotatedRect(new Point2f(100, 100),
                            new Size2f(100, 100),
                            45);
  var rr2 = new RotatedRect(new Point2f(130, 100),
                            new Size2f(100, 100),
                            0);

  Cv2.RotatedRectangleIntersection(rr1, rr2,
                out var intersectingRegion);

  ....

  intersectingRegion.ToString();
}


Найденные ошибки

Проверено проектов
367
Собрано ошибок
13 552

А ты совершаешь ошибки в коде?

Проверь с помощью
PVS-Studio

Статический анализ
кода для C, C++, C#
и Java

goto PVS-Studio;