Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-1005

A function should have a single point of exit at the end of the function

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Legacy Key:
      FunctionSinglePointOfExit,ReturnInProcedureCheck
    • Covered Languages:
      C, C++, Flex, Objective-C, PL/SQL
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min

      Description

      This is required by IEC 61508, under good programming style.

      Noncompliant Code Example

      int function1()
      {
        return 3;
      }
      
      void function2()
      {
        function1();
      }
      
      int function3(char* ptr) /* Noncompliant; two explicit returns */
      {
        if (ptr == NULL) return -1;
      
        return 7;
      }
      
      void function4(char *ptr) /* Noncompliant; two returns, one explicit and one implicit */
      {
        if (1) return;
      
        printf("hello world!\n");
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                Anonymous
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: