Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-13240

Extract Function should check if the parameter is used after the function call

XMLWordPrintable

    • 840263eb9a (qt-creator/qt-creator/master)

      Check the attached code snippet.
      After the "Extract Method" the a parameter is input only and a = b has no effect on the calling function a variable.

      main.cpp
      int testFunction()
      {
          int a = 0;
          // SELECTION START for Extract method
          int b = 0;
      
          for( int i= 0; i< 5; ++i) {
              b=i;
      
              if(i == 2)
                  a = b;
          }
          // SELECTION END for Extract Method
      
          return a;
      }
      
      main_after_extract_method.cpp
      // RESULT FROM EXTRACT METHOD
      int testFunction()
      {
          int a = 0;
          foo(a);
      
          return a;
      }
      
      // a is input only parameter -> a = b has no effect on the calling function a variable
      void foo(int a)
      {
          int b = 0;
      
          for( int i= 0; i< 5; ++i) {
              b=i;
      
              if(i == 2)
                  a = b;
          }
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kandeler Christian Kandeler
            kileppal Kimmo Leppälä
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes