PowerShell / PowerShell/PSScriptAnalyzer
Accept `-Fix` for `-ScriptDefinition`
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
Currently the -Fix parameter is mutual exclusive with the -ScriptDefinition parameter:
Invoke-ScriptAnalyzer -ScriptDefinition 'GCI *' -Fix
Invoke-ScriptAnalyzer: Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot; be used together or an insufficient number of parameters were provided.
Proposed technical implementation details (optional)
When both ( -Fixand -ScriptDefinition) parameters, are supplied, I would expect to get a fixed ScriptDefinition back (instead of a [Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic.DiagnosticRecord]).
This way, it would be easier to (pester) test a rule with SuggestedCorrections.
(You might of cause check the SuggestedCorrections property but that will not confirm it has been correctly inserted in the script.)
Besides it will allow to fix scripts by creating a fixed copy rather than make sure that you have a backup of your files when using this parameter.
Wishful thinking:
Get-Content *.ps1 | Foreach-Object { Invoke-ScriptAnalyzer -ScriptDefinition $_ | Set-Content "Fixed\$($_.Name)" }
What is the latest version of PSScriptAnalyzer at the point of writing
1.21.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 việc xem xét entry point của Invoke-ScriptAnalyzer và cách hiện tại nó xử lý -ScriptDefinition và -Fix. Xác minh cách lệnh hiện trả về các chẩn đoán, sau đó xác định phạm vi kiểm thử cho việc chấp nhận cả hai tham số, trả về định nghĩa script đã được sửa và xác nhận rằng SuggestedCorrections được áp dụ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ệ
- powershell
- Lĩnh vực
- cli, tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 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