@@ -47,8 +47,23 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
47
47
if ( Helper . Instance . GetCommandInfo ( cmdAst . GetCommandName ( ) ) != null
48
48
&& Helper . Instance . PositionalParameterUsed ( cmdAst ) )
49
49
{
50
- yield return new DiagnosticRecord ( string . Format ( CultureInfo . CurrentCulture , Strings . AvoidUsingPositionalParametersError , cmdAst . GetCommandName ( ) ) ,
51
- cmdAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName , cmdAst . GetCommandName ( ) ) ;
50
+ PipelineAst parent = cmdAst . Parent as PipelineAst ;
51
+
52
+ if ( parent != null && parent . PipelineElements . Count > 1 )
53
+ {
54
+ // raise if it's the first element in pipeline. otherwise no.
55
+ if ( parent . PipelineElements [ 0 ] == cmdAst )
56
+ {
57
+ yield return new DiagnosticRecord ( string . Format ( CultureInfo . CurrentCulture , Strings . AvoidUsingPositionalParametersError , cmdAst . GetCommandName ( ) ) ,
58
+ cmdAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName , cmdAst . GetCommandName ( ) ) ;
59
+ }
60
+ }
61
+ // not in pipeline so just raise it normally
62
+ else
63
+ {
64
+ yield return new DiagnosticRecord ( string . Format ( CultureInfo . CurrentCulture , Strings . AvoidUsingPositionalParametersError , cmdAst . GetCommandName ( ) ) ,
65
+ cmdAst . Extent , GetName ( ) , DiagnosticSeverity . Warning , fileName , cmdAst . GetCommandName ( ) ) ;
66
+ }
52
67
}
53
68
}
54
69
}
0 commit comments