You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Defensive Programming is essential to software engineering. To enable fail-fast methodology in PowerShell, you must add $ErrorActionPreference = "Stop" to the top of every PowerShell file. One can easily forget to add this line; I would like a PSScriptAnalyzer rule that enforces the presence of $ErrorActionPreference = "Stop", or at a minimum enforces explicitly setting $ErororActionPreference.
What is the latest version of PSScriptAnalyzer at the point of writing
N/A (whatever comes in the latest version of VS Code PowerShell extension)
The text was updated successfully, but these errors were encountered:
There are multiple types of errors in PowerShell, this would require people to throw away soft errors in favor of trying to turn everything into an exception. That might be appropriate in some places, but it's certainly not necessary in every file.
Nothing wrong with you having a rule like that for your own projects if you feel strongly about it, but it's not a rule we'd want to push on the whole community.
That is to say: you're welcome to argue that non-exception/non-terminating errors aren't useful (discussions related to that come up frequently in the PowerShell/PowerShell/issues), but if the PowerShell team is arguing the error design is right, you shouldn't ask the PSScriptAnalyzer team to say it's wrong.
@Jaykul , I completely agree that this should not be enabled by default, but it nonetheless would be immensely valuable as an optional rule that can be installed with Install-Module PSScriptAnalyzer.
Summary of the new feature
Defensive Programming is essential to software engineering. To enable fail-fast methodology in PowerShell, you must add
$ErrorActionPreference = "Stop"
to the top of every PowerShell file. One can easily forget to add this line; I would like a PSScriptAnalyzer rule that enforces the presence of$ErrorActionPreference = "Stop"
, or at a minimum enforces explicitly setting$ErororActionPreference
.What is the latest version of PSScriptAnalyzer at the point of writing
N/A (whatever comes in the latest version of VS Code PowerShell extension)
The text was updated successfully, but these errors were encountered: