title: Sonar "useless assignment to local variable" workaround?
body: <p>I am working towards improving my code, and I came across this issue from Sonar:</p>
  
  <pre><code>Remove this useless assignment to local variable "uiRequest"
  </code></pre>
  
  <p>Fact is, it is not useless, as I am using it just after in the code:</p>
  
  <pre><code>        // I am supposed to remove this
          UiRequest uiRequest = null;
  
          if("Party".equals(vauban.getName()))   {
              uiRequest = contextBuilder.buildContext(vauban);
          } else {
              // Maybe I could work my way around here ?
              throw new NamingException(
                      String.format(
                              "Hey %s, change your name to %s, thanks",
                              vauban.getName(), "Vauban"));
          }
  
          // Set the generated Id in the result of context builder
          MyOwnService response = callService(uiRequest, vauban);
  
          return response;
  </code></pre>
  
  <p>Sonar still tells me that "uiRequest" is useless, why ? It is not, as I don't want it to reach the code if it is null. I tried initializing it (<code>uiRequest = new UiRequest()</code>) but it keeps telling me that it is useless.</p>
  
  <p>Anyone got an idea about why Sonar behaves like this / how to correct this ?</p>