﻿# V7008\. Two or more 'case' branches perform the same actions\.

The analyzer has detected that multiple case clauses of the switch statement contain the same code\.

This error may occur, for example, as a result of copying code\. 

The example:

```cpp
switch (selector) {
  case "foo":
    res = foo;
    break;
  case "bar":
    res = bar;
    break;
  case "baz":
    res = bar;
    break;
}
```

In the `"baz"` case, `res` is assigned the value of `bar` instead of `baz`\.

The fixed code:

```cpp
switch (selector) {
  case "foo":
    res = foo;
    break;
  case "bar":
    res = bar;
    break;
  case "baz":
    res = baz;
    break;
}
```

This warning may also indicate redundant code that can be improved by combining `case` labels\. 

The example of redundant code:

```cpp
switch (selector) {
  case "fooX":
    res = foo;
    break;
  case "fooY":
    res = foo;
    break;
  case "barX":
    res = bar;
    break;
  case "barY":
    res = bar;
    break;    
}
```

Although this is not an error, combining case labels can enhance code readability and reduce redundancy:

```cpp
switch (selector) {
  case "fooX":
  case "fooY":
    res = foo;
    break;
  case "barX":
  case "barY":
    res = bar;
    break;
}
```