Expand Minimize

Correctness

Correctness rules check the PowerShell code for correct usage.

Index

Rule Description Type Severity
SPC019101: Do not use empty Catch Blocks Empty catch blocks are a poor design. Always output an error and use error handling in the event of an exception. PoShFile CriticalWarning
SPC019102: Do not invoke non constant members Using variable member invocations can result in an empty invocation from occurring. This can result in undesired circumstances. PoShFile CriticalWarning
SPC019103: Do not use special characters in method names The use of special characters in method names can result in parser errors when executing the script. PoShFile CriticalError
SPC019104: Do not use reserved words as parameter names Exceptions and unwanted bahaviour occurs when reserved words are used as paramater names. PoShFile CriticalError
SPC019105: Functions that use ShouldProcess sould support Force to bypass In order to correctly support the force boolean switch, you need to call ShouldContinue correctly when you call ShouldProcess. PoShFile CriticalWarning
SPC019106: Do not use trap statements Trap statements are designed for administrators. Try Catch should be used in all written script files. History: Trap was implemented in v1, because it was all the PowerShell team had time to implement. PoShFile CriticalWarning
SPC019107: Do not use unitialized variables Uninitialized variables will cause script errors, and should never be used before assignment. PoShFile CriticalWarning
SPC019108: Incorrect precedence for comparison operator against null If the item on the left hand side is an Array, PowerShell will automatically check the whole Array for null. PoShFile CriticalWarning
SPC019109: Use only approved verbs The approved verbs are designed to describe the scope of the action, not using them can confuse the scripts intention to the end user. PoShFile Warning
SPC019110: Use a Byte Order Mark with non Ascii files Ascii is a 7-bit to the byte encoding. Files that use UTF-8/UTF-16 or another encoding should use a byte order mark to allow identification. PoShFile CriticalWarning
SPC019111: Call CmdLets with correct parameters CmdLets must be called with the correct syntax and parameters. PoShFile CriticalWarning
SPC019112: Remove unused variable Variables that have been assigned but not used should be removed for better supportability in the future. Having unused variables can confuse the scripts intent. PoShFile Warning
SPC019113: Declare output types correctly No exception will be thrown if you pass the wrong type, which can result in undesired results. PoShFile CriticalWarning
SPC019114: Use singular nouns for CmdLets As standard practice for PowerShell, CmdLets should be named Verb-Noun in the singular form. PoShFile Warning
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.