Skip to content

Cannot pipe multiple files to Invoke-ScriptAnalyzer #1039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edyoung opened this issue Jul 16, 2018 · 1 comment
Closed

Cannot pipe multiple files to Invoke-ScriptAnalyzer #1039

edyoung opened this issue Jul 16, 2018 · 1 comment

Comments

@edyoung
Copy link
Contributor

edyoung commented Jul 16, 2018

Path is annotated with [ValueFromPipeline] so it should be possible to pipe records to it. But code in BeginProcessing tries to use the value of the path variable, which won't be set at that point if the paths to process are being pipelined.

Steps to reproduce

get-childitem *.ps1 | Invoke-ScriptAnalyzer

Expected behavior

Processes each of the files specified and produces analysis results for each one

Actual behavior

Error: Invoke-ScriptAnalyzer : Cannot process argument because the value of argument "path" is null. Change the
value of argument "path" to a non-null value.

PSMessageDetails      :
Exception             : System.Management.Automation.PSArgumentNullException: Cannot process argument because
                        the value of argument "path" is null. Change the value of argument "path" to a
                        non-null value.
                           at
                        System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String
                        path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider&
                        providerInstance)
                           at
                        System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String
                        path, Boolean allowNonexistingPaths, CmdletProvider& providerInstance)
                           at Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
                        .ProcessPath()
                           at Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
                        .BeginProcessing()
                           at System.Management.Automation.Cmdlet.DoBeginProcessing()
                           at System.Management.Automation.CommandProcessorBase.DoBegin()
TargetObject          :
CategoryInfo          : InvalidArgument: (:) [Invoke-ScriptAnalyzer], PSArgumentNullException
FullyQualifiedErrorId : ArgumentNull,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzer
                        Command
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.16299.547
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.16299.547
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.17.1
1.16.1
@edyoung
Copy link
Contributor Author

edyoung commented Jul 16, 2018

See also #561 - this blocks Joey's suggested workaround

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants