@@ -47,8 +47,23 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
4747 if ( Helper . Instance . GetCommandInfo ( cmdAst . GetCommandName ( ) ) != null
4848 && Helper . Instance . PositionalParameterUsed ( cmdAst ) )
4949 {
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+ }
5267 }
5368 }
5469 }
0 commit comments