PowerShell / PowerShell/PSScriptAnalyzer
Rule request: Avoid using the Assignment by Addition Operator (`+=`) to build a string
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 2.2k
- Forks
- 414
- Merge moyen
- 13 h 1 min
- PR mergées (30 j)
- 2
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par examiner le prototype lié AvoidPlusEqualsToBuildStrings et les références de l’issue concernant l’addition de chaînes PowerShell. Examinez ensuite les modèles de règles et les tests existants de PSScriptAnalyzer. Le travail est terminé lorsqu’une règle identifie l’utilisation de += pour construire des chaînes et la signale conformément aux conventions de l’analyseur du projet.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, powershell
- Domaine
- tooling
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 38/100