title: Refactor multiple if-else
body: <p>I have below code with lot of if else codition. Due to this if else code looking more complex and also sonar saying <code>"Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed."</code></p>
  
  <p>Is there any other way so that I can reduce the complexcity.</p>
  
  <pre><code>    if (CONDITION1) {
          validatorVO.setErrorCode("ERROR_CODE_1");
      } else if (CONDITION2) {
          validatorVO.setErrorCode("ERROR_CODE_2");
      } else if (CONDITION3) {
          validatorVO.setErrorCode("ERROR_CODE_3");
      } else if (CONDITION4) {
          if (CONDITION5) {
              validatorVO.setErrorCode("ERROR_CODE_4");
          } else if (CONDITION6) {
              validatorVO.setErrorCode("ERROR_CODE_5");
          } else if (CONDITION7) {
              validatorVO.setErrorCode("ERROR_CODE_6");
          } else {
              validatorVO.setErrorCode("ERROR_CODE_7");
          }
      } else if (CONDITION8) {
          validatorVO.setErrorCode("ERROR_CODE_8");
      } else if (CONDITION9) {
          validatorVO.setErrorCode("ERROR_CODE_9");
      } else if (CONDITION10) {
          validatorVO.setErrorCode("ERROR_CODE_10");
      } else if (CONDITION11) {
          validatorVO.setErrorCode("ERROR_CODE_11");
      }
  }
  </code></pre>
  
  <p>Note : Based on the condition error code will be different</p>