isocpp / isocpp/CppCoreGuidelines
Mismatch between the synopsis and enforcement of rule Enum.2
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 45.3k
- Forks
- 5.6k
- PR merge metrics
- No merged PRs in 30d
Description
The synopsis of rule Enum.2 is "Use enumerations to represent sets of related named constants" and the enforcement of this rule is about flagging switch statements for enumerations that don't cover all enumerators. The enforcements certainly make sense but if you violate these it doesn't mean that you haven't "Used enumerations that don't represent sets of related named constants". These are completely unrelated.
Since I think the enforcements are great, they should be kept. It would better to change the synopsis to something like "Make sure all cases are covered when using a switch statement".
Note that a third enforcement could be added in this context:
- Flag switch-statements where the cases cover all enumerators and there is a default.
The reason for this is that the default is actually dead code in such a case. But more importantly, the other enforcements will not trigger if there is a default because the default will cover the new enumerator.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Enum.2 rule entry and compare its synopsis with the listed switch-statement enforcements. Update the synopsis so it matches the existing checks, and determine whether the suggested redundant-default case is within scope; done means the rule description and enforcement behavior are consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100