To get a trial key
fill out the form below
Team License (standard version)
Enterprise License (extended version)
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
GBP
RUB
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
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

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
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

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

** This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Message submitted.

Your message has been sent. We will email you at


If you haven't received our response, please do the following:
check your Spam/Junk folder and click the "Not Spam" button for our message.
This way, you won't miss messages from our team in the future.

>
>
Examples of errors detected by the V300…

Examples of errors detected by the V3001 diagnostic

Apr 05 2021

V3001. There are identical sub-expressions to the left and to the right of the 'foo' operator.


Umbraco

V3001 There are identical sub-expressions 'FocalPoint.Top != 0.5m' to the left and to the right of the '&&' operator. ImageCropDataSet.cs 58


public class ImageCropFocalPoint
{
  [DataMember(Name = "left")]
  public decimal Left { get; set; }

  [DataMember(Name = "top")]
  public decimal Top { get; set; }
}

public bool HasFocalPoint()
{
  return FocalPoint != null &&
         FocalPoint.Top != 0.5m && FocalPoint.Top != 0.5m;
}

Umbraco

V3001 There are identical sub-expressions 'node != null' to the left and to the right of the '&&' operator. BaseTree.cs 503


protected virtual void OnBeforeNodeRender(ref XmlTree sender,
                                          ref XmlTreeNode node,
                                          EventArgs e)
{
  if (node != null && node != null)
  {
    if (BeforeNodeRender != null)
      BeforeNodeRender(ref sender, ref node, e);
  }
}

Umbraco

V3001 There are identical sub-expressions 'key == ExifTag.WindowsTitle' to the left and to the right of the '||' operator. ExifPropertyCollection.cs 78


public void Set (ExifTag key, string value)
{
  if (items.ContainsKey (key))
    items.Remove (key);
  if (key == ExifTag.WindowsTitle ||         // <=
      key == ExifTag.WindowsTitle ||         // <=
      key == ExifTag.WindowsComment ||
      key == ExifTag.WindowsAuthor ||
      key == ExifTag.WindowsKeywords ||
      key == ExifTag.WindowsSubject) {
    items.Add (key, new WindowsByteString (key, value));
  ....
}

SharpDevelop

V3001 There are identical sub-expressions 'mc_a.Location.File' to the left and to the right of the '!=' operator. membercache.cs 1306


static
MemberCore GetLaterDefinedMember (MemberSpec a, MemberSpec b)
{
  var mc_a = a.MemberDefinition as MemberCore;
  var mc_b = b.MemberDefinition as MemberCore;

  ....

  if (mc_a.Location.File != mc_a.Location.File)
    return mc_b;

  return mc_b.Location.Row > mc_a.Location.Row ? mc_b : mc_a;
}

Microsoft Code Contracts

V3001 There are identical sub-expressions 'semanticType.Name == null' to the left and to the right of the '||' operator. ContractsProvider.cs 694


public bool TryGetTypeReference(....)
{
  ....
  if (semanticType.Name == null || semanticType.Name == null)
    goto ReturnFalse;
  cciType = new Microsoft.Cci.MutableCodeModel.NamespaceTypeR....
  {
    ContainingUnitNamespace = cciNamespace,
    GenericParameterCount = (ushort) (....),
    InternFactory = Host.InternFactory,
    IsValueType = semanticType.IsValueType,
    IsEnum = semanticType.TypeKind == TypeKind.Enum,
    Name = Host.NameTable.GetNameFor(semanticType.Name),
    TypeCode=CSharpToCCIHelper.GetPrimitiveTypeCode(semanticType)
  };
  goto ReturnTrue;'
  ....
}

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'semanticType.Name == null' to the left and to the right of the '||' operator. ContractsProvider.cs 714

MonoDevelop

V3001 There are identical sub-expressions 'string.IsNullOrEmpty (fixtureTypeName)' to the left and to the right of the '||' operator. MonoDevelop.NUnit NUnitProjectTestSuite.cs 84


protected override SourceCodeLocation
  GetSourceCodeLocation (string fixtureTypeNamespace,
                         string fixtureTypeName,
                         string methodName)
{
  if (string.IsNullOrEmpty (fixtureTypeName) ||
      string.IsNullOrEmpty (fixtureTypeName))
    return null;
  ....
}

MonoDevelop

V3001 There are identical sub-expressions 'doc.Editor != null' to the left and to the right of the '&&' operator. MonoDevelop.AspNet RazorCSharpParser.cs 180


bool TryAddDocument (string fileName,
         out OpenRazorDocument currentDocument)
{
  ....
  var guiDoc = IdeApp.Workbench.GetDocument (fileName);
  if (guiDoc != null && guiDoc.Editor != null)
  ....
  guiDoc.Closed += (sender, args) =>
  {
    var doc = sender as MonoDevelop.Ide.Gui.Document;
    if (doc.Editor != null && doc.Editor != null)
    ....
  }
  ....
}

MonoDevelop

V3001 There are identical sub-expressions 'mc_a.Location.File' to the left and to the right of the '!=' operator. ICSharpCode.NRefactory.CSharp membercache.cs 1319


static MemberCore
  GetLaterDefinedMember(MemberSpec a, MemberSpec b)
{
  var mc_a = a.MemberDefinition as MemberCore;
  var mc_b = b.MemberDefinition as MemberCore;
  if (mc_a == null)
    return mc_b;

  if (mc_b == null)
    return mc_a;

  if (a.DeclaringType.MemberDefinition !=
      b.DeclaringType.MemberDefinition)
    return mc_b;

  if (mc_a.Location.File != mc_a.Location.File)
    return mc_b;

  return mc_b.Location.Row > mc_a.Location.Row ? mc_b : mc_a;
}

MonoDevelop

V3001 There are identical sub-expressions 'resultIter != null' to the left and to the right of the '&&' operator. MonoDevelop.Ide GtkTreeModelResult.cs 125


public override AppResult
  Property(string propertyName, object value)
{
  if (resultIter != null && resultIter.HasValue) {
    var objectToCompare =
           TModel.GetValue (resultIter.Value, Column);
    return MatchProperty (propertyName, objectToCompare, value);
  }

  return MatchProperty (propertyName, ParentWidget, value);
}

TreeIter? resultIter;

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'resultIter != null' to the left and to the right of the '&&' operator. MonoDevelop.Ide GtkTreeModelResult.cs 135

MonoDevelop

V3001 There are identical sub-expressions 'member1.DeclaredAccessibility' to the left and to the right of the '!=' operator. CSharpBinding AbstractImplementInterfaceService.CodeAction.cs 544


Accessibility DeclaredAccessibility { get; }
bool IsStatic { get; }

private bool MembersMatch(ISymbol member1, ISymbol member2)
{
  if (member1.Kind != member2.Kind)
  {
    return false;
  }

  if (member1.DeclaredAccessibility !=
      member1.DeclaredAccessibility
   || member1.IsStatic != member1.IsStatic)
  {
    return false;
  }

  if (member1.ExplicitInterfaceImplementations().Any() ||
      member2.ExplicitInterfaceImplementations().Any())
  {
    return false;
  }

  return SignatureComparer
    .HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(
       member1, member2, this.IsCaseSensitive);
}

MonoDevelop

V3001 There are identical sub-expressions 'member1.IsStatic' to the left and to the right of the '!=' operator. CSharpBinding AbstractImplementInterfaceService.CodeAction.cs 545


Accessibility DeclaredAccessibility { get; }
bool IsStatic { get; }

private bool MembersMatch(ISymbol member1, ISymbol member2)
{
  if (member1.Kind != member2.Kind)
  {
    return false;
  }

  if (member1.DeclaredAccessibility !=
      member1.DeclaredAccessibility
   || member1.IsStatic != member1.IsStatic)
  {
    return false;
  }

  if (member1.ExplicitInterfaceImplementations().Any() ||
      member2.ExplicitInterfaceImplementations().Any())
  {
    return false;
  }

  return SignatureComparer
    .HaveSameSignatureAndConstraintsAndReturnTypeAndAccessors(
       member1, member2, this.IsCaseSensitive);
}

IronPython and IronRuby

V3001 There are identical sub-expressions 'litBegin.Value is int' to the left and to the right of the '&&' operator. IronRubyParseTreeOps.cs 277


private bool Enter(RangeExpression/*!*/ node, bool isCondition) {
  ....
  if (!isCondition && litBegin != null && litEnd != null
    && litBegin.Value is int && litBegin.Value is int) {
    _result = MakeNode(NodeKind.lit, new Range(
      (int)litBegin.Value, (int)litEnd.Value,
      node.IsExclusive));
  } else {
    ....
  }
  ....
}

IronPython and IronRuby

V3001 There are identical sub-expressions 'self is PythonDictionary' to the left and to the right of the '||' operator. IronPython ObjectOps.cs 452


private static PythonTuple ReduceProtocol2(
  CodeContext/*!*/ context, object self) {
  ....
  if (self is PythonDictionary || self is PythonDictionary) {
    dictIterator = PythonOps.Invoke(context, self,
      "iteritems", ArrayUtils.EmptyObjects);
  }
  ....
}

Samples by the Infragistics Company

V3001 There are identical sub-expressions 'double.IsNaN(Latitude)' to the left and to the right of the '||' operator. WeatherStation.cs 25


public bool IsValid
{
  get {
    var valid =
      double.IsNaN(Latitude) || double.IsNaN(Latitude) ||
      this.Weather.DateTime == Weather.DateTimeInitial;
    return valid;
  }
}

Samples by the Infragistics Company

V3001 There are identical sub-expressions 'xmax > rc.Right' to the left and to the right of the '&&' operator. Geometry. Geometry.CubicSpline.cs 529


private static int clipSegment(....)
{
  if (xmax > rc.Right && xmax > rc.Right)
  {
    return -1;
  }
}

Samples by the Infragistics Company

V3001 There are identical sub-expressions 'LineSpacingType == Infrastructure.LineSpacingTypes.Exactly' to the left and to the right of the '||' operator. ParagraphSettingsPreviewAdapter.cs 268


void ParagraphSettingsPreviewAdapter_PropertyChanged(
 object sender, PropertyChangedEventArgs e) {
  ....
  if (LineSpacingType == Infrastructure.LineSpacingTypes.Exactly
   || LineSpacingType == Infrastructure.LineSpacingTypes.Exactly)
  { .... }

Space Engineers

V3001 There are identical sub-expressions 'property.Name == "AxisScale"' to the left and to the right of the '||' operator. Sandbox.Graphics MyParticleEmitter.cs 352


void DeserializeV0(XmlReader reader)
{
  ....
  if (property.Name == "Rotation"  ||
      property.Name == "AxisScale" ||
      property.Name == "AxisScale")
    continue;
  ....
}

Xenko

V3001 There are identical sub-expressions 'SupportFormat(converting.Format)' to the left and to the right of the '&&' operator. SiliconStudio.TextureConverter DxtTexLib.cs 141


public bool CanHandleRequest(TexImage image, IRequest request)
{
  ....
  return SupportFormat(compress.Format) &&
           SupportFormat(image.Format);
  ....
  return SupportFormat(converting.Format) &&
           SupportFormat(converting.Format);      // <=
  ....
}

Xenko

V3001 There are identical sub-expressions 'rescale.Filter == Filter.Rescaling.Bicubic' to the left and to the right of the '||' operator. SiliconStudio.TextureConverter DxtTexLib.cs 148


public enum Rescaling
{
  Box = 0,
  Bicubic = 1,
  Bilinear = 2,
  BSpline = 3,
  CatmullRom = 4,
  Lanczos3 = 5,
  Nearest,
}

public bool CanHandleRequest(TexImage image, IRequest request)
{
  ....
  return rescale.Filter == Filter.Rescaling.Box      ||
           rescale.Filter == Filter.Rescaling.Bicubic ||  // <=
           rescale.Filter == Filter.Rescaling.Bicubic ||  // <=
           rescale.Filter == Filter.Rescaling.Nearest;
  ....
}

Xenko

V3001 There are identical sub-expressions 'box.Maximum.X - box.Minimum.X > sphere.Radius' to the left and to the right of the '&&' operator. SiliconStudio.Core.Mathematics Collision.cs 1322


public static ContainmentType BoxContainsSphere(
                                ref BoundingBox box,
                                ref BoundingSphere sphere)
{
  ....
  if ((((box.Minimum.X + sphere.Radius <= sphere.Center.X)    &&
        (sphere.Center.X <= box.Maximum.X - sphere.Radius))   &&
       ((box.Maximum.X - box.Minimum.X > sphere.Radius)      &&
       (box.Minimum.Y + sphere.Radius <= sphere.Center.Y)))  &&
      (((sphere.Center.Y <= box.Maximum.Y - sphere.Radius)   &&
        (box.Maximum.Y - box.Minimum.Y > sphere.Radius))    &&
      (((box.Minimum.Z + sphere.Radius <= sphere.Center.Z)    &&
      (sphere.Center.Z <= box.Maximum.Z - sphere.Radius))     &&
        (box.Maximum.X - box.Minimum.X > sphere.Radius))))
  ....
}

Xenko

V3001 There are identical sub-expressions 'item.Key == null' to the left and to the right of the '||' operator. SiliconStudio.Core MultiValueSortedDictionary.cs 318


public bool Remove(KeyValuePair<TKey, Tvalue> item)
{
  if (item.Key == null ||
      item.Key == null)
    throw new ArgumentException();
  ....
}

Xamarin.Forms

V3001 There are identical sub-expressions 'RwWait' to the left and to the right of the '|' operator. SplitOrderedList.cs 458


const int RwWait  = 1;
const int RwWrite = 2;
const int RwRead  = 4;
....

public void EnterReadLock()
{
  ....

  if ((Interlocked.Add(ref _rwlock, RwRead) &
      (RwWait | RwWait)) == 0)
    return;

  ....
}

Xamarin.Forms

V3001 There are identical sub-expressions 'Left == 0' to the left and to the right of the '&&' operator. Thickness.cs 29


public double Left   { get; set; }
public double Top    { get; set; }
public double Right  { get; set; }
public double Bottom { get; set; }

internal bool IsDefault
{
  get { return Left  == 0 && Top  == 0 &&
               Right == 0 && Left == 0; }
}

Accord.Net

V3001 There are identical sub-expressions 'image.PixelFormat != PixelFormat.Format32bppRgb' to the left and to the right of the '&&' operator. Accord.Imaging BlobCounterBase.cs 670


public Blob[] GetObjects(UnmanagedImage image,
                         bool extractInOriginalSize)
{
  ....
  if ((image.PixelFormat != PixelFormat.Format24bppRgb)    &&
      (image.PixelFormat != PixelFormat.Format8bppIndexed) &&
      (image.PixelFormat != PixelFormat.Format32bppRgb)    &&
      (image.PixelFormat != PixelFormat.Format32bppArgb)   &&
      (image.PixelFormat != PixelFormat.Format32bppRgb)    &&
      (image.PixelFormat != PixelFormat.Format32bppPArgb)
      )
  ....
}

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'image.PixelFormat != PixelFormat.Format32bppRgb' to the left and to the right of the '&&' operator. Accord.Imaging BlobCounterBase.cs 833

Mono

V3001 There are identical sub-expressions 'u.TypeArguments.Length' to the left and to the right of the '!=' operator. generic.cs 3135


public int ExactInference (TypeSpec u, TypeSpec v)
{
  ....
  var ac_u = (ArrayContainer) u;
  var ac_v = (ArrayContainer) v;
  ....
  var ga_u = u.TypeArguments;
  var ga_v = v.TypeArguments;
  ....
  if (u.TypeArguments.Length != u.TypeArguments.Length) // <=
    return 0;

  ....
}

Mono

V3001 There are identical sub-expressions 'j' to the left and to the right of the '-' operator. ecore.cs 4832


bool BetterFunction (....)
{
  ....
  int j = 0;
  ....
  if (!candidate_params &&
      !candidate_pd.FixedParameters [j - j]  // <=
                   .HasDefaultValue) {
    return true;
  }
  ....
  if (!candidate_pd.FixedParameters [j - 1].HasDefaultValue &&
       best_pd.FixedParameters [j - 1].HasDefaultValue)
    return true;

  if (candidate_pd.FixedParameters [j - 1].HasDefaultValue &&
      best_pd.HasParams)
    return true;
  ....
}

Mono

V3001 There are identical sub-expressions 'c != '<'' to the left and to the right of the '&&' operator. HttpListenerRequest.cs 99


internal void SetRequestLine (string req)
{
  ....
  if ((ic >= 'A' && ic <= 'Z') ||
      (ic > 32 && c < 127 && c != '(' && c != ')' && c != '<' &&
       c != '<' && c != '>'  && c != '@'  && c != ','         &&
       c != ';' && c != ':'  && c != '\\' && c != '"'         &&
       c != '/' && c != '['  && c != ']'  && c != '?'         &&
       c != '=' && c != '{'  && c != '}'))
    continue;
  ....
}

Mono

V3001 There are identical sub-expressions 'grid_style.LinkHoverColor' to the left and to the right of the '!=' operator. DataGrid.cs 2225


protected virtual bool ShouldSerializeLinkHoverColor ()
{
  return grid_style.LinkHoverColor != grid_style.LinkHoverColor;
}

Mono

V3001 There are identical sub-expressions 'value1.ClassName' to the left and to the right of the '==' operator. ThemeVisualStyles.cs 2141


static bool AreEqual (VisualStyleElement value1,
                      VisualStyleElement value2)
{
  return
    value1.ClassName == value1.ClassName && // <=
    value1.Part == value2.Part &&
    value1.State == value2.State;
}

GitExtensions

V3001 There are identical sub-expressions to the left and to the right of the '||' operator. GitUI FormRemotes.cs 192


private void ConfigureRemotes()
{
  ....
  if (!remoteHead.IsRemote ||
    localHead.IsRemote ||
    !string.IsNullOrEmpty(
      localHead.GetTrackingRemote(localConfig)) || // <=
    !string.IsNullOrEmpty(
      localHead.GetTrackingRemote(localConfig)) || // <=
    remoteHead.IsTag ||
    localHead.IsTag ||
    !remoteHead.Name.ToLower().Contains(
      localHead.Name.ToLower()) ||
    !remoteHead.Name.ToLower().Contains(
      _remote.ToLower()))
    continue;
  ....
}

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions '!curItem.IsSourceEqual(item.NeutralValue)' to the left and to the right of the '&&' operator. TranslationApp TranslationHelpers.cs 112

PowerShell

V3001 There are identical sub-expressions 'BaseMaximumVersion != null' to the left and to the right of the '&&' operator. System.Management.Automation ImportModuleCommand.cs 1663


internal Version BaseMinimumVersion { get; set; }
internal Version BaseMaximumVersion { get; set; }
protected override void ProcessRecord()
{
  if (BaseMaximumVersion != null &&
      BaseMaximumVersion != null &&
      BaseMaximumVersion < BaseMinimumVersion)
  {
    string message = StringUtil.Format(
      Modules.MinimumVersionAndMaximumVersionInvalidRange,
      BaseMinimumVersion,
      BaseMaximumVersion);
    throw new PSArgumentOutOfRangeException(message);
  }
  ....
}

PowerShell

V3001 There are identical sub-expressions to the left and to the right of the '&&' operator. System.Management.Automation serverremotesession.cs 633


internal static class RemoteDataNameStrings
{
  ....
  internal const string MinRunspaces = "MinRunspaces";
  internal const string MaxRunspaces = "MaxRunspaces";
  ....
}
internal void ExecuteConnect(....)
{
  ....
  if
  (
    connectRunspacePoolObject.Data
      .Properties[RemoteDataNameStrings.MinRunspaces] != null
    &&
    connectRunspacePoolObject.Data
      .Properties[RemoteDataNameStrings.MinRunspaces] != null
  )
  {
    try
    {
      clientRequestedMinRunspaces =
        RemotingDecoder.GetMinRunspaces(
          connectRunspacePoolObject.Data);
      clientRequestedMaxRunspaces =
        RemotingDecoder.GetMaxRunspaces(
          connectRunspacePoolObject.Data);
      clientRequestedRunspaceCount = true;
    }
    ....
  }
  ....
}

Media Portal 2

V3001 There are identical sub-expressions 'screenWidth != _screenSize.Width' to the left and to the right of the '||' operator. MainForm.cs 922


protected override void WndProc(ref Message m)
{
  int bitDepth = m.WParam.ToInt32();
  int screenWidth = m.LParam.ToInt32() & 0xFFFF;
  int screenHeight = m.LParam.ToInt32() >> 16;  // <=
  if (bitDepth != _screenBpp ||
      screenWidth != _screenSize.Width ||
      screenWidth != _screenSize.Width)         // <=
  {
    ....
  }

  ....
}

Instead of 'screenWidth' and '_screenSize.Width', we must use 'screenHeight' and '_screenSize.Height'.

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'p == null' to the left and to the right of the '||' operator. TriangulationConstraint.cs 141

PascalABC.NET

V3001 There are identical sub-expressions 'token.Kind == openBracketToken' to the left and to the right of the '||' operator. ICSharpCode.SharpDevelop NRefactoryInsightWindowHandler.cs 66


readonly int eofToken,
             commaToken,
             openParensToken,
             closeParensToken,
             openBracketToken,
             closeBracketToken,
             openBracesToken,
             closeBracesToken,
             statementEndToken;

public void InitializeOpenedInsightWindow(....)
{
  ....
  if (token.Kind == openParensToken ||
      token.Kind == openBracketToken ||
      token.Kind == openBracketToken) {  // <=
    bracketCount++;
  }
  ....
}

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'File.Exists(pdbFileName)' to the left and to the right of the '&&' operator. VisualPascalABCNET RunnerManagerHandlers.cs 165
  • V3001 There are identical sub-expressions '_pascal_set_constant.values != null' to the left and to the right of the '&&' operator. TreeConverter syntax_tree_visitor.cs 4553

Unity C# reference source code

V3001 There are identical sub-expressions 'MethodAttributes.Public' to the left and to the right of the '|' operator. SyncListStructProcessor.cs 240


MethodReference GenerateSerialization()
{
  ....
  MethodDefinition serializeFunc = new
      MethodDefinition("SerializeItem", MethodAttributes.Public |
            MethodAttributes.Virtual |
            MethodAttributes.Public |  // <=
            MethodAttributes.HideBySig,
            Weaver.voidType);
  ....
}

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'MethodAttributes.Public' to the left and to the right of the '|' operator. SyncListStructProcessor.cs 309

Unity C# reference source code

V3001 There are identical sub-expressions 'format == RenderTextureFormat.ARGBFloat' to the left and to the right of the '||' operator. RenderTextureEditor.cs 87


public static bool IsHDRFormat(RenderTextureFormat format)
{
  Return (format == RenderTextureFormat.ARGBHalf ||
    format == RenderTextureFormat.RGB111110Float ||
    format == RenderTextureFormat.RGFloat ||
    format == RenderTextureFormat.ARGBFloat ||
    format == RenderTextureFormat.ARGBFloat ||
    format == RenderTextureFormat.RFloat ||
    format == RenderTextureFormat.RGHalf ||
    format == RenderTextureFormat.RHalf);
}

Infer.NET

V3001 There are identical sub-expressions 'double.IsInfinity(transition1.Weight.Value)' to the left and to the right of the '&&' operator. Runtime Automaton.Simplification.cs 479


private void MergeParallelTransitions()
{
  ....
  if (   transition1.DestinationStateIndex ==
         transition2.DestinationStateIndex
      &&
         transition1.Group ==
         transition2.Group)
  {
    if (transition1.IsEpsilon && transition2.IsEpsilon)
    {
      ....
    }
    else if (!transition1.IsEpsilon && !transition2.IsEpsilon)
    {
      ....
      if (double.IsInfinity(transition1.Weight.Value) &&
          double.IsInfinity(transition1.Weight.Value))
      {
        newElementDistribution.SetToSum(
          1.0, transition1.ElementDistribution,
          1.0, transition2.ElementDistribution);
      }
      else
      {
        newElementDistribution.SetToSum(
          transition1.Weight.Value, transition1.ElementDistribution,
          transition2.Weight.Value, transition2.ElementDistribution);
      }
  ....
}

Infer.NET

V3001 There are identical sub-expressions 'BindingFlags.Public' to the left and to the right of the '|' operator. Compiler CodeBuilder.cs 194


internal MethodBase ToMethodInternal(IMethodReference imr)
{
  ....
  bf |=   BindingFlags.Public
        | BindingFlags.NonPublic
        | BindingFlags.Public
        | BindingFlags.Instance;
  ....
}

AWS SDK for .NET

V3001 There are identical sub-expressions 'this.token == JsonToken.String' to the left and to the right of the '||' operator. AWSSDK.Core.Net45 JsonReader.cs 343


public bool Read()
{
  ....
  if (
    (this.token == JsonToken.ObjectEnd ||
    this.token == JsonToken.ArrayEnd ||
    this.token == JsonToken.String ||  // <=
    this.token == JsonToken.Boolean ||
    this.token == JsonToken.Double ||
    this.token == JsonToken.Int ||
    this.token == JsonToken.UInt ||
    this.token == JsonToken.Long ||
    this.token == JsonToken.ULong ||
    this.token == JsonToken.Null ||
    this.token == JsonToken.String  // <=
    ))
  {
    ....
  }
  ....
}

.NET Core Libraries (CoreFX)

V3001 There are identical sub-expressions 'CharType.Comment' to the left and to the right of the '|' operator. XmlUTF8TextReader.cs 56


private static byte[] s_charType = new byte[256]
{
  ....
  CharType.None|
  CharType.Comment|
  CharType.Comment|
  CharType.Whitespace|
  CharType.Text|
  CharType.SpecialWhitespace,
  ....
  CharType.None|
  CharType.Comment|
  CharType.Comment|
  CharType.Whitespace|
  CharType.Text|
  CharType.SpecialWhitespace,
  ....
  CharType.None|
  CharType.Comment|
  CharType.Comment|
  CharType.Whitespace,
  ....
};

Similar errors can be found in some other places:

  • V3001 There are identical sub-expressions 'CharType.Comment' to the left and to the right of the '|' operator. XmlUTF8TextReader.cs 58
  • V3001 There are identical sub-expressions 'CharType.Comment' to the left and to the right of the '|' operator. XmlUTF8TextReader.cs 64

Roslyn Analyzers

V3001 There are identical sub-expressions 'data1.IsReachableBlockData' to the left and to the right of the '==' operator. AnalysisEntityBasedPredicateAnalysisData.cs 39


protected AnalysisEntityBasedPredicateAnalysisData(....)
  : base(....)
{
  Debug.Assert(data1.IsReachableBlockData == data1.IsReachableBlockData);
  ....
}

Azure PowerShell

V3001 There are identical sub-expressions 'strTimespan.Contains("M")' to the left and to the right of the '||' operator. AzureServiceBusCmdletBase.cs 187


public static TimeSpan ParseTimespan(string strTimespan)
{
  ....
  if (strTimespan.Contains("P")
    || strTimespan.Contains("D")
    || strTimespan.Contains("T")
    || strTimespan.Contains("H")
    || strTimespan.Contains("M")
    || strTimespan.Contains("M"))
  ....
}

Azure PowerShell

V3001 There are identical sub-expressions 'this.AggregationType != null' to the left and to the right of the '&&' operator. GetAzureRmMetricCommand.cs 156


public AggregationType? AggregationType { get; set; }
....
protected override void ProcessRecordInternal()
{
  ....
  string aggregation = (this.AggregationType != null &&
    this.AggregationType.HasValue) ?
    this.AggregationType.Value.ToString() : null;
  ....
}

Telerik UI for UWP

V3001 There are identical sub-expressions 'newValue.HasValue' to the left and to the right of the '&&' operator. DateTimePicker.cs 576


private static void OnValueChanged(object sender,
                                   DependencyPropertyChangedEventArgs args)
{
  DateTimePicker picker = sender as DateTimePicker;

  var newValue = (DateTime?)args.NewValue;

  if (newValue.HasValue && newValue != null)      // <=
  {
    picker.utcValue = DateTime.SpecifyKind(newValue.Value,
                                           DateTimeKind.Utc);
  }
  else
  {
    picker.utcValue = DateTime.SpecifyKind(DateTime.Now,
                                           DateTimeKind.Utc);
  }
  ....
}

Azure SDK for .NET

V3001 There are identical sub-expressions 'buffer.Length' to the left and to the right of the '<' operator. AzureBaseBuffersExtensions.cs 30


public static async Task WriteAsync(...., ReadOnlyMemory<byte> buffer, ....)
{
  byte[]? array = null;
  ....
  if (array == null || buffer.Length < buffer.Length)
  {
    ....
  }
  ....
}

AvaloniaUI

V3001 There are identical sub-expressions 'controlledFlags' to the left and to the right of the '^' operator. WindowImpl.cs 975TwitterClientMessageHandler.cs 52


private void UpdateWMStyles(Action change)
{
  ....
  var style = (WindowStyles)GetWindowLong(....);
  ....
  style = style | controlledFlags ^ controlledFlags;
  ....
}

osu!

V3001 There are identical sub-expressions 'result == HitResult.Perfect' to the left and to the right of the '||' operator. DrawableHoldNote.cs 266


protected override void CheckForResult(....)
{
  ....
  ApplyResult(r =>
  {
    if (holdNote.hasBroken
      && (result == HitResult.Perfect || result == HitResult.Perfect))
      result = HitResult.Good;
    ....
  });
}

public enum HitResult
{
    None,
    Miss,
    Meh,
    Ok,
    Good,
    Great,
    Perfect,
}

osu!

V3001 There are identical sub-expressions 'family != GetFamilyString(TournamentTypeface.Aquatico)' to the left and to the right of the '&&' operator. TournamentFont.cs 64


public static string GetWeightString(string family, FontWeight weight)
{
  ....
  if (weight == FontWeight.Regular
    && family != GetFamilyString(TournamentTypeface.Aquatico)
    && family != GetFamilyString(TournamentTypeface.Aquatico))
    weightString = string.Empty;
  ....
}

Emby

V3001 There are identical sub-expressions 'c != '<'' to the left and to the right of the '&&' operator. HttpListenerRequest.Managed.cs 49


internal void SetRequestLine(string req)
{
  ....
  if ((ic >= 'A' && ic <= 'Z') ||
  (ic > 32 && c < 127 && c != '(' && c != ')' && c != '<' &&   // <=
  c != '<' && c != '>' && c != '@' && c != ',' && c != ';' &&  // <=
  c != ':' && c != '\\' && c != '"' && c != '/' && c != '[' &&
  c != ']' && c != '?' && c != '=' && c != '{' && c != '}'))
    continue;
  ....
}

RunUO

V3001 There are identical sub-expressions 'deed is SmallBrickHouseDeed' to the left and to the right of the '||' operator. RealEstateBroker.cs 132


public int ComputePriceFor( HouseDeed deed )
{
  int price = 0;

  if ( deed is SmallBrickHouseDeed ||    // <=
       deed is StonePlasterHouseDeed ||
       deed is FieldStoneHouseDeed ||
       deed is SmallBrickHouseDeed ||    // <=
       deed is WoodHouseDeed ||
       deed is WoodPlasterHouseDeed ||
       deed is ThatchedRoofCottageDeed )
      ....
}

Chocolatey

V3001 There are identical sub-expressions 'commandArguments.contains("-apikey")' to the left and to the right of the '||' operator. ArgumentsUtility.cs 42


public static bool arguments_contain_sensitive_information(string
 commandArguments)
{
  return commandArguments.contains("-install-arguments-sensitive")
  || commandArguments.contains("-package-parameters-sensitive")
  || commandArguments.contains("apikey ")
  || commandArguments.contains("config ")
  || commandArguments.contains("push ")
  || commandArguments.contains("-p ")
  || commandArguments.contains("-p=")
  || commandArguments.contains("-password")
  || commandArguments.contains("-cp ")
  || commandArguments.contains("-cp=")
  || commandArguments.contains("-certpassword")
  || commandArguments.contains("-k ")
  || commandArguments.contains("-k=")
  || commandArguments.contains("-key ")
  || commandArguments.contains("-key=")
  || commandArguments.contains("-apikey")
  || commandArguments.contains("-api-key")
  || commandArguments.contains("-apikey")
  || commandArguments.contains("-api-key");
}

Nethermind

V3001 There are identical sub-expressions 'a.s2 == b.s2' to the left and to the right of the '&&' operator. Nethermind.Dirichlet.Numerics UInt256.cs 1154


public static bool Equals(ref UInt256 a, ref UInt256 b)
{
  return a.s0 == b.s0 && a.s1 == b.s1 && a.s2 == b.s2 && a.s2 == b.s2;
}

ONLYOFFICE Community Server

V3001 There are identical sub-expressions 'searchFilterData.WithCalendar == WithCalendar' to the left and to the right of the '&&' operator. MailSearchFilterData.cs 131


public override bool Equals(object obj)
{
    var searchFilterData = obj as MailSearchFilterData;
    return searchFilterData != null &&
      searchFilterData.PrimaryFolder == PrimaryFolder &&
      searchFilterData.Unread == Unread &&
      searchFilterData.Attachments == Attachments &&
      searchFilterData.PeriodFrom == PeriodFrom &&
      searchFilterData.PeriodTo == PeriodTo &&
      searchFilterData.Important == Important &&
      searchFilterData.Sort == Sort &&
      searchFilterData.SortOrder == SortOrder &&
      searchFilterData.SearchText == SearchText &&
      searchFilterData.Page == Page &&
      searchFilterData.PageSize == PageSize &&
      searchFilterData.SetLabel == SetLabel &&
      searchFilterData.WithCalendar == WithCalendar &&  // <=
      searchFilterData.WithCalendar == WithCalendar &&  // <=
      searchFilterData.UserFolderId == UserFolderId &&
      searchFilterData.FromDate == FromDate &&
      searchFilterData.FromMessage == FromMessage &&
      searchFilterData.PrevFlag == PrevFlag;
}

EFCore

V3001 There are identical sub-expressions 'unaryExpression.NodeType == ExpressionType.Convert' to the left and to the right of the '||' operator. EFCore.Specification.Tests NorthwindStringIncludeQueryTestBase.cs 257


private static string GetPath(Expression expression)
{
  switch (expression)
  {
    ....
    case UnaryExpression unaryExpression
         when unaryExpression.NodeType == ExpressionType.Convert
           || unaryExpression.NodeType == ExpressionType.Convert
           || unaryExpression.NodeType == ExpressionType.TypeAs:

      return GetPath(unaryExpression.Operand);

    default:
      throw ....
  }
}

EFCore

V3001 There are identical sub-expressions 'sqlFunctionName == "max"' to the left and to the right of the '||' operator. EFCore.Sqlite.Core SqliteMathTranslator.cs 90


private static readonly Dictionary<MethodInfo, string> _supportedMethods = new()
{
  ....
  { typeof(Math).GetRequiredMethod(nameof(Math.Max), ...., "max" },
  { typeof(Math).GetRequiredMethod(nameof(Math.Min), ...., "min" },
  ....
};

public virtual SqlExpression? Translate(SqlExpression? instance, ....)
{
  if (_supportedMethods.TryGetValue(method, out var sqlFunctionName))
  {
    ....
    if (sqlFunctionName == "max" || sqlFunctionName == "max")
      ....
  }
  ....
}

Popular related articles
The Last Line Effect

Date: May 31 2014

Author: Andrey Karpov

I have studied many errors caused by the use of the Copy-Paste method, and can assure you that programmers most often tend to make mistakes in the last fragment of a homogeneous code block. I have ne…
Appreciate Static Code Analysis!

Date: Oct 16 2017

Author: Andrey Karpov

I am really astonished by the capabilities of static code analysis even though I am one of the developers of PVS-Studio analyzer myself. The tool surprised me the other day as it turned out to be sma…
Technologies used in the PVS-Studio code analyzer for finding bugs and potential vulnerabilities

Date: Nov 21 2018

Author: Andrey Karpov

A brief description of technologies used in the PVS-Studio tool, which let us effectively detect a large number of error patterns and potential vulnerabilities. The article describes the implementati…
Characteristics of PVS-Studio Analyzer by the Example of EFL Core Libraries, 10-15% of False Positives

Date: Jul 31 2017

Author: Andrey Karpov

After I wrote quite a big article about the analysis of the Tizen OS code, I received a large number of questions concerning the percentage of false positives and the density of errors (how many erro…
How PVS-Studio Proved to Be More Attentive Than Three and a Half Programmers

Date: Oct 22 2018

Author: Andrey Karpov

Just like other static analyzers, PVS-Studio often produces false positives. What you are about to read is a short story where I'll tell you how PVS-Studio proved, just one more time, to be more atte…
Static analysis as part of the development process in Unreal Engine

Date: Jun 27 2017

Author: Andrey Karpov

Unreal Engine continues to develop as new code is added and previously written code is changed. What is the inevitable consequence of ongoing development in a project? The emergence of new bugs in th…
The Ultimate Question of Programming, Refactoring, and Everything

Date: Apr 14 2016

Author: Andrey Karpov

Yes, you've guessed correctly - the answer is "42". In this article you will find 42 recommendations about coding in C++ that can help a programmer avoid a lot of errors, save time and effort. The au…
Free PVS-Studio for those who develops open source projects

Date: Dec 22 2018

Author: Andrey Karpov

On the New 2019 year's eve, a PVS-Studio team decided to make a nice gift for all contributors of open-source projects hosted on GitHub, GitLab or Bitbucket. They are given free usage of PVS-Studio s…
PVS-Studio for Java

Date: Jan 17 2019

Author: Andrey Karpov

In the seventh version of the PVS-Studio static analyzer, we added support of the Java language. It's time for a brief story of how we've started making support of the Java language, how far we've co…
The way static analyzers fight against false positives, and why they do it

Date: Mar 20 2017

Author: Andrey Karpov

In my previous article I wrote that I don't like the approach of evaluating the efficiency of static analyzers with the help of synthetic tests. In that article, I give the example of a code fragment…

Comments (0)

Next comments

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site.
Learn More →
Accept