Sonar

Increment the branch measure when encountering "throw" and "return" instructions

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.9
  • Component/s: Squid
  • Labels:
    None
  • Number of attachments :
    0

Description

Branch measure should be incremented by 1 each time a "throw" or "return" instruction is encountered except for the last return from a block.

Activity

Hide
Simon Brandhof added a comment -

Hi Freddy,
Could you explain the reason of this issue ? I found many contradictory formulas on the web.

I'm surprised that the two following codes have not the same complexity (3 and 2):

public void foo(boolean b) {
  if (b) {
    return b;
  }
  return false;
}
public void foo(boolean b) {
  boolean result;
  if (b) {
    result=b;
  } else {
    result= !b;
  }
  return result;
}
Show
Simon Brandhof added a comment - Hi Freddy, Could you explain the reason of this issue ? I found many contradictory formulas on the web. I'm surprised that the two following codes have not the same complexity (3 and 2):
public void foo(boolean b) {
  if (b) {
    return b;
  }
  return false;
}
public void foo(boolean b) {
  boolean result;
  if (b) {
    result=b;
  } else {
    result= !b;
  }
  return result;
}

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: