PowerShell / PowerShell/PSScriptAnalyzer

AvoidAssignmentToAutomaticVariable doesn't distinguish between normal and DSC scripts

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

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ả

The AvoidAssignmentToAutomaticVariable rule doesn't distinguish between a normal script and a DSC script, meaning DSC specific auto-variables like $allNodes will cause complaints when the rule runs. I don't know if this is even something that could have logic applied to it in an effort to suppress, given there isn't necessarily an easy way to discern context of DSC vs Non-DSC scripts

Steps to reproduce

Create a standard powershell script ps1 file and enter the following. If in VS Code PSScriptAnalyzer automatically runs against it.

$allNodes = "Put anything here"

Expected behavior

Rule does not complain about usage of $allNodes as script is not used in DSC.

Actual behavior

The Variable 'allNodes' is an automatic variable that is built into PowerShell, assigning to it might have undesired side effects. If assignment is not by design, please use a different name.

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

Bắt đầu từ quy tắc AvoidAssignmentToAutomaticVariable và tái hiện vấn đề bằng một PowerShell .ps1 tiêu chuẩn có phép gán cho $allNodes. Xác định liệu quy tắc có thể phân biệt các tập lệnh DSC với các tập lệnh thông thường hay không, sau đó xác minh rằng trường hợp tập lệnh thông thường không còn báo cáo biến này mà không thay đổi hành vi DSC dự kiến.

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
tooling
Loại issue
Lỗi
Độ 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
35/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.