PowerShell / PowerShell/PSScriptAnalyzer
Invoke-Formatter loses one level of identation after chain with more than 2 commands and script blocks
Đang mở
Chưa có ai nhận issue này.
Area - Formatter
- 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ả
Steps to reproduce
Input script, formatted already as expected.
Function a {
Function b {
Get-Content blah | ? {
$_ -match foo
} | Set-Content bleh
$AnotherStatement = 1
}
Write-Host "hi"
b
exit 1
}
a
Expected behavior
The example above after formatted looks the same.
Actual behavior
After a chain of more than 2 commands which spans several lines, the formatter loses one level of indentation. Using $(...) triggers the same problem.
Function a {
Function b {
Get-Content blah | ? {
$_ -match foo
} | Set-Content bleh
$AnotherStatement = 1
}
Write-Host "hi"
b
exit 1
}
a
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.15063.1805
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.1805
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.18.3
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
Bắt đầu bằng cách tái hiện hành vi được báo cáo với Invoke-Formatter và script PowerShell trong issue, bao gồm pipeline nhiều lệnh và biến thể $(...). Theo dõi điểm vào của formatter và xác minh rằng việc định dạng giữ nguyên thụt lề ban đầu của các câu lệnh theo sau những chuỗi và khối script này.
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
- 45/100