preferences file does not support $env: variables
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
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- powershell
- Lĩnh vực
- tooling
Hướng nghiên cứu
Tái hiện sự cố với PSScriptAnalyzerSettings.psd1 và Invoke-ScriptAnalyzer bằng cả CustomRulePath đơn giản lẫn biểu thức $env: hoặc $PSScriptRoot. Theo dõi cách tệp cài đặt được phân tích cú pháp và cách CustomRulePath được phân giải; hoàn tất khi các giá trị biến môi trường được hỗ trợ được chấp nhận mà không gặp lỗi xác thực hashtable và lệnh được ghi trong tài liệu hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
# # PSScriptAnalyzerSettings.psd1
# @{
# CustomRulePath = "rules.psm1"
# }
Invoke-ScriptAnalyzer -Path .\test.ps1 -Settings ./PSScriptAnalyzerSettings.psd1
outputs: (correct)
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSAvoidInvokeSomething Warning test.ps1 1 The command 'Invoke-Something' should not be used. Please
use 'Invoke-SomethingElse' instead
Actual behavior
# # PSScriptAnalyzerSettings.psd1
# @{
# CustomRulePath = "$PSScriptRoot/rules.psm1"
# }
Invoke-ScriptAnalyzer -Path .\test.ps1 -Settings ./PSScriptAnalyzerSettings.psd1
Outputs:
Invoke-ScriptAnalyzer: Value in the settings hashtable should be a string or an array of strings: line 2 column 22 in file [...]\Powershell\PSScriptAnalyzerSettings.psd1
Reasoning
according to this article,
Module manifests are loaded in RestrictedLanguage mode and may use these additional variables:
$PSScriptRoot
$PSEdition
$EnabledExperimentalFeatures
Any environment variable, like $env:TEMP
relative file paths CustomRulePath for my environment
were resolving relative to the cwd instead of relative to the settings.file in neovim. the
./rules.psm1 and rules.psm1 were not resolving correctly.
~/.../Powershell/PSScriptAnalyzerSettings.psd1
where '~' expands to HOMEDIR does work
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Microsoft Windows 10.0.26100
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.24.0
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 415
- Merge trung bình
- 13 giờ 1 phút
- Pull request đã merge (30 ngày)
- 2
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 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 bình luận ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Tất cả issue của PowerShell/PSScriptAnalyzer
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
sillsdev/languageforge-lexbox#2665 ·
-
bug documentation frontend
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
azurenoops/spin_agent#975 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
SubtitleEdit/subtitleedit#15108 · 1 bình luận ·