PowerShell / PowerShell/PSResourceGet
Update-PSModuleManifest -FunctionsToExport breaks PSAvoidTrailingWhitespace scriptanalyzer rule
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 576
- Forks
- 114
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 7
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
I use a build script to generate powershell modules. The tasks of the build script include updating the module manifest to list the FunctionsToExport - and a call to Invoke-ScriptAnalyzer to ensure that the code follows best practice.
The problem is that Update-PSModuleManifest -FunctionsToExport splits the array across multiple lines in the psd1 file in a way that violates the PSAvoidTrailingWhitespace rule from Invoke-Scriptanalyzer.
I discovered the behaviour in Update-ModuleManifest from PowerShellGet but I have verified that the newer Update-PSModuleManifest has the exact same behaviour
Steps to reproduce:
New-ModuleManifest -Path foo.psd1
Update-ModuleManifest -Path foo.psd1 -FunctionsToExport "Get-Something", "Convert-SomethingElse", "Add-MyFunction", "Remove-TheLineBreak"
Invoke-ScriptAnalyzer .\foo.psd1
Expected behavior
(no output)
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidTrailingWhitespace Information foo.psd1 72 Line has trailing whitespace
Error details
Environment data
>Get-Module Microsoft.PowerShell.PSResourceGet; $PSVersionTable | Format-Table
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 1.1.1 Microsoft.PowerShell.PSResourceGet {Compress-PSResource, Find-PSResource, Get-InstalledPSResource, Get-PSResourceReposit…
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
Test scenario:
Actual module file in VS Code - with the trailing whitespace highlighted:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Update-PSModuleManifest entry point and reproduce the issue using the commands in the report, then run Invoke-ScriptAnalyzer on the generated foo.psd1. Done means the FunctionsToExport output contains no trailing whitespace and the analyzer produces no PSAvoidTrailingWhitespace finding.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100