Roslyn-analyzers: CA1717 false positives for "status"

Created on 18 Oct 2017  路  8Comments  路  Source: dotnet/roslyn-analyzers

Analyzer package

Microsoft.CodeAnalysis.FxCopAnalyzers

Analyzer

CA1717

Repro steps

Add a non-flags enumeration with a suffix of "Status", such as ViewStatus

Expected behavior

No violation, since "status" is not generally accepted as a pluralization.

Actual behavior

warning CA1717: Only FlagsAttribute enums should have plural names
4 - In Review Area-Microsoft.CodeQuality.Analyzers Bug False_Positive

Most helpful comment

Here's me thinking the heuristic would be more sophisticated than an EndsWith("s") 馃槅

All 8 comments

Thank you, @kentcb! Reproduced and confirmed

In accordance with https://msdn.microsoft.com/en-us/library/bb264486.aspx:

When to Suppress Warnings
It is safe to suppress a violation if the name is a plural word but does not end in 's'. For example, if the multiple-day enumeration that was described previously were named 'DaysOfTheWeek', this would violate the logic of the rule but not its intent. Such violations should be suppressd.

As far as I know, there are no plans to add specific checks for words ending with 's'. So, you can safely suppress the warning. Thank you!

Here's me thinking the heuristic would be more sophisticated than an EndsWith("s") 馃槅

We recently started using Humanizer for plurality naming suggestions in the IDE. @rchande, do you think it would be possible to use that for this application as well?

@333fred Definitely! They have pretty comprehensive heuristics for checking if a word is plural.

This should be done.

If I have to go to every occurrence of violations of this rule to suppress the rule, it makes the rule useless.

This should be done.

If I have to go to every occurrence of violations of this rule to suppress the rule, it makes the rule useless.

"Useless" is strong, but given how common "Status" is, it would seem sensible to add an exception for. Even "-us" - I suspect there's very few English words likely to be used to name an Enum that have a plural ending in -us.

Was this page helpful?
0 / 5 - 0 ratings