PowerShell / PowerShell/PSScriptAnalyzer
PSPlaceCloseBrace can't handle empty lines
Đang mở
Chưa có ai nhận issue này.
Area - Formatter
Issue - Bug
- 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ả
Basically, it gets fixed if I have:
}
else {
But it doesn't get fixed if I have:
}
else {
And I would really like it to be able to handle:
}
# An explanation of the next code block
else {
And format it like:
} else {
# An explanation of the next code block
Steps to reproduce
Invoke-Formatter {
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
}
elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
} -Settings @{
Rules = @{
PSPlaceCloseBrace = @{
Enable = $true
NoEmptylineBefore = $true
NewLineAfter = $false
}
}
}
Expected behavior
It should output
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
} elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
Actual behavior
if (Test-Path ReadMe.md) {
Show-Markdown ReadMe.md
}
elseif (Test-Path ReadMe*) {
Get-Item ReadMe* | Select-Object -First 1 | Get-Content
}
Environment data
> $PSVersionTable
$PSVersionTable
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.19.1
1.18.1
1.18.0
1.17.1
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 hành vi bằng Invoke-Formatter và các thiết lập PSPlaceCloseBrace được hiển thị trong issue, so sánh các trường hợp dòng trống và chú thích. Theo dõi đường dẫn formatter của PSScriptAnalyzer cho quy tắc này; được xem là hoàn tất khi một dòng trống hoặc chú thích xen giữa không còn ngăn dấu ngoặc nhọn đóng và else được nối lại như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, 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
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100