Our website uses cookies to enhance your browsing experience.
Accept
to the top
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

>
>
>
Examples of errors detected by the V300…

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.

.NET Core Libraries (CoreFX)

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


public virtual bool TryAdd(XmlDictionaryString value, out int key)
{
  IntArray keys;
  if (value == null)
    ....

  if (_maps.TryGetValue(value.Dictionary, out keys))
  {
    ....
    return true; // <=
  }

  ....
  return true; // <=
}

.NET Core Libraries (CoreFX)

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


internal virtual bool OnHandleReference(....)
{
  if (xmlWriter.depth < depthToCheckCyclicReference)
    return false;
  if (canContainCyclicReference)
    ....
  return false;
}

.NET Core Libraries (CoreFX)

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


public bool Remove(out int testPosition, out MaskedTextResultHint resultHint)
{
  ....
  if (lastAssignedPos == INVALID_INDEX)
  {
    ....
    return true; // nothing to remove.
  }
  ....
  return true;
}

AvaloniaUI

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


internal bool ScrollSlotIntoView(int slot, bool scrolledHorizontally)
{
  if (.....)
  {
    ....
    if (DisplayData.FirstScrollingSlot < slot
         && DisplayData.LastScrollingSlot > slot)
    {
      return true;
    }
    else if (DisplayData.FirstScrollingSlot == slot && slot != -1)
    {
      ....
      return true;
    }
    ....
  }
  ....
  return true;
}

osu!

V3009 [CWE-393] It's odd that this method always returns one and the same value of 'false'. KeyCounterAction.cs 19


public bool OnPressed(T action, bool forwards)
{
  if (!EqualityComparer<T>.Default.Equals(action, Action))
    return false;

  IsLit = true;
  if (forwards)
    Increment();
  return false;
}

public bool OnPressed(T action) =>
  Target.Children
    .OfType<KeyCounterAction<T>>()
    .Any(c => c.OnPressed(action, Clock.Rate >= 0));

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 'false'. KeyCounterAction.cs 30

Open XML SDK

V3009 It's odd that this method always returns one and the same value of '".xml"'. CustomXmlPartTypeInfo.cs 31


internal static string GetTargetExtension(CustomXmlPartType partType)
{
    switch (partType)
    {
        case CustomXmlPartType.AdditionalCharacteristics:
            return ".xml";

        case CustomXmlPartType.Bibliography:
            return ".xml";

        case CustomXmlPartType.CustomXml:
            return ".xml";

        case CustomXmlPartType.InkContent:
            return ".xml";

        default:
            return ".xml";
    }
}

Similar errors can be found in some other places:

  • V3009 It's odd that this method always returns one and the same value of '".xml"'. CustomPropertyPartTypeInfo.cs 25
  • V3009 It's odd that this method always returns one and the same value of '".bin"'. EmbeddedControlPersistenceBinaryDataPartTypeInfo.cs 22

ONLYOFFICE Community Server

V3009 It's odd that this method always returns one and the same value of 'PredefinedObjectAcl.PublicRead'. GoogleCloudStorage.cs 305


private PredefinedObjectAcl GetGoogleCloudAcl(ACL acl)
{
    switch (acl)
    {
        case ACL.Read:
            return PredefinedObjectAcl.PublicRead;
        default:
            return PredefinedObjectAcl.PublicRead;
    }
}

ONLYOFFICE Community Server

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


//TODO: Simplify
public bool SetUnread(List<int> ids, bool unread, bool allChain = false)
{
    ....
    if (!chainedMessages.Any())
        return true;

    var listIds = allChain
        ? chainedMessages.Where(x => x.IsNew == !unread).Select(....).ToList()
        : ids;

    if (!listIds.Any())
        return true;
    ....
    return true;
}

135 lines of code


Ryujinx

V3009 It's odd that this method always returns one and the same value of 'ResultCode.Success'. IApplicationFunctions.cs 116


public ResultCode GetDesiredLanguage(ServiceCtx context)
{
    ....
    if (firstSupported > (int)SystemState.TitleLanguage.Chinese)
    {
        Logger.Warning?.Print(LogClass.ServiceAm,
            "Application has zero supported languages");

        context.ResponseData.Write(desiredLanguageCode);

        return ResultCode.Success;
    }
    ....
    return ResultCode.Success;
}

Similar errors can be found in some other places:

  • V3009 It's odd that this method always returns one and the same value of 'ResultCode.Success'. IAddOnContentManager.cs 52
  • V3009 It's odd that this method always returns one and the same value of 'ResultCode.Success'. ISystemSettingsServer.cs 30
  • V3009 It's odd that this method always returns one and the same value of 'Status.Success'. ConsumerBase.cs 131
  • And 2 additional diagnostic messages.

Eto.Forms

V3009 It's odd that this method always returns one and the same value of 'true'. Eto DashStyle.cs 56


public static bool TryParse(string value, out DashStyle style)
{
  if (string.IsNullOrEmpty(value))
  {
    style = DashStyles.Solid;
    return true;
  }

  switch (value.ToUpperInvariant())
  {
    case "SOLID":
      style = DashStyles.Solid;
      return true;
      case "DASH":
        style = DashStyles.Dash;
        return true;
      case "DOT":
        style = DashStyles.Dot;
        return true;
      case "DASHDOT":
        style = DashStyles.DashDot;
        return true;
      case "DASHDOTDOT":
        style = DashStyles.DashDotDot;
        return true;
  }
  var values = value.Split(',');
  if (values.Length == 0)
  {
    style = DashStyles.Solid;
    return true;
  }
  float offset;
  if (!float.TryParse(values[0], out offset))
    throw new ArgumentOutOfRangeException("value", value);
  float[] dashes = null;
  if (values.Length > 1)
  {
    dashes = new float [values.Length - 1];
    for (int i = 0; i < dashes.Length; i++)
    {
      float dashValue;
      if (!float.TryParse(values[i + 1], out dashValue))
        throw new ArgumentOutOfRangeException("value", value);
      dashes[i] = dashValue;
    }
  }

  style = new DashStyle(offset, dashes);
  return true;
}

Barotrauma

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


public static bool MoveToParentDirectory(GUIButton button, object userdata)
{
  string dir = CurrentDirectory;
  if (dir.EndsWith("/")) { dir = dir.Substring(0, dir.Length - 1); }
  int index = dir.LastIndexOf("/");
  if (index < 0) { return false; }
  CurrentDirectory = CurrentDirectory.Substring(0, index+1);

  return false;
}

.NET 7

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


public static bool TryParse(string text, out MetricSpec spec)
{
  int slashIdx = text.IndexOf(MeterInstrumentSeparator);
  if (slashIdx == -1)
  {
    spec = new MetricSpec(text.Trim(), null);
    return true;
  }
  else
  {
    string meterName = text.Substring(0, slashIdx).Trim();
    string? instrumentName = text.Substring(slashIdx + 1).Trim();
    spec = new MetricSpec(meterName, instrumentName);
    return true;
  }
}

.NET 7

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


public virtual bool TryAdd(XmlDictionaryString value, out int key)
{
  ArgumentNullException.ThrowIfNull(value);

  IntArray? keys;

  if (_maps.TryGetValue(value.Dictionary, out keys))
  {
    key = (keys[value.Key] - 1);

    if (key != -1)
    {
      // If the key is already set, then something is wrong
      throw ....;
    }

    key = Add(value.Value);
    keys[value.Key] = (key + 1);
    return true;                 // <=
  }

  key = Add(value.Value);
  keys = AddKeys(value.Dictionary, value.Key + 1);
  keys[value.Key] = (key + 1);
  return true;                   // <=
}