PowerShell / PowerShell/PSScriptAnalyzer
Test for and provide recommendation for resolution when $ErrorActionPreference = Break is found in script
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
Summary of the new feature
With the upcoming new feature to allow $ErrorActionPreference to be set to a value of "Break" as per tweet from @SteveL-MSFT (https://twitter.com/Steve_MSFT/status/1171871656664420352) can we add a PSScriptAnalyzer test for this so that scripts do not make it in to a Production environment with this feature still present and enabled in a line of code.
Proposed technical implementation details (optional)
Test for
$ErrorActionPreference = "break"
or
$ErrorActionPreference = 'break'
recommend the line is removed entirely but might accept that it is commented out when code reaches production
What is the latest version of PSScriptAnalyzer at the point of writing
1.18.2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing PSScriptAnalyzer rule implementations and their test conventions for assignment statements. Add coverage for both quoted forms of $ErrorActionPreference = "break" and verify that the diagnostic recommends removing the line or commenting it out before production.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100