-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
If the rule is testing a function hat has a parameter with a type that is not loaded into the session the rule fails on all parameters in all examples.
For example if having this parameter:
param
(
[Parameter()]
[Microsoft.SqlServer.Management.Smo.Server]
$SqlServerObject
)This row will return the function but the property Parameters will be $null
Line 25 in e1466ed
| $functionInfo = Get-FunctionInfo -ScriptBlock $definition |
which result in that this evaluation always return $true
Line 54 in e1466ed
| $_ -is [CommandParameterAst] -and $_.ParameterName -notin $functionInfo.Parameters.Keys |
Suggest adding a error message when $null -eq $functionInfo.Parameters saying something like "Parameters of the function X could not be parsed, this can for example be due to that a type that is used by a parameter is not loaded into the session.".
I worked around this by loading stubs classes before running Invoke-ScriptAnalyzer.
Metadata
Metadata
Assignees
Labels
No labels