PowerShell / PowerShell/PSScriptAnalyzer

PSUseConsistentWhitespace - Ability to ignore if in a line with multiple pipes

Đang mở
#2,162 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

Summary of the new feature

The various PSUseConsistentWhitespace rules have various issues that might never be solved:

My biggest issue is that I don't want it to touch one liners or multiliners like this:

(
    (
        Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
    ) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = {[System.Version]$_}} -Descending | Select-Object -First 1

Which becomes this:

(
    (
        Invoke-RestMethod -Method 'Get' -Uri 'https://api.github.com/repos/chocolatey/choco/releases'
    ) | Where-Object -Property 'prerelease' -NE $true
).'tag_name' | Sort-Object -Property @{'Expression' = { [System.Version]$_ } } -Descending | Select-Object -First 1

If I could tell PSScriptAnalyzer to ignore cases like that I'd be happy.

Current impact

This makes it so that I don't use the code formatting presets, and instead define all the rules manually and disable most of the PSUseConsistentWhitespace rules.

Side note: Would be great with the ability to override built-in presets, so you don't have to specify all the rules.

Proposed technical implementation details (optional)

Don't know. Some ideas:

  • Ability to ignore if more than one pipe `| is found on the same line?

What is the latest version of PSScriptAnalyzer at the point of writing

v1.24.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Xem xét các quy tắc PSUseConsistentWhitespace hiện tại và các issue đang mở được liên kết để hiểu whitespace được áp dụng như thế nào trên các pipeline. Xác định hành vi chính xác đối với các dòng chứa nhiều pipe, sau đó xác minh rằng hành vi bỏ qua được đề xuất vẫn giữ nguyên các kiểm tra định dạng hiện có mà không ảnh hưởng đến các trường hợp khác.

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
devtools, tooling
Loại issue
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
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
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.