PowerShell / PSScriptAnalyzer

Download ScriptAnalyzer from PowerShellGallery
https://www.powershellgallery.com/packages/PSScriptAnalyzer/
MIT License
1.85k stars 375 forks source link

Functions that have a word starting with 'S' following a single noun trip the 'plural noun' warning #401

Closed joel74 closed 8 years ago

joel74 commented 8 years ago

I have two functions - Get-PoolMemberStatus' and 'Get-PoolMemberCollectionStatus' - that are failing the plural noun check. Maybe this check should consider case?

nightroman commented 8 years ago

It is about trailing 's', i.e. "Status" is treated as plural.

For example these "names" cause no issues:

function Get-PoolMemberStatu {}
function Get-PoolMemberCollectionStatu {}
joel74 commented 8 years ago

Thanks, Nightroman. After a bit more testing, I believe it's more nuanced than that.

function get-Status{}
function get-MyStatus{}
function get-ThisHiss{}

I think it has to do specifically with the word 'Status' being combined with other words. Of the preceding 3 functions, only get-MyStatus{} threw a warning.

raghushantha commented 8 years ago

We rely on .NET's PluralizationService to tell us if a given "noun" is plural or not. Looks like it does not account for all kinds of words. One workaround is to maintain a dictionary of regex for most common exceptions..

https://msdn.microsoft.com/en-us/library/system.data.entity.design.pluralizationservices.pluralizationservice.isplural(v=vs.110).aspx

joeyaiello commented 8 years ago

Per a conversation we had today, we're proposing that we regex the noun to look for the last capitalized word to get the "base noun" which should be passed to PluralizationService. It's a bit of heuristic, but we couldn't come up with a new false positive that would be fired that isn't fired today.

Does anyone have any feedback?

joel74 commented 8 years ago

That works for me. Thanks.

KirkMunro commented 8 years ago

That's a good approach IMHO. The only potential that comes to mind as an exception here would be if you were ending your command with an acronym that finishes with "s". e.g. Restart-Iis. Exceptions like those should be pretty rare though, and if the command author can use a pragma to silence those types of exceptions at some point, we should be good.

raghushantha commented 8 years ago

Fixed: https://github.com/PowerShell/PSScriptAnalyzer/pull/432

wordcarlos commented 7 years ago

Total 23816 words created by multiple letters combination with "S" as prefix, below there are some words listed starting with "S" Example: 1). Sacramentary 2). Satisfactive 3). Scholarships 4). Satisfactory 5). Sociologists etc.

Scrabble word finder