All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sonar.l10n.py.rules.python.S2190.html Maven / Gradle / Ivy

There is a newer version: 4.23.0.17664
Show newest version

Why is this an issue?

Recursion happens when control enters a loop that has no exit. This can happen when a method invokes itself or when a pair of methods invoke each other. It can be a useful tool, but unless the method includes a provision to break out of the recursion and return, the recursion will continue until the stack overflows and the program crashes.

Noncompliant code example

def my_pow(num, exponent):  # Noncompliant
    num = num * my_pow(num, exponent - 1)
    return num  # this is never reached

Compliant solution

def my_pow(num, exponent):  # Compliant
    if exponent > 1:
      num = num * my_pow(num, exponent - 1)
    return num




© 2015 - 2024 Weber Informatics LLC | Privacy Policy