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


V3038. The argument was passed to method several times. It is possible that other argument should be passed instead.


SharpDevelop

V3038 The first argument of 'Replace' function is equal to the second argument. ReflectionDisassembler.cs 349


void
WriteSecurityDeclarationArgument(CustomAttributeNamedArgument na)
{
  ....
  output.Write("string('{0}')",
    NRefactory.CSharp.TextWriterTokenWriter.
    ConvertString((string)na.Argument.Value).Replace("'", "\'"));
  ....
}

Correct version: Replace("'", "\\'") There is exactly the same bug in the 'Xamarin.Forms' project.


Xamarin.Forms

V3038 The first argument of 'Replace' function is equal to the second argument. ICSharpCode.Decompiler ReflectionDisassembler.cs 349


void WriteSecurityDeclarationArgument(
         CustomAttributeNamedArgument na)
{
  ....
  output.Write("string('{0}')",
    NRefactory.CSharp
              .TextWriterTokenWriter
              .ConvertString(
                (string)na.Argument.Value).Replace("'", "\'"));
  ....
}

There is exactly the same bug in the 'SharpDevelop' project.


PascalABC.NET

V3038 The 'enum_consts[i]' argument was passed to 'Compare' method several times. It is possible that other argument should be passed instead. CodeCompletion SymTable.cs 2206


private List<string> enum_consts = new List<string>();
public override bool IsEqual(SymScope ts)
{
  EnumScope es = ts as EnumScope;
  if (es == null) return false;
  if (enum_consts.Count != es.enum_consts.Count) return false;
  for (int i = 0; i < es.enum_consts.Count; i++)
    if (string.Compare(enum_consts[i],
                       this.enum_consts[i], true) != 0)  // <=
      return false;
  return true;
}


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

Проверено проектов
346
Собрано ошибок
13 124

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

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

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

goto PVS-Studio;