PowerShell / PowerShell/PSScriptAnalyzer
Global variables are erroneously reported as "never used"
未關閉
還沒有人認領這個 Issue。
Area - PSUseDeclaredVarsMoreThanAssignments
- 主要語言
- C#
- 星號
- 2.2k
- 分支
- 415
- 平均合併
- 13 小時 1 分鐘
- 30 天內合併 PR
- 2
描述
System Details Output
### VSCode version: 1.36.1 2213894ea0415ee8c85c5eea0d0ff81ecc191529 x64
### VSCode extensions:
bierner.lit-html@1.11.0
mikeburgh.xml-format@1.0.2
MS-CEINTL.vscode-language-pack-de@1.36.2
ms-vscode.powershell@2019.5.0
msjsdiag.debugger-for-chrome@4.11.6
slevesque.vscode-hexdump@1.7.2
### PSES version:
### PowerShell version:
Name Value
---- -----
PSVersion 5.1.16299.1146
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.1146
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Issue Description
PowerShell extension reports global variables as assigned but not used when they are not used from within a .psm1 module file. However, global variables may be used by scripts outside that module importing it.
Expected Behaviour
Global variables should never be reported as being unused.
Actual Behaviour
PowerShell extension reports global variables as assigned but not used when they are not used from within a .psm1 module file.

貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
未指定原始檔案、測試或進入點。首先找出用於回報已指派但未使用變數的分析器邏輯,以及涵蓋模組或全域變數範圍的測試。確認目前的行為,然後更新相關的測試預期,使全域變數不會被回報為未使用,並執行受影響的分析器測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- csharp, powershell
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100