PowerShell / PowerShell/PSScriptAnalyzer
Use proper output streams for messages output by PSScriptAnalyzer
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
This issue is a great example of why issue #193 should be approved and implemented.
Today if you run Invoke-ScriptAnalyzer on a moderate sized module recursively with the -Verbose switch, you get 38 verbose output messages per file in your module. For one of my modules that has 58 files (I put each function in its own file if the module is only small-to-medium in size), this results in 2204 verbose messages being sent to the console. These 2204 verbose messages are nothing but noise to me.
For each of the files that are processed, I get one verbose message that indicates a file is being analyzed and then I get 37 messages (one for each rule, so that will only grow over time) indicating that a rule is being processed for that file. Those should be progress messages, not verbose messages, and so they should be output using WriteProgress, not WriteVerbose. Verbose should be reserved for non-progress messages that provide some additional detail about what is happening behind the scenes -- some small amount of information that would be useful for the invoker to know if they want the additional detail, but that they don't see regularly. This is exactly why the PSProvideVerboseMessage rule needs to go away -- it encourages users to wrongly add verbose message output where there shouldn't be any.
The reason why I invoked Invoke-ScriptAnalyzer with -Verbose in the first place is because I wanted to see if it was writing a verbose message to the output stream when a rule is found but suppressed. It is not doing this, but that is a great example of the kind of output I would expect to be in a verbose stream for this command. This verbose output would not be noise, because it includes additional detail that is not visible by default (and rightly so) that would add value to a caller trying to figure out why a particular rule is not showing up in certain scenarios. This verbose output would also be highly useful to the community because it would allow them to catch scripts and/or modules that were a little too "suppress-happy", in which case they could inform the author about the error in their ways.
In summary, Invoke-ScriptAnalyzer should:
a) convert the current WriteVerbose calls that output what are really progress messages to the verbose stream to WriteProgress calls (this will also help wrt performance, so that end users see the progress as it is happening)
b) add WriteVerbose calls that output verbose messages indicating when a rule is suppressed, identifying the rule that is suppressed, the line/file where it would have been raised, and ideally the line/file where the attribute to suppress that rule was defined (the source of the suppression).
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 em Invoke-ScriptAnalyzer e localize as chamadas atuais a WriteVerbose para o processamento de arquivos e regras. Revise como os streams de progresso e verbose são tratados e, em seguida, verifique a saída de progresso solicitada e os detalhes de supressão em relação aos critérios indicados no issue. A descrição não nomeia arquivos nem testes; portanto, identificar os locais relevantes da implementação e dos testes faz parte do trabalho.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- csharp, powershell
- Domínio
- cli, tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100