PowerShell / PowerShell/PSScriptAnalyzer
Formatting Issue, example included
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Issue Type: Bug
This is an example of the formatting issue I have been struggling with. It appears that that using a multi-line piping statement, along with the 'Out-Null' is the cause in this situation. Formatting the document adds an additional tab each time this code happens. I have much more involved code then this example that becomes really confusing when this indent issue occurs.
function Test-Format([int]$num) {
if($num -eq 1){
Get-ChildItem -Path 'c:\*.*' | Where-Object {$_.name -like 'test1.*'} |
ForEach-Object{Remove-Item -Path $_ | Out-Null}
}
else{
Get-ChildItem -Path 'c:\*.*' | Where-Object {$_.name -like 'test2.*'} |
ForEach-Object{Remove-Item -Path $_ | Out-Null}
}
}
Test-format -num 1
Extension version: 2021.2.2
VS Code version: Code 1.54.1 (f30a9b73e8ffc278e71575118b6bf568f04587c8, 2021-03-04T22:38:31.419Z)
OS version: Windows_NT x64 10.0.19042
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Xeon(R) CPU E5-1620 v2 @ 3.70GHz (8 x 3700) |
| GPU Status | 2d_canvas: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on oop_rasterization: enabled opengl: enabled_on protected_video_decode: unavailable_off rasterization: enabled skia_renderer: enabled_on video_decode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.92GB (22.25GB free) |
| Process Argv | --crash-reporter-id 73837bc4-9684-4f62-8d48-bb5a4bc03bd8 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstry244cf:30256637
pythonvsdeb440:30248342
pythonvsded773:30248341
pythonvspyt875:30259475
dockersubset:30265998
pythontbcf:30265426
vspre833:30267464
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用本报告中的多行 PowerShell pipeline 和 Out-Null 示例重现该问题,并尽可能使用所述版本的 PSScriptAnalyzer 扩展和 VS Code。跟踪处理 pipeline 缩进的 formatter 入口点;当重复格式化不再添加额外的制表符,并且所示的 if/else 结构仍保持正确对齐时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100