PowerShell / PowerShell/PSScriptAnalyzer
Rule request: AvoidUsingOutNull
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
I want PSScriptAnalyzer to flag uses of Out-Null for output suppression so that I can maintain consistent code style and potentially gain minor performance improvements.
Currently, many PowerShell scripts use | Out-Null to suppress command output, but there are alternative approaches like [void], > $null, or assignment to $null that are stylistically preferred by many developers. While the performance difference is minimal, having a consistent approach to output suppression improves code readability and maintainability.
Proposed technical implementation details (optional)
- Rule Name:
AvoidUsingOutNull - Severity:
Information(since this is primarily a style preference) - Category:
Style - Detection: Flag any pipeline that ends with
| Out-Null - Suggested alternatives:
[void](command)command > $null$null = command
- Example violation:
Get-Process | Out-Null - Example fix:
[void](Get-Process)orGet-Process > $null
The rule should provide informational messages suggesting these alternatives while acknowledging that this is primarily a stylistic choice rather than a critical performance issue.
What is the latest version of PSScriptAnalyzer at the point of writing
1.24.0
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ìm các quy tắc PSScriptAnalyzer tương tự và các bài kiểm thử của chúng, sau đó kiểm tra cách tên quy tắc, mức độ nghiêm trọng, danh mục, chẩn đoán và các mẫu pipeline được biểu diễn. Hoàn tất khi các pipeline kết thúc bằng Out-Null tạo ra một chẩn đoán Style mang tính thông tin với các lựa chọn thay thế được đề xuất, trong khi các dạng suppress output khác không bị ảnh hưởng.
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
- Tính năng
- Độ 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