Update-PSModuleManifest -FunctionsToExport breaks PSAvoidTrailingWhitespace scriptanalyzer rule

Aperta
#1,813 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
powershell
Ambito
tooling

Direzione di ricerca

Inizia dal punto di ingresso Update-PSModuleManifest e riproduci il problema usando i comandi nel report, quindi esegui Invoke-ScriptAnalyzer sul foo.psd1 generato. Il lavoro è completato quando l’output di FunctionsToExport non contiene spazi bianchi finali e l’analizzatore non produce alcuna segnalazione PSAvoidTrailingWhitespace.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Area-InfoFile
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:
Image

Actual module file in VS Code - with the trailing whitespace highlighted:
Image

Lingua principale
C#
Stelle
581
Fork
116
Merge medio
1g 21h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PowerShell/PSResourceGet

Tutte le issue di PowerShell/PSResourceGet

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.