Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7721c7b

Browse files
committed
C#: Remove redundant conditions
1 parent cbdd131 commit 7721c7b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

csharp/extractor/Semmle.Extraction.CSharp/Entities/Expressions/Assignment.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ private static ExprKind GetAssignmentOperation(Context cx, AssignmentExpressionS
8181

8282
private static ExprKind GetKind(Context cx, AssignmentExpressionSyntax syntax)
8383
{
84-
var leftSymbol = cx.GetSymbolInfo(syntax.Left);
85-
var assignEvent = leftSymbol.Symbol != null && leftSymbol.Symbol is IEventSymbol;
8684
var kind = GetAssignmentOperation(cx, syntax);
8785
var leftType = cx.GetType(syntax.Left);
8886

@@ -93,6 +91,9 @@ private static ExprKind GetKind(Context cx, AssignmentExpressionSyntax syntax)
9391
return kind;
9492
}
9593

94+
var leftSymbol = cx.GetSymbolInfo(syntax.Left);
95+
var assignEvent = leftSymbol.Symbol is IEventSymbol;
96+
9697
if (kind == ExprKind.ASSIGN_ADD && assignEvent)
9798
{
9899
return ExprKind.ADD_EVENT;

csharp/extractor/Semmle.Extraction.CSharp/Entities/Types/Type.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,9 @@ public void ExtractRecursive(TextWriter trapFile, IEntity parent)
276276
public static Type Create(Context cx, ITypeSymbol type)
277277
{
278278
type = type.DisambiguateType();
279-
const bool errorTypeIsNull = false;
280-
return type == null || (errorTypeIsNull && type.TypeKind == TypeKind.Error) ?
281-
NullType.Create(cx).Type : (Type)cx.CreateEntity(type);
279+
return type == null
280+
? NullType.Create(cx).Type
281+
: (Type)cx.CreateEntity(type);
282282
}
283283

284284
public static AnnotatedType Create(Context cx, AnnotatedTypeSymbol type) =>

0 commit comments

Comments
 (0)