PowerShell / PowerShell/PSScriptAnalyzer
PSUseCmdletCorrectly breaks on Write-Verbose -Verbose
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 2.2k
- Forks
- 415
- Merge médio
- 13h 1min
- PRs com merge (30d)
- 2
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece reproduzindo o problema com Invoke-ScriptAnalyzer e a regra PSUseCmdletCorrectly usando o snippet de PowerShell do relatório. Rastreie como Write-Verbose e Write-Warning são verificados e, em seguida, confirme que a reprodução não produz violações, enquanto os casos existentes de Write-Error continuam cobertos.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, powershell
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100