Examples of errors detected by the V3009 diagnostic


V3009. It's odd that this method always returns one and the same value of NN.


Umbraco

V3009 It's odd that this method always returns one and the same value of 'true'. DynamicNode.cs 695


private bool ConvertPropertyValueByDataType(....)
{
  if (string.IsNullOrEmpty(string.Format("{0}", result)))
  {
    result = false;
    return true;
  }
  ....
    return true;
  ....
    return true;
  ....
    return true;
  ....
    return true;
  ....
    return true;
  ....
  ....
  return true;
}

Microsoft Code Contracts

V3009 It's odd that this method always returns one and the same value of 'true'. LinearEqualities.cs 5262


public bool TryGetFirstAvailableDimension(out int dim)
{
  for (var i = 0; i < map.Length; i++)
  {
    if (!map[i])
    {
      dim = i;
      return true;
    }
  }

  map.Length++;

  dim = map.Length;

  return true;
}

Xamarin.Forms

V3009 It's odd that this method always returns one and the same value of 'false'. Xamarin.Forms.UITest.TestCloud OptionSet.cs 239


static bool
Unprocessed(ICollection<string> extra, Option def,
                    OptionContext c, string argument)
{
  if (def == null)
  {
    ....
    return false;
  }
  ....
  return false;
}

MSBuild

V3009 It's odd that this method always returns one and the same value of 'true'. ComReference.cs 304


internal static bool GetTypeLibNameForITypeLib(....)
{
  ....
  if (typeLib2 == null)
  {
    ....
    return true;  // <=
  }
  ....
  try
  {
    if (data == null || ...)
    {
      ....
      return true;  // <=
    }
    ....
  }
  catch (COMException ex)
  {
    ....
    return true;  // <=
  }
  return true;  // <=
}

PascalABC.NET

V3009 It's odd that this method always returns one and the same value of 'false'. NETGenerator NETGenerator.cs 5434


private bool BeginOnForNode(IStatementNode value)
{
  //if (value is IForNode) return true;
  IStatementsListNode stats = value as IStatementsListNode;
  if (stats == null) return false;
  if (stats.statements.Length == 0) return false;
  //if (stats.statements[0] is IForNode) return true;
  return false;
}

Similar errors can be found in some other places:

  • V3009 It's odd that this method always returns one and the same value of '0'. PABCNETC CommandConsoleCompiler.cs 297
  • V3009 It's odd that this method always returns one and the same value of '0'. PABCNETCclear CommandConsoleCompiler.cs 266

SubtitleEdit

V3009 CWE-393 It's odd that this method always returns one and the same value of 'true'. Main.cs 10153


private bool LoadTextSTFromMatroska(
  MatroskaTrackInfo matroskaSubtitleInfo,
  MatroskaFile matroska,
  bool batchMode)
{
  ....
  _fileDateTime = new DateTime();
  _converted = true;
  if (batchMode)
      return true;

  SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
  if (_subtitle.Paragraphs.Count > 0)
      SubtitleListview1.SelectIndexAndEnsureVisible(0);

  ShowSource();
  return true;
}

Unity C# reference source code

V3009 CWE-393 It's odd that this method always returns one and the same value of 'false'. ProjectBrowser.cs 1417


// Returns true if we should early out of OnGUI
bool HandleCommandEventsForTreeView()
{
  ....
  if (....)
  {
    ....
    if (....)
      return false;
    ....
  }
  return false;
}

AWS SDK for .NET

V3009 [CWE-393] It's odd that this method always returns one and the same value of 'true'. AWSSDK.Core.Net45 Lexer.cs 651


private static bool State19 (....)
{
  while (....) {
    switch (....) {
    case '"':
      ....
      return true;

    case '\\':
      ....
      return true;

    default:
      ....
      continue;
    }
  }
  return true;
}

Similar errors can be found in some other places:

  • V3009 [CWE-393] It's odd that this method always returns one and the same value of 'true'. AWSSDK.Core.Net45 Lexer.cs 752
  • V3009 [CWE-393] It's odd that this method always returns one and the same value of 'true'. AWSSDK.Core.Net45 Lexer.cs 810
  • V3009 [CWE-393] It's odd that this method always returns one and the same value of 'true'. AWSSDK.Core.Net45 Lexer.cs 822
  • And 1 additional diagnostic messages.


Bugs Found

Checked Projects
336
Collected Errors
12 743