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


V3005. The 'x' variable is assigned to itself.


Umbraco

V3005 The 'member.UpdateDate' variable is assigned to itself. MemberService.cs 114


public void SavePassword(IMember member, string password)
{
  ....
  member.RawPasswordValue = result.RawPasswordValue;
  member.LastPasswordChangeDate = result.LastPasswordChangeDate;
  member.UpdateDate = member.UpdateDate;
}

Similar errors can be found in some other places:

  • V3005 The 'user.UpdateDate' variable is assigned to itself. UserService.cs 269

SharpDevelop

V3005 The 'linearGradientBrush.GradientStops' variable is assigned to itself. BrushEditor.cs 120


void DetermineCurrentKind()
{
  ....
  else if (Brush is LinearGradientBrush) {
    linearGradientBrush = Brush as LinearGradientBrush;
    radialGradientBrush.GradientStops =
      linearGradientBrush.GradientStops;
    CurrentKind = BrushEditorKind.Linear;
  }
  else if (Brush is RadialGradientBrush) {
    radialGradientBrush = Brush as RadialGradientBrush;
    linearGradientBrush.GradientStops =      // <=
      linearGradientBrush.GradientStops;     // <=
    CurrentKind = BrushEditorKind.Radial;
  }
}

Most likely this is what should be written here: linearGradientBrush.GradientStops = radialGradientBrush.GradientStops;


SharpDevelop

V3005 The 'this.WhiteSpaceText' variable is assigned to itself. WhitespaceNode.cs 65


public WhitespaceNode(string whiteSpaceText,
                      TextLocation startLocation)
{
  this.WhiteSpaceText = WhiteSpaceText;
  this.startLocation = startLocation;
}

Lower case 'w' should have been used instead of capital 'W'. Correct variant: this.WhiteSpaceText = whiteSpaceText;


MonoDevelop

V3005 The 'MacroCharacter' variable is assigned to itself. Mono.TextEditor ViMacro.cs 57


public ViMacro (char macroCharacter) {
  MacroCharacter = MacroCharacter;
}

public char MacroCharacter {get; set;}

MonoDevelop

V3005 The 'MarkCharacter' variable is assigned to itself. Mono.TextEditor ViMark.cs 45


public ViMark (char markCharacter) {
  MarkCharacter = MarkCharacter;
}

public char MarkCharacter {get; set;}

MonoDevelop

V3005 The 'this.WhiteSpaceText' variable is assigned to itself. ICSharpCode.NRefactory.CSharp WhitespaceNode.cs 65


public WhitespaceNode(string whiteSpaceText,
                      TextLocation startLocation)
{
  this.WhiteSpaceText = WhiteSpaceText;
  this.startLocation = startLocation;
}

public string WhiteSpaceText { get; set; }

MonoDevelop

V3005 The 'iconMargin.IsVisible' variable is assigned to itself. MonoDevelop.HexEditor HexEditor.cs 241


void OptionsChanged (object sender, EventArgs e)
{
  gutterMargin.IsVisible = Options.ShowLineNumberMargin;
  iconMargin.IsVisible = iconMargin.IsVisible;
  ....
}

public bool IsVisible { get; set; }

IronPython and IronRuby

V3005 The 'd["latin1"]' variable is assigned to itself. StringOps.cs 1905


private static Dictionary<string, EncodingInfoWrapper>
  MakeCodecsDict() {
  ....
  switch (normalizedName) {
    case "iso_8859_1":
      d["8859"] = d["latin_1"] = d["latin1"] =
      d["iso 8859_1"] = d["iso8859_1"] = d["cp819"] =
      d["819"] = d["latin"] = d["latin1"] = d["l1"] =
      encs[i];
      break;
  ....
}

.NET Compiler Platform ("Roslyn")

V3005 The 'Name' variable is assigned to itself. AsynchronousOperationListener.DiagnosticAsyncToken.cs 32


public DiagnosticAsyncToken(
  AsynchronousOperationListener listener,
  string name,
  object tag,
  string filePath,
  int lineNumber)
  : base(listener)
{
  Name = Name;
  Tag = tag;
  FilePath = filePath;
  LineNumber = lineNumber;
  StackTrace = PortableShim.StackTrace.GetString();
}

Sony ATF

V3005 The 'ProgressError' variable is assigned to itself. Atf.Gui.Wpf.vs2010 StatusService.cs 24


public ProgressCompleteEventArgs(Exception progressError,
                                 object progressResult,
                                 bool cancelled)
{
  ProgressError = ProgressError;
  ProgressResult = progressResult;
  Cancelled = cancelled;
}

Sony ATF

V3005 The 'window.Left' variable is assigned to itself. Atf.Gui.Wpf.vs2010 DockPanel.cs 706


public double Left { get; set; }

public void ApplyLayout(XmlReader reader)
{
  ....
  FloatingWindow window = new FloatingWindow(
                                this, reader.ReadSubtree());
  ....
  window.Left = window.Left;
  window.Top = window.Top;
  ....
}

Sony ATF

V3005 The 'window.Top' variable is assigned to itself. Atf.Gui.Wpf.vs2010 DockPanel.cs 707


public double Top  { get; set; }

public void ApplyLayout(XmlReader reader)
{
  ....
  FloatingWindow window = new FloatingWindow(
                                this, reader.ReadSubtree());
  ....
  window.Left = window.Left;
  window.Top = window.Top;
  ....
}

Xenko

V3005 The 'hashCode' variable is assigned to itself. SiliconStudio.Xenko ParameterKeys.cs 346


public ParameterComposedKey(ParameterKey key,
                            string name,
                            int indexer)
{
  Key = key;
  Name = name;
  Indexer = indexer;

  unchecked
  {
    hashCode = hashCode = Key.GetHashCode();
    hashCode = (hashCode * 397) ^ Name.GetHashCode();
    hashCode = (hashCode * 397) ^ Indexer;
  }
}

WPF samples by Microsoft

V3005 The 'clipboardInfo.Text' variable is assigned to itself. MainWindow.cs 204


private void DumpAllClipboardContentsInternal()
{
  ....
  if (dataObject == null)
  {
    clipboardInfo.Text =
      clipboardInfo.Text =
        "Can't access clipboard now!
          \n\nPlease click Dump All Clipboard
              Contents button again.";
  }
  else
  {
     ....
}

Old NASA World Wind (C#)

V3005 The 'num1' variable is assigned to itself. PlaceFinder.cs 2011


public static bool SearchForAddress(....)
{
  double num1;
  long2 = num1 = 0;
  long1 = num1 = num1;  // <=
  lat2  = num1 = num1;  // <=
  lat1 = num1;
  ....
}

Similar errors can be found in some other places:

  • V3005 The 'num1' variable is assigned to itself. PlaceFinder.cs 2012

MSBuild

V3005 The '_nextProjectId' variable is assigned to itself. LoggingService.cs 325


public int NextProjectId
{
  get
  {
    lock (_lockObject)
    {
      _nextProjectId = _nextProjectId += MaxCPUCount + 2;  // <=
      return _nextProjectId;
    }
  }
}

PascalABC.NET

V3005 The 'miGenerateRealization.Visible' variable is assigned to itself. VisualPascalABCNET OptionsManager.cs 342


public void UpdateUserOptions()
{
  ....
  tsViewIntellisensePanel.Visible =
  .... =
  miGenerateRealization.Visible =
  miGenerateRealization.Visible =
  ....;
}

Similar errors can be found in some other places:

  • V3005 The 'visitNode' variable is assigned to itself. SyntaxVisitors SimplePrettyPrinterVisitor.cs 106

SubtitleEdit

V3005 The 'positionInfo' variable is assigned to itself. WebVTT.cs 79


internal static string GetPositionInfoFromAssTag(Paragraph p)
{
  ....
  if (!string.IsNullOrEmpty(line))
  {
    if (positionInfo == null)
      positionInfo = " line:" + line;
    else
      positionInfo = positionInfo += " line:" + line;
  }
  ....
}

Azure PowerShell

V3005 The 'this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent' variable is assigned to itself. SetAzureVMOperatingSystemCommand.cs 298


public override void ExecuteCmdlet()
{
  ....
  // OS Profile
  this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent =
    this.VM.OSProfile.WindowsConfiguration.ProvisionVMAgent;
  ....
}

[JsonProperty(PropertyName = "provisionVMAgent")]
public bool? ProvisionVMAgent { get; set; }

Azure PowerShell

V3005 The 'this.LastHeartbeat' variable is assigned to itself. PSFabricDetails.cs 804


public ASRInMageAzureV2SpecificRPIDetails(
  InMageAzureV2ReplicationDetails details)
{
  this.LastHeartbeat = this.LastHeartbeat;  // <=
  this.RecoveryAvailabilitySetId = details.RecoveryAvailabilitySetId;
  this.AgentVersion = details.AgentVersion;
  this.DiscoveryType = details.DiscoveryType;
  ....
}

public DateTime? LastHeartbeat { get; set; }

public class InMageAzureV2ReplicationDetails :
  ReplicationProviderSpecificSettings
{
  ....
  [JsonProperty(PropertyName = "lastHeartbeat")]
  public DateTime? LastHeartbeat { get; set; }
  ....
}

Similar errors can be found in some other places:

  • V3005 The 'this.ResourceGroupName' variable is assigned to itself. RemoveAzureRmExpressRouteConnectionCommand.cs 84
  • V3005 The 'this.ExpressRouteGatewayName' variable is assigned to itself. RemoveAzureRmExpressRouteConnectionCommand.cs 85
  • V3005 The 'this.Name' variable is assigned to itself. RemoveAzureRmExpressRouteConnectionCommand.cs 86


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

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

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

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

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

goto PVS-Studio;