Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update S1479: "Switch with too many cases" should ignore empty, fall-through cases #388

Closed
ganncamp opened this issue May 30, 2017 · 0 comments
Assignees
Milestone

Comments

@ganncamp
Copy link

ganncamp commented May 30, 2017

Rule S1479

The reasoning behind this rule is

When switch statements have large sets of case clauses, it is usually an attempt to map two sets of data. A real map structure would be more readable and maintainable

But empty, fall-through cases argue against this interpretation. So at the very least they should be ignored by the count. E.G.:

switch (i) {
  case 1:  // ignored
  case 2:  // ignored
  case 3:  // fallthrough but NOT ignored
    DoTheThing();
  case 4:  // counted as usual
    DoTheFinalThing();
    break;
  case 5:
//...
@valhristov valhristov changed the title S1479 (switch with too many cases) should ignore empty, fall-through cases Update S1479: "Switch with too many cases" should ignore empty, fall-through cases May 31, 2017
@valhristov valhristov added this to the near-future milestone May 31, 2017
@Evangelink Evangelink modified the milestones: 6.1, near-future Jun 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants