PowerShell / PowerShell/PSScriptAnalyzer
PSUseCmdletCorrectly breaks on Write-Verbose -Verbose
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 2.2k
- Forks
- 414
- Merge medio
- 13 h 1 min
- PR fusionados (30 d)
- 2
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo el problema con Invoke-ScriptAnalyzer y la regla PSUseCmdletCorrectly usando el fragmento de PowerShell del informe. Sigue cómo se comprueban Write-Verbose y Write-Warning y, después, verifica que la reproducción no produzca ninguna infracción, mientras los casos existentes de Write-Error sigan cubiertos.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, powershell
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100