PowerShell / PowerShell/PSScriptAnalyzer
PSPossibleIncorrectComparisonWithNull not checked inside DSC Configurations
Đang mở
Chưa có ai nhận issue này.
Area - Configuration
Area - DSC
Issue - Bug
Up-for-Grabs
- 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
if (@() -eq $null) { 'true' } else { 'false' }
if (@() -ne $null) { 'true' } else { 'false' }
Configuration Test
{
if (@() -eq $null) { 'true' } else { 'false' }
if (@() -ne $null) { 'true' } else { 'false' }
}
Expected behavior
All 4 comparisons produce Warnings
Actual behavior
# Only the first two comparisons produce Warnings
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSPossibleIncorrectComparisonWithNull Warning test.ps1 1 $null should be on the left side of equality comparisons.
PSPossibleIncorrectComparisonWithNull Warning test.ps1 2 $null should be on the left side of equality comparisons.
If an unexpected error was thrown then please report the full error details using e.g. $error[0] | Select-Object *
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.18362.1171
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.1171
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.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ụ với PSScriptAnalyzer 1.20.0 và so sánh hành vi của rule đối với hai phép so sánh ở cấp cao nhất với hai phép so sánh bên trong DSC Configuration. Được xem là hoàn thành khi PSPossibleIncorrectComparisonWithNull cảnh báo cho cả bốn phép so sánh, bao gồm cả những phép so sánh bên trong configuration.
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
- 35/100