PowerShell / PowerShell/PSScriptAnalyzer
Remove-Module PSScriptAnalyzer leaves behavior of removed module version
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Removing a version of PSScriptAnalyzer does not remove its behavior from the session. I don't know much about this, but it looks like we're missing code to clean up after a remove.
Version 1.10.0 and 1.11.0 are somewhat different. For example, in 1.11.0, the Settings parameter tab-completes the .psd1 file names in the Settings subdirectory. Also, the PSPlaceOpenBrace and PSPlaceCloseBrace rules do not trigger on a one-line function, such as:
function Test-Brace1 () {"Hello, World"}
However, if you import one version (Import-Module), remove that version (Remove-Module), and then import the other version, the result is the same as if you imported only the first version.
This is important, because the results of the different module versions are perceptibly different.
REPRO:
0. Start a new session, e.g. new console.
1. ipmo PSScriptAnalyzer -RequiredVersion 1.10.0 -Passthru
2. gmo | rmo
3. ipmo PSScriptAnalyzer -RequiredVersion 1.11.0 -Passthru
Now, test one of the differing features.
4. Invoke-ScriptAnalyzer -Settings <TAB> #Fails to tab complete, as in 1.10.0.
5. Invoke-ScriptAnalyzer -ScriptDefinition 'function Test-Brace1 () {"Hello, World"}' -Settings $home\Documents\WindowsPowerShell\Modules\PSScriptAnalyzer\1.11.0\Settings\CodeFormatting.psd1
This returns output that you shouldn't see any more in 1.11.0.
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSPlaceOpenBrace Warning 1 There is no new line after open brace.
PSPlaceCloseBrace Warning 1 Close brace is not on a new line.
The same is true if you reverse the order of the versions.
0. Start a new session, e.g. new console.
1. ipmo PSScriptAnalyzer -RequiredVersion 1.11.0 -Passthru
2. gmo | rmo
3. ipmo PSScriptAnalyzer -RequiredVersion 1.10.0 -Passthru
Now, we have 1.10.0 with 1.11.0 behavior:
4. Invoke-ScriptAnalyzer -Settings <TAB> #Tab completes!
5. Invoke-ScriptAnalyzer -ScriptDefinition 'function Test-Brace1 () {"Hello, World"}' -Settings CodeFormatting
Version 1.10.0 should error on the one-liner, but it doesn't.
PS C:\> Invoke-ScriptAnalyzer -Settings CodeFormatting -ScriptDefinition 'function Test-Brace1 () {"Hello, World"}'
PS C:\>
Strange, I know. If you need more info, let me know. Thanks!
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
先从复现中的 Import-Module 和 Remove-Module 序列开始,然后检查在 PSScriptAnalyzer 1.10.0 和 1.11.0 之间切换后 Invoke-ScriptAnalyzer 的行为。比较设置的 Tab 补全以及 PSPlaceOpenBrace 和 PSPlaceCloseBrace 的结果;当移除一个版本后,该版本的行为不再留在会话中时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- csharp, powershell
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100