Rule request: Avoid using the Assignment by Addition Operator (`+=`) to build a string
還沒有人認領這個 Issue。
評估
研究方向
首先檢視連結的 AvoidPlusEqualsToBuildStrings 原型,以及 issue 中關於 PowerShell 字串加法的參考資料。接著檢查 PSScriptAnalyzer 既有的規則模式與測試。當某條規則能夠識別使用 += 建構字串的情況,並依照專案的分析器慣例一致地回報該情況時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PowerShell/PSScriptAnalyzer 的其他 Issue
-
Up-for-Grabs
難度 1/5 1-3 小時 新手友好度 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 則留言 ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`)未關閉
難度 3/5 1-2 天 新手友好度 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 則留言 ·
-
難度 3/5 1-2 天 新手友好度 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks未關閉
難度 3/5 1-2 天 新手友好度 70/100
PowerShell/PSScriptAnalyzer#2210 ·
查看 PowerShell/PSScriptAnalyzer 的全部 Issue
相似的 Issue
-
ci-failure-cause test-failure
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
-
area:frontend bug FE hotspot:css mvp P3
難度 1/5 1 小時以內 新手友好度 90/100
klasolsson81/jobbliggaren#1856 ·
維護者通常 1 天內回覆
-
Area: App+Library Build
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
Aaronontheweb/freshdesk-cli#148 ·