PowerShell / PowerShell/PSScriptAnalyzer
UseProcessBlockForPipelineCommand returns a warning when pipeline behavior is explicitly disabled
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ả
I've noticed that UseProcessBlockForPipelineCommand rule produces warning notifications when pipeline behavior (ValueFromPipeline, ValueFromPipelineByPropertyName) is explicitly disabled.
Steps to reproduce
Function Get-Number
{
[CmdletBinding()]
[OutputType([int])]
Param(
[Parameter(ValueFromPipeline=$false)]
[int]
$Number
)
$Number
}
Expected behavior
The rule should not report any findings
Actual behavior
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseProcessBlockForPipelineCommand Warning Test-PSSA. 8 Command accepts pipeline input but has not defined a
ps1 process block.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.1.3
PSEdition Core
GitCommitId 7.1.3
OS Microsoft Windows 10.0.19042
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.20.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
Bắt đầu bằng cách tái hiện ví dụ PowerShell và theo dõi điểm vào của quy tắc UseProcessBlockForPipelineCommand, tập trung vào các giá trị ValueFromPipeline và ValueFromPipelineByPropertyName được đặt rõ ràng thành false. Xác định các kiểm thử hiện có của quy tắc, bổ sung độ bao phủ cho trường hợp này và xác nhận rằng ví dụ không tạo ra phát hiện 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ệ
- csharp, powershell
- Lĩnh vực
- devtools
- 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
- 42/100