PowerShell / PowerShell/PSScriptAnalyzer

`SuppressMessageAttribute` not working for ScriptBlock params

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

Chưa có ai nhận issue này.

Area - Rule Sets Issue - Enhancement
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ả

Before submitting a bug report:

  • Make sure you are able to repro it on the latest released version
  • Perform a quick search for existing issues to check if this bug has already been reported

Steps to reproduce

Register-ArgumentCompleter -Native -CommandName dotnet -ScriptBlock {
	[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'wordToComplete', Justification = 'Reason for suppressing')]
	param(
		$wordToComplete,
		$commandAst,
		$cursorPosition)

	dotnet complete --position $cursorPosition "$commandAst" | ForEach-Object {
		[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
	}
}

Expected behavior

Rule `PSReviewUnusedParameter` doesn't trigger for parameter `$wordToComplete`.

Actual behavior

Rule `PSReviewUnusedParameter` triggers for parameter `$wordToComplete`.

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                      7.3.0
PSEdition                      Core
GitCommitId                    7.3.0
OS                             Microsoft Windows 10.0.22000
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() }
Using built-in version of VSCode Powershell extension (v2022.10.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

Tái hiện ví dụ PowerShell với rule PSReviewUnusedParameter và xác nhận rằng suppression attribute bị bỏ qua đối với $wordToComplete. Truy tìm entry point của analyzer cho các tham số ScriptBlock và kiểm tra các test hiện có của nó, nếu có. Được xem là hoàn tất khi rule không còn báo cáo tham số đó nữa, đồng thời vẫn giữ nguyên hành vi hiện tại đối với các tham số không bị suppress.

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
45/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.