PowerShell / PowerShell/PSScriptAnalyzer
Ability for script exclusions for PSUseCompatible* rules
Nessuno ha ancora preso questa issue.
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 414
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia individuando la configurazione delle regole PSUseCompatibleCommands, PSUseCompatibleSyntax, PSUseCompatibleTypes e PSUseCompatibleCmdlets e i relativi test esistenti. Confronta le due impostazioni proposte, quindi verifica che gli script esclusi disabilitino solo queste regole di compatibilità, mentre le altre regole rimangono attive.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell
- Ambito
- tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100