PowerShell / PowerShell/PSScriptAnalyzer
PSUseCmdletCorrectly breaks on Write-Verbose -Verbose
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 2.2k
- Forks
- 414
- Ø Merge
- 13 Std. 1 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
I'm getting a rule violation when we force Write-Verbose to have output like this:
Write-Verbose -Verbose "My Message"
Steps to reproduce
Invoke-ScriptAnalyzer -ScriptDefinition '
Write-Verbose -Verbose "Getting file list from $pwd"
Write-Warning -Verbose "Getting file list from $pwd"
Write-Error -Verbose "Getting file list from $pwd"
Write-Error -ErrorAction SilentlyContinue "Getting file list from $pwd"
' -IncludeRule PSUseCmdletCorrectly
Expected behavior
There are no violations.
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseCmdletCorrectly Warning 2 Cmdlet 'Write-Verbose' may be used incorrectly. Please
check that all mandatory parameters are supplied.
PSUseCmdletCorrectly Warning 3 Cmdlet 'Write-Warning' may be used incorrectly. Please
check that all mandatory parameters are supplied.
I think it's significant that it has no problem with either of the Write-Error lines, but I have not looked at the code to understand what is happening ...
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.1171
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.1171
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.19.1
1.19.1
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Problem mit Invoke-ScriptAnalyzer und der Regel PSUseCmdletCorrectly anhand des PowerShell-Snippets im Bericht zu reproduzieren. Verfolge, wie Write-Verbose und Write-Warning geprüft werden, und stelle anschließend sicher, dass die Reproduktion keine Verstöße erzeugt, während die vorhandenen Write-Error-Fälle weiterhin abgedeckt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100