we've a python function that can be achieved in 2 ways 1st method
def complexity_1(x, y):
if 2 == x and 3 == y:
a=3
b=4
c = a + b
elif 2 == x and not 3 == y:
a = 3
b = 5
c = a + b
else:
c=5
return c
2nd method
def complexity_2(x, y):
if 2 == x:
a=3
if y==3:
b=4
else:
b=5
c = a + b
else:
c=5
return c
Which is the better way to do it the first one east to understand and reduces cyclomatic complexity but you're having duplicated code
c=a+b
and
a=3
twice, but in the 2nd method you don't have that duplication but hard to go through the logic which one is better and right way to do?