PowerShell / PowerShell/PSScriptAnalyzer

Incorrectly formats an array passed to a parameter when backtick is used to separate parameters

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

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

Area - Formatter Issue - Bug
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ả

Not sure what rule is responsible for this error, so this might have been reported before. 🤔 If so please close.

Steps to reproduce

$scriptDefinition = @'
$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
    -DesiredValues $desiredValues `
    -ValuesToCheck @(
        'LoginName'
        'AsymmetricKeyName'
        'CertificateName'
        'UserType'
    ) `
    -TurnOffTypeChecking
'@

Invoke-Formatter -ScriptDefinition $scriptDefinition  

Expected behavior

No formatting change.

$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
    -DesiredValues $desiredValues `
    -ValuesToCheck @(
        'LoginName'
        'AsymmetricKeyName'
        'CertificateName'
        'UserType'
    ) `
    -TurnOffTypeChecking

Actual behavior

Array is wrongly indented.

$testTargetResourceReturnValue = Test-DscParameterState -CurrentValues $getTargetResourceResult `
    -DesiredValues $desiredValues `
    -ValuesToCheck @(
    'LoginName'
    'AsymmetricKeyName'
    'CertificateName'
    'UserType'
) `
    -TurnOffTypeChecking

Environment data

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

and

Name                           Value
----                           -----
PSVersion                      7.0.3
PSEdition                      Core
GitCommitId                    7.0.3
OS                             Microsoft Windows 10.0.19042
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.19.1

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 bằng cách tái hiện vấn đề định dạng với Invoke-Formatter bằng cách sử dụng định nghĩa script PowerShell được nêu trong báo cáo. Theo dõi cách formatter xử lý các tham số được phân tách bằng backtick và mảng -ValuesToCheck, sau đó xác minh rằng thụt lề của mảng khớp với đầu ra mong đợi mà không thay đổi bất kỳ định dạng nào khác.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
42/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.