PowerShell / PowerShell/PSScriptAnalyzer
AvoidAssignmentToAutomaticVariable doesn't distinguish between normal and DSC scripts
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
The AvoidAssignmentToAutomaticVariable rule doesn't distinguish between a normal script and a DSC script, meaning DSC specific auto-variables like $allNodes will cause complaints when the rule runs. I don't know if this is even something that could have logic applied to it in an effort to suppress, given there isn't necessarily an easy way to discern context of DSC vs Non-DSC scripts
Steps to reproduce
Create a standard powershell script ps1 file and enter the following. If in VS Code PSScriptAnalyzer automatically runs against it.
$allNodes = "Put anything here"
Expected behavior
Rule does not complain about usage of $allNodes as script is not used in DSC.
Actual behavior
The Variable 'allNodes' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.
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 pela regra AvoidAssignmentToAutomaticVariable e reproduza o problema com um PowerShell .ps1 padrão contendo uma atribuição a $allNodes. Determine se a regra consegue distinguir scripts DSC de scripts normais e, em seguida, verifique se o caso do script normal não relata mais essa variável sem alterar o comportamento pretendido de DSC.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- 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