PowerShell / PowerShell/PSScriptAnalyzer
Rule request: Avoid using the Assignment by Addition Operator (`+=`) to build a string
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
Summary of the new feature
Strings are immutable. Each addition to the string actually creates a new string big enough to hold the contents of both the left and right operands, then copies the elements of both operands into the new string. For small strings, this overhead may not matter. For large strings, this can affect performance and memory consumption.
This will create more awareness of the possible performance impact of using the Assignment by Addition Operator (+= ), see also:
- Avoid the increase assignment operator (
+=) for building strings - PowerShell scripting performance considerations / String addition
Proposed technical implementation details (optional)
See (PowerShell based) prototype AvoidPlusEqualsToBuildStrings at: https://github.com/iRon7/PSRules
What is the latest version of PSScriptAnalyzer at the point of writing
1.21.0
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 revisando o protótipo vinculado AvoidPlusEqualsToBuildStrings e as referências da issue sobre adição de strings do PowerShell. Em seguida, examine os padrões e testes de regras existentes do PSScriptAnalyzer. A tarefa estará concluída quando uma regra identificar o uso de += para construir strings e reportá-lo de forma consistente com as convenções do analisador do projeto.
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
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100