title: How do I fix SonarQube "variable is null on at least one execution path"?
body: <p>using sonarqube to analyze my code and being told "'alloc' is null on at least one execution path" for the following code</p>
  
  <pre><code>public RetirementAdvantageProgramSleeveAllocation(VariableDVAPolicy policy, Fund fund)
          : base(policy, fund)
      {
          SleeveAllocation alloc = null;
          if (fund.FundAccountType == FundAccountType.PortfolioChoice)
          {
              alloc = PortfolioChoiceAccountAllocation;
          }
          else if (fund.FundAccountType == FundAccountType.Heritage)
          {
              alloc = HeritageAccountAllocation;
          }
          else if (fund.FundAccountType == FundAccountType.RetirementProtection)
          {
              alloc = RetirementProtectionAccountAllocation;
          }
          alloc.PercentValue = fund.Value;
          alloc.PercentAllocation = fund.Value;
          alloc.Units = 0;
          alloc.Value = 0;
      }
  </code></pre>
  
  <p><code>alloc.PercentValue = fund.Value;</code> is where i am getting the Possible System.NullReferenceException however is this a false positive? or do i really need to wrap all of these into a <code>if (alloc == null)</code></p>
  
  <p>thanks</p>