PowerShell / PowerShell/PSScriptAnalyzer
Rule request: Avoid using the Assignment by Addition Operator (`+=`) to build a string
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia esaminando il prototipo collegato AvoidPlusEqualsToBuildStrings e i riferimenti dell'issue sull'addizione di stringhe PowerShell. Poi analizza i pattern e i test delle regole esistenti di PSScriptAnalyzer. Il lavoro è completo quando una regola identifica l'uso di += per costruire stringhe e lo segnala in modo coerente con le convenzioni dell'analizzatore del progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- csharp, powershell
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100