Suppression with `SuppressMessageAttribute` is completely broken for variables
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện PowerShell với PSScriptAnalyzer 1.23.0 và theo dõi cách SuppressMessageAttribute được xử lý đối với các biến. So sánh việc khớp tên quy tắc đối với NonexistentRule và PSAvoidGlobalVars; được xem là hoàn tất khi quy tắc không tồn tại không suppress PSUseDeclaredVarsMoreThanAssignments, trong khi quy tắc hợp lệ suppress PSAvoidGlobalVars.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Steps to reproduce
Consider this code:
$foo = "never used" # Should generate PSUseDeclaredVarsMoreThanAssignments
$global:var1 = $null # Should generate PSAvoidGlobalVars
Now let's try to add these suppressions:
[Diagnostics.CodeAnalysis.SuppressMessage('NonexistentRule', '')]
$foo = "never used" # Should still generate PSUseDeclaredVarsMoreThanAssignments
[Diagnostics.CodeAnalysis.SuppressMessage('PSAvoidGlobalVars', '')]
$global:var1 = $null # Should NOT generate PSAvoidGlobalVars
Expected behavior
I should still see the PSUseDeclaredVarsMoreThanAssignments warning, but not the PSAvoidGlobalVars one.
Actual behavior
The opposite happens, the first message is suppressed, but the second is not:
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidGlobalVars Warning Test.ps1 5 Found global variable 'global:var1'.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.5
PSEdition Core
GitCommitId 7.4.5
OS Microsoft Windows 10.0.22631
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.23.0
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 422
- Merge trung bình
- 2 giờ 23 phút
- Pull request đã merge (30 ngày)
- 25
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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.
Issue khác của PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 18/100
PowerShell/PSScriptAnalyzer#2302 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
PowerShell/PSScriptAnalyzer#2300 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember)Có thể đã có người làm @jessehouwing đã nhận 89 ngày trước. Đang mởIssue - Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
PowerShell/PSScriptAnalyzer#2229 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
PowerShell/PSScriptAnalyzer#2222 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PowerShell/PSScriptAnalyzer
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
GamaEdtech/gamatrain-back#977 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-templates triage:bot-seen triage:needs-human
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/aspire#22356 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
PowerShell/PowerShell#28432 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/aspire.dev#2184 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area-controls-refreshview platform/ios s/triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
dotnet/maui#40314 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày