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
Nouns used in cmdlet naming need to be very specific so that the user can discover your cmdlets. Prefix generic nouns such as "server" with a shortened version of the product name. For example, if a noun refers to a server that is running an instance of Microsoft SQL Server, use a noun such as "SQLServer". The combination of specific nouns and the short list of approved verbs enable the user to quickly discover and anticipate functionality while avoiding duplication among cmdlet names.
To enhance the user experience, the noun that you choose for a cmdlet name should be singular. For example, use the name Get-Process instead of Get-Processes. It is best to follow this rule for all cmdlet names, even when a cmdlet is likely to act upon more than one item.
The part about singular vs. plural nouns is purely to "enhance the user experience". If the rule can't figure out if something is singular or plural, then the rule should not generate a warning, but leave the decision of how to "enhance the user experience" to the cmdlet writer.
The text was updated successfully, but these errors were encountered:
Hi Francis, thank you for the suggestion. We will work on fixing this rule. Can you provide us with a word where IsSingular and IsPlural returns false? This would be really helpful for testing purposes. Thanks.
The real problem is if someone makes up a word to represent a product and PluralizationService returns $false for IsSingular and IsPlural. From the list above, I know that the word "all" is the name of laundry detergent. We just can't know what will happen in the future to the English language or to the algorithm that PluralizationService is using, so I think the rule has to be very selective about its warnings.
There is a great example of this right in front of all of us:
"Windows"
If you had a command called Reset-Windows, where Windows is a name and also a noun, then that would have to be allowed. But you may also have a Close-Window command referring to a command that closes one or more open windows on your desktop, in which case that would have to be singular since that is referring to window as a noun only.
The trick is in identifying when to warn on a noun like "Windows". This is a perfect example why command authors, and not only command users, need to be able to indicate the best practice for their commands. The author of Reset-Windows should be able to apply an attribute to their command indicating that the noun is, in fact, singular. See #211 about enabling authors to guide PSScriptAnalyzer in the right direction like this.
Hi @imfrancisd, a new fix #220 is merged with BugFixes. We take your suggestion and modify the check based on the "truth table" (expected behavior). Thanks!
Suggestion
The "UseSingularNouns" rule should only generate a warning for words that are plural but not singular.
Before #139
The rule before #139 generated a warning for words that were both plural and singular.
After #139
The rule after #139 generates a warning even though the rule doesn't know if the word is plural or singular.
References
The "UseSingularNouns" rule can be traced back to:
The part about singular vs. plural nouns is purely to "enhance the user experience". If the rule can't figure out if something is singular or plural, then the rule should not generate a warning, but leave the decision of how to "enhance the user experience" to the cmdlet writer.
The text was updated successfully, but these errors were encountered: