Examples of errors detected by the V3010 diagnostic.


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


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