PowerShell / PowerShell/PSScriptAnalyzer
Formatting the PowerShell script removes necessary pipe operator `|`
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 414
- Merge trung bình
- 13 giờ 1 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
System Details
System Details Output
### VSCode version: 1.51.1 e5a624b788d92b8d34d1392e4c4d9789406efe8f x64
### VSCode extensions:
janisdd.vscode-edit-csv@0.6.0
ms-python.python@2021.2.633441544
ms-toolsai.jupyter@2021.2.576440691
ms-vscode.cpptools@1.1.3
ms-vscode.hexeditor@1.3.0
ms-vscode.powershell@2020.6.0
redhat.vscode-commons@0.0.6
redhat.vscode-xml@0.16.1
### PSES version: 2.2.0.0
### PowerShell version:
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Description
Create a PowerShell file, input following script, and hit Alt+Shift+F. The pipe operator in $a | ForEach-Object { $_ } is removed.
$a=@('a','b','c')
$b=@{
a=1
b=2
c=3
}
$b | Select-Object -Property ($a | ForEach-Object { $_ })
Related settings in settings.json:
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
Expected Behaviour
The format result should look like:
$a = @('a', 'b', 'c')
$b = @{
a = 1
b = 2
c = 3
}
$b | Select-Object -Property ($a | ForEach-Object { $_ })
Actual Behaviour
The format result is (note that the | is missing):
$a = @('a', 'b', 'c')
$b = @{
a = 1
b = 2
c = 3
}
$b | Select-Object -Property ($a ForEach-Object { $_ })
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Tái hiện vấn đề của formatter bằng script PowerShell và các cài đặt định dạng được nêu trong issue, sau đó lần theo điểm vào định dạng PowerShell xử lý các biểu thức pipe lồng nhau. Công việc được xem là hoàn tất khi | bên trong được giữ lại trong đầu ra đã định dạng và một bài kiểm thử hồi quy bao quát ví dụ này; issue không nêu tệp nguồn hay bài kiểm thử hiện có nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- powershell
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100