@@ -620,7 +620,7 @@ public bool IsCmdlet(CommandAst cmdAst) {
620
620
/// Given a commandast, checks whether positional parameters are used or not.
621
621
/// </summary>
622
622
/// <param name="cmdAst"></param>
623
- /// <param name="moreThanTwoPositional">only return true if more than three positional parameters are used</param>
623
+ /// <param name="moreThanTwoPositional">only return true if more than two positional parameters are used</param>
624
624
/// <returns></returns>
625
625
public bool PositionalParameterUsed ( CommandAst cmdAst , bool moreThanTwoPositional = false )
626
626
{
@@ -629,13 +629,18 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona
629
629
return false ;
630
630
}
631
631
632
+ < << << << 29f 5017120d e0ccf4c9737ca8a89d50ee66b63a1
633
+ == = == ==
634
+ int parameters = 0 ;
635
+ >>> > >>> Trigger AvoidPositionalParameters rule for function defined and called inside a sript given as argument to Script Analyzer .
632
636
// Because of the way we count, we will also count the cmdlet as an argument so we have to -1
633
637
int argumentsWithoutProcedingParameters = - 1 ;
634
638
bool parameterPreceding = false ;
635
639
636
640
foreach ( CommandElementAst ceAst in cmdAst . CommandElements )
637
641
{
638
642
var cmdParamAst = ceAst as CommandParameterAst ;
643
+ < << << << 29f 5017120d e0ccf4c9737ca8a89d50ee66b63a1
639
644
if ( cmdParamAst ! = null )
640
645
{
641
646
parameterPreceding = true ;
@@ -646,6 +651,11 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona
646
651
argumentsWithoutProcedingParameters += 1 ;
647
652
}
648
653
parameterPreceding = false ;
654
+ = == == ==
655
+ if ( cmdParamAst == null )
656
+ {
657
+ arguments += 1 ;
658
+ > >>> >>> Trigger AvoidPositionalParameters rule for function defined and called inside a sript given as argument to Script Analyzer.
649
659
}
650
660
}
651
661
0 commit comments