Skip to content

Commit

Permalink
Fixes SonarQube's "Null checks should not be used with 'is'" / Code S…
Browse files Browse the repository at this point in the history
…mell (dotnet#1059)

* Fix SonarQube's "Null checks should not be used with 'is'" / Code Smell

* Revert wrongly refactored "Null checks should not be used with 'is'"
  • Loading branch information
marodev authored and lytico committed Jun 8, 2021
1 parent e82f99c commit 22dacae
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Controls/src/Core/Accelerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public override string ToString()

public override bool Equals(object obj)
{
return obj != null && obj is Accelerator && Equals((Accelerator)obj);
return obj is Accelerator && Equals((Accelerator)obj);
}

bool Equals(Accelerator other)
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/src/Core/TypedBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ internal override void Unapply(bool fromBindingContextChanged = false)
// ApplyCore 100000 (w/o INPC, w/o unnapply) : 20ms.
internal void ApplyCore(object sourceObject, BindableObject target, BindableProperty property, bool fromTarget = false)
{
var isTSource = sourceObject != null && sourceObject is TSource;
var isTSource = sourceObject is TSource;
var mode = this.GetRealizedMode(property);
if ((mode == BindingMode.OneWay || mode == BindingMode.OneTime) && fromTarget)
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Primitives/GridLength.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public GridLength(double value, GridUnitType type)

public override bool Equals(object? obj)
{
return obj != null && obj is GridLength && Equals((GridLength)obj);
return obj is GridLength && Equals((GridLength)obj);
}

bool Equals(GridLength other)
Expand Down

0 comments on commit 22dacae

Please sign in to comment.