Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] Unconditional Recursion #2860

Open
numeralnathan opened this issue Oct 22, 2020 · 1 comment
Open

[java] Unconditional Recursion #2860

numeralnathan opened this issue Oct 22, 2020 · 1 comment
Labels
a:new-rule Proposal to add a new built-in rule

Comments

@numeralnathan
Copy link

numeralnathan commented Oct 22, 2020

Proposed Rule Name: UnconditionalRecursion

Proposed Category: Bug

Description:

Please create a rule that flags a problem for recursive calls that do not have a condition.

Code Sample:

The following code will cause a StackOverflowError.

void sum(int count)
{
   return sum(count - 1);
}

The following code may still cause a StackOverflowError depending on the parameter but if the parameter is not too large then it will terminate. However, since there is a condition, then this is "correct" code.

void sum(int count)
{
   if (count > 0)
      return sum(count - 1);

   return 0;
}

Possible Properties:

Can you think of some properties?

@numeralnathan numeralnathan added the a:new-rule Proposal to add a new built-in rule label Oct 22, 2020
@linusjf
Copy link

linusjf commented Oct 26, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:new-rule Proposal to add a new built-in rule
Projects
None yet
Development

No branches or pull requests

2 participants