Skip to content

Commit

Permalink
Remove unnecessary casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Manigandan Jegannathan committed Jun 8, 2020
1 parent f512390 commit 09c0cf7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Rules/ReviewUnusedParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,16 @@ private static bool IsBoundParametersReference(Ast ast)
&& memberAst.Member is StringConstantExpressionAst memberStringAst
&& memberStringAst.Value.Equals("BoundParameters", StringComparison.OrdinalIgnoreCase))
{
MemberExpressionAst meAst = (MemberExpressionAst)ast;

// $MyInvocation.BoundParameters
if (meAst.Expression is VariableExpressionAst veAst
if (memberAst.Expression is VariableExpressionAst veAst
&& veAst.VariablePath.UserPath.Equals("MyInvocation", StringComparison.OrdinalIgnoreCase))
{
return true;
}

// $PSCmdlet.MyInvocation.BoundParameters
if (meAst.Expression is MemberExpressionAst)
if (memberAst.Expression is MemberExpressionAst meAstNested)
{
MemberExpressionAst meAstNested = (MemberExpressionAst)meAst.Expression;

if (meAstNested.Expression is VariableExpressionAst veAstNested
&& veAstNested.VariablePath.UserPath.Equals("PSCmdlet", StringComparison.OrdinalIgnoreCase)
&& meAstNested.Member is StringConstantExpressionAst sceAstNested
Expand Down

0 comments on commit 09c0cf7

Please sign in to comment.