PowerShell / PowerShell/PSScriptAnalyzer
Ability for script exclusions for PSUseCompatible* rules
还没有人认领这个 Issue。
- 主要语言
- C#
- 星标
- 2.2k
- 派生
- 414
- 平均合并
- 13 小时 1 分钟
- 30 天内合并 PR
- 2
描述
Summary of the new feature
When using PSUseCompatible* rules with target profiles for PSv3, PSSA generates a whole bunch of issues for Pester tests that I have inside of my Script/Module projects. My Dev machine, as well as build machines run latest version of PowerShell, and the tests don't get bundled with my script/modules, hence I don't really care whether they'd run on versions other than latest. It would be really great if I could exclude my Test scripts (by path, by name pattern, or by name) just for these rules, and keep the rest of the rules active.
Proposed technical implementation details (optional)
Introduce an additional configuration setting for PSUseCompatible* rules, i.e. IgnoreScriptPath as follows:
@{
Rules = @{
PSUseCompatibleCommands = @{
Enable = $true
TargetProfiles = @(...);
IgnoreScriptPath = @(
'./Tests/', # Ignore any scripts within the Tests sub-folder
'./*.ps1', # Ignore all PowerShell scripts withing the root folder (i.e. build scripts)
'./HelperScripts/SomeHelperScriptForMyBuild.ps1' # Ignore a single helper file
)
};
PSUseCompatibleSyntax = @{
Enable = $true
TargetedVersions = @(...)
IgnoreScriptPath = @(
'./Tests/', # Ignore any scripts within the Tests sub-folder
'./*.ps1', # Ignore all PowerShell scripts withing the root folder (i.e. build scripts)
'./HelperScripts/SomeHelperScriptForMyBuild.ps1' # Ignore a single helper file
)
};
PSUseCompatibleTypes = @{
Enable = $true
TargetProfiles = @(...)
IgnoreScriptPath = @(
'./Tests/', # Ignore any scripts within the Tests sub-folder
'./*.ps1', # Ignore all PowerShell scripts withing the root folder (i.e. build scripts)
'./HelperScripts/SomeHelperScriptForMyBuild.ps1' # Ignore a single helper file
)
};
'PSUseCompatibleCmdlets' = @{
'compatibility' = @(...)
'IgnoreScriptPath' = @(
'./Tests/', # Ignore any scripts within the Tests sub-folder
'./*.ps1', # Ignore all PowerShell scripts withing the root folder (i.e. build scripts)
'./HelperScripts/SomeHelperScriptForMyBuild.ps1' # Ignore a single helper file
)
}
}
}
Alternatively, given that the collection of paths to ignore would most likely be identical for all the PSUseCompatible* rules, it might actually be easier to mention it once in a separate place, i.e.:
@{
Rules = @{
...
}
'PSUseCompatibleRulesIgnoreScriptPath' = @(
'./Tests/', # Ignore any scripts within the Tests sub-folder
'./*.ps1', # Ignore all PowerShell scripts withing the root folder (i.e. build scripts)
'./HelperScripts/SomeHelperScriptForMyBuild.ps1' # Ignore a single helper file
)
}
What is the latest version of PSScriptAnalyzer at the point of writing
1.18.3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先定位 PSUseCompatibleCommands、PSUseCompatibleSyntax、PSUseCompatibleTypes 和 PSUseCompatibleCmdlets 规则的配置及其现有测试。比较两个提议的设置,然后验证被排除的脚本只会抑制这些兼容性规则,而其他规则仍保持启用状态。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- powershell
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100