PowerShell / PowerShell/PSScriptAnalyzer
PSScriptAnalyzer doesn't seem to be using the SuppressMessageAttribute ctor fields as intended.
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 2.2k
- Forks
- 414
- Merge médio
- 13h 1min
- PRs com merge (30d)
- 2
Descrição
So here is an example of how PSScriptAnalyzer is using this attribute to target a parameter:
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "b")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideDefaultParameterValue", "a")]
Param([string]$a, [int]$b)
But the intent of the first two parameters of the SuppressMessageAttribute constructor are to uniquely identify the suppressed rule, and to apply to a parameter would use the MessageId property e.g.:
[SuppressMessage("Microsoft.Performance", "CA1801:ReviewUnusedParameters", MessageId = "isChecked")]
[SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "fileIdentifier")]
static void FileNode(string name, bool isChecked)
So I would expect that every PowerShell suppression of a built-in rule would start like this:
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.PowerShell", "PSAvoidUsingCmdletAliases")]
This identifies the rule as a built-in rule. I could imagine custom rules would use their module/assembly name in the first field (category).
Suppression of a parameter should look like:
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.PowerShell", "PSProvideDefaultParameterValue", MessageId="b")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.PowerShell", "PSProvideDefaultParameterValue", MessageId="a")]
Param([string]$a, [int]$b)
Note that MessageId is the field that is supposed to be used if Scope/Target aren't sufficiently precise.
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 localizando o código do PSScriptAnalyzer que interpreta SuppressMessageAttribute e rastreando como seus argumentos do construtor e MessageId são tratados. Compare as supressões direcionadas a parâmetros com a semântica do atributo mostrada na issue; considera-se concluído quando as supressões de regras integradas usam os campos de categoria e regra, enquanto os destinos específicos de parâmetros usam MessageId.
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
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100