Is there a way to suppress PSScriptAnalyzer
from highlighting alias
warnings? e.g.
'rm' is an alias of 'Remove-Item'. Aliases can introduce possible problems and make scripts hard to maintain. Please consider changing alias to its full content.
Aliases in PowerShell are extremely useful. I have a simple rule: I only ever use the rational built-in aliases in scripts (I ignore the strange ones). Why? Well, most of these particular aliases are now 13 years old and have never changed (PowerShell 1.0 release November 14, 2006). So, for example, %
or ls
or cd
are reliable in 99.99% of cases. I consider 99.99% reliability to be "good enough". Possibly the single-most-over-repeated comment on all PowerShell StackOverflow questions is "Note: it is not recommended to use aliases in PowerShell scripts as they can change!" (not recommended by whom I often wonder? God? ;-) )
However, PSScriptAnalyzer
in VSCode highlights all aliases as problems so that my current 7,000 line script has 488 such "problems". Is there a way to tell PSScriptAnalyzer
that I like aliases, I intend to use aliases for the vastly more concise code, clarity, and greatly improved readability that they give me, and so I do not consider them to be problems?