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
Warn when 'Get-' prefix was omitted as part of the PSAvoidUsingCmdletAliases rule. (#927)
* Warn when 'Get-' prefix was omitted. Rename some variables to make the code clearer
* update docs
* do not warn for get- completion when the command exists natively (e.g. 'date' or service' on Unix systems)
* add test that there are no warnings about get- completion when native command takes precedence. Tested on Ubuntu 16.04 LTS
* use `date` for test because on some MacOs distros, service is not available
* Fix GetCommandInfoInternal method to actually use the CommandTypes argument
However, its calling method GetCommandInfo was relying on this bug (or its callers), therefore the method was declared legacy in order to not break existing behaviour
* change test syntax as requested in PR
Copy file name to clipboardExpand all lines: RuleDocumentation/AvoidUsingCmdletAliases.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
## Description
6
6
7
7
An alias is an alternate name or nickname for a CMDLet or for a command element, such as a function, script, file, or executable file.
8
-
You can use the alias instead of the command name in any Windows PowerShell commands.
8
+
You can use the alias instead of the command name in any Windows PowerShell commands. There are also implicit aliases: When PowerShell cannot find the cmdlet name, it will try to append `Get-` to the command as a last resort before, therefore e.g. `verb` will excute `Get-Verb`.
9
9
10
10
Every PowerShell author learns the actual command names, but different authors learn and use different aliases. Aliases can make code difficult to read, understand and
<value>An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. But when writing scripts that will potentially need to be maintained over time, either by the original author or another Windows PowerShell scripter, please consider using full cmdlet name instead of alias. Aliases can introduce these problems, readability, understandability and availability.</value>
121
+
<value>An alias is an alternate name or nickname for a cmdlet or for a command element, such as a function, script, file, or executable file. An implicit alias is also the omission of the 'Get-' prefix for commands with this prefix. But when writing scripts that will potentially need to be maintained over time, either by the original author or another Windows PowerShell scripter, please consider using full cmdlet name instead of alias. Aliases can introduce these problems, readability, understandability and availability.</value>
<value>Empty catch blocks are considered poor design decisions because if an error occurs in the try block, this error is simply swallowed and not acted upon. While this does not inherently lead to bad things. It can and this should be avoided if possible. To fix a violation of this rule, using Write-Error or throw statements in catch blocks.</value>
<value>'{0}' is implicitly aliasing '{1}' because it is missing the 'Get-' prefix. This can introduce possible problems and make scripts hard to maintain. Please consider changing command to its full name.</value>
0 commit comments