Skip to content

The ForStatementAst visitor do not work correctly ? #609

Closed
@LaurentDardenne

Description

@LaurentDardenne

With this function :

Function Measure-OptimizeForSatement{

 [CmdletBinding()]
 [OutputType([Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord[]])]

 Param(
       [Parameter(Mandatory = $true)]
       [ValidateNotNullOrEmpty()]
       [System.Management.Automation.Language.ForStatementAst]
      $ForStatementAst
 )

Invoke-ScriptAnalyzer return only the first occurence of ForStatementAst :

if($commentLines.Count -gt 2)
{
    for($i = 1; $i -lt ($commentLines.count - 1); $i++)
    {
        $line = $commentLines[$i]
    }
}

function TestScriptFileInfo
{
  if($commentLines.Count -gt 2)
  {
      for($i = 1; $i -lt ($commentLines.count - 1); $i++)
      {
          $line = $commentLines[$i]
      }
  }
}

The occurence of ForStatementAst inside the function 'TestScriptFileInfo' is not 'visited'.
See the demo file.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions