Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no_else_return.py 934B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. """ Test that superfluous else return are detected. """
  2. # pylint:disable=invalid-name,missing-docstring,unused-variable
  3. def foo1(x, y, z):
  4. if x: # [no-else-return]
  5. a = 1
  6. return y
  7. else:
  8. b = 2
  9. return z
  10. def foo2(x, y, w, z):
  11. if x: # [no-else-return]
  12. a = 1
  13. return y
  14. elif z:
  15. b = 2
  16. return w
  17. else:
  18. c = 3
  19. return z
  20. def foo3(x, y, z):
  21. if x: # [no-else-return]
  22. a = 1
  23. if y: # [no-else-return]
  24. b = 2
  25. return y
  26. else:
  27. c = 3
  28. return x
  29. else:
  30. d = 4
  31. return z
  32. def bar1(x, y, z):
  33. if x:
  34. return y
  35. return z
  36. def bar2(w, x, y, z):
  37. if x:
  38. return y
  39. elif z:
  40. a = 1
  41. else:
  42. return w
  43. return None
  44. def bar3(x, y, z):
  45. if x:
  46. if z:
  47. return y
  48. else:
  49. return z
  50. return None