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


V3127. Two similar code fragments were found. Perhaps, this is a typo and 'X' variable should be used instead of 'Y'.


Media Portal 2

V3127 Two similar code fragments were found. Perhaps, this is a typo and 'AllocinebId' variable should be used instead of 'CinePassionId' MovieRelationshipExtractor.cs 126


if (movie.CinePassionId > 0)
  ids.Add(ExternalIdentifierAspect.SOURCE_CINEPASSION,
    movie.CinePassionId.ToString());
if (movie.CinePassionId > 0) // <=
  ids.Add(ExternalIdentifierAspect.SOURCE_ALLOCINE,
    movie.AllocinebId.ToString());

Similar errors can be found in some other places:

  • V3127 Two similar code fragments were found. Perhaps, this is a typo and 'attrY' variable should be used instead of 'attrX' AbstractSortByComparableValueAttribute.cs 94
  • V3127 Two similar code fragments were found. Perhaps, this is a typo and 'X' variable should be used instead of 'Y' Point2DList.cs 935
  • V3127 Two similar code fragments were found. Perhaps, this is a typo and 'Y' variable should be used instead of 'X' PointAnimation.cs 125

Roslyn Analyzers

V3127 Two similar code fragments were found. Perhaps, this is a typo and 'leadingTrivia' variable should be used instead of 'trailingTrivia' UseLiteralsWhereAppropriate.Fixer.cs 76


private async Task<Document> ToConstantDeclarationAsync(...)
{
  ....
  if (leadingTrivia.Count == 0 && trailingTrivia.Count == 0)
  {
     leadingTrivia = leadingTrivia.AddRange(modifier.LeadingTrivia);
     trailingTrivia = trailingTrivia.AddRange(modifier.TrailingTrivia);
  }
  else
  {
     trailingTrivia = trailingTrivia.AddRange(modifier.LeadingTrivia);  // <=
     trailingTrivia = trailingTrivia.AddRange(modifier.TrailingTrivia); // <=
     ....
  }
....
}

Telerik UI for UWP

V3127 Two similar code fragments were found. Perhaps, this is a typo and 'emptyIconContainer' variable should be used instead of 'filledIconContainer' RadRatingItem.cs 240


protected override void OnApplyTemplate()
{
  ....

  this.filledIconContainer = this.GetTemplateChild("FilledIconContainer")
                               as Border;
  if (this.filledIconContainer == null)
  {
    throw new MissingTemplatePartException("FilledIconContainer",
                                            typeof(Border));
  }

  this.emptyIconContainer = this.GetTemplateChild(EmptyIconContainer")
                              as Border;
  if (this.filledIconContainer == null)                   // <=
  {
    throw new MissingTemplatePartException("EmptyIconContainer",
                                            typeof(Border));
  }

  this.Initialize();
}


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

Проверено проектов
361
Собрано ошибок
13 417

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

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

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

goto PVS-Studio;