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


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