CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-admin/import/livejournal.php

Summary

Maintainability
F
6 days
Test Coverage

File livejournal.php has 830 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * LiveJournal API Importer
 *
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 day to fix

    LJ_API_Import has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LJ_API_Import {
    
        var $comments_url = 'http://www.livejournal.com/export_comments.bml';
        var $ixr_url      = 'http://www.livejournal.com/interface/xmlrpc';
        var $ixr;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 3 hrs to fix

      Function step1 has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          function step1() {
              global $verified;
              set_time_limit( 0 );
              update_option( 'ljapi_step', 1 );
              if ( !$this->ixr ) $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 2 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method step1 has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function step1() {
              global $verified;
              set_time_limit( 0 );
              update_option( 'ljapi_step', 1 );
              if ( !$this->ixr ) $this->ixr = new IXR_Client( $this->ixr_url, false, 80, 30 );
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 2 hrs to fix

        Method parse_comment has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function parse_comment( $comment ) {
                global $wpdb;
        
                // Get the top-level attributes
                preg_match( '|<comment([^>]+)>|i', $comment, $attribs );
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 2 hrs to fix

          Method greet has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function greet() {
                  ?>
                  <div class="narrow">
                  <form action="admin.php?import=livejournal" method="post">
                  <?php wp_nonce_field( 'lj-api-import' ) ?>
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

            Method import_post has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function import_post( $post ) {
                    global $wpdb;
            
                    // Make sure we haven't already imported this one
                    if ( $this->get_wp_post_ID( $post['itemid'] ) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

              Method setup has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  function setup() {
                      global $verified;
                      // Get details from form or from DB
                      if ( !empty( $_POST['lj_username'] ) && !empty( $_POST['lj_password'] ) ) {
                          // Store details for later
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                Method step2 has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function step2() {
                        set_time_limit( 0 );
                        update_option( 'ljapi_step', 2 );
                        $this->username = get_option( 'ljapi_username' );
                        $this->password = get_option( 'ljapi_password' );
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                  Function download_comment_meta has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      function download_comment_meta() {
                          $cookie = $this->get_session();
                          if ( is_wp_error( $cookie ) )
                              return $cookie;
                  
                  
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Method step3 has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      function step3() {
                          global $wpdb;
                          set_time_limit( 0 );
                          update_option( 'ljapi_step', 3 );
                  
                  
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                    Function setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        function setup() {
                            global $verified;
                            // Get details from form or from DB
                            if ( !empty( $_POST['lj_username'] ) && !empty( $_POST['lj_password'] ) ) {
                                // Store details for later
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function download_post_bodies has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                    Open

                        function download_post_bodies() {
                            $imported_count  = (int) get_option( 'ljapi_imported_count' );
                            $sync_item_times = get_option( 'ljapi_sync_item_times' );
                            $lastsync        = get_option( 'ljapi_lastsync_posts' );
                            if ( !$lastsync )
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Method download_post_bodies has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function download_post_bodies() {
                            $imported_count  = (int) get_option( 'ljapi_imported_count' );
                            $sync_item_times = get_option( 'ljapi_sync_item_times' );
                            $lastsync        = get_option( 'ljapi_lastsync_posts' );
                            if ( !$lastsync )
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                      Method download_comment_meta has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          function download_comment_meta() {
                              $cookie = $this->get_session();
                              if ( is_wp_error( $cookie ) )
                                  return $cookie;
                      
                      
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                        Function import_post has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            function import_post( $post ) {
                                global $wpdb;
                        
                                // Make sure we haven't already imported this one
                                if ( $this->get_wp_post_ID( $post['itemid'] ) )
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                        Cognitive Complexity

                        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                        A method's cognitive complexity is based on a few simple rules:

                        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                        • Code is considered more complex for each "break in the linear flow of the code"
                        • Code is considered more complex when "flow breaking structures are nested"

                        Further reading

                        Method download_post_meta has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            function download_post_meta() {
                                $total           = (int) get_option( 'ljapi_total' );
                                $count           = (int) get_option( 'ljapi_count' );
                                $lastsync        = get_option( 'ljapi_lastsync' );
                                if ( !$lastsync ) {
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                          Method download_comment_bodies has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function download_comment_bodies() {
                                  global $wpdb;
                                  $cookie = $this->get_session();
                                  if ( is_wp_error( $cookie ) )
                                      return $cookie;
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                            Function download_comment_bodies has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                                function download_comment_bodies() {
                                    global $wpdb;
                                    $cookie = $this->get_session();
                                    if ( is_wp_error( $cookie ) )
                                        return $cookie;
                            Severity: Minor
                            Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 1 hr to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function download_post_meta has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                function download_post_meta() {
                                    $total           = (int) get_option( 'ljapi_total' );
                                    $count           = (int) get_option( 'ljapi_count' );
                                    $lastsync        = get_option( 'ljapi_lastsync' );
                                    if ( !$lastsync ) {
                            Severity: Minor
                            Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 55 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Function insert_postmeta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                            Open

                                function insert_postmeta( $post_id, $post ) {
                                    // Need the original LJ id for comments
                                    add_post_meta( $post_id, 'lj_itemid', $post['itemid'] );
                            
                                    // And save the permalink on LJ in case we want to link back or something
                            Severity: Minor
                            Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 35 mins to fix

                            Cognitive Complexity

                            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                            A method's cognitive complexity is based on a few simple rules:

                            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                            • Code is considered more complex for each "break in the linear flow of the code"
                            • Code is considered more complex when "flow breaking structures are nested"

                            Further reading

                            Avoid too many return statements within this method.
                            Open

                                            return false;
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 30 mins to fix

                              Function parse_comment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  function parse_comment( $comment ) {
                                      global $wpdb;
                              
                                      // Get the top-level attributes
                                      preg_match( '|<comment([^>]+)>|i', $comment, $attribs );
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function step3 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  function step3() {
                                      global $wpdb;
                                      set_time_limit( 0 );
                                      update_option( 'ljapi_step', 3 );
                              
                              
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function lj_ixr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  function lj_ixr() {
                                      if ( $challenge = $this->ixr->query( 'LJ.XMLRPC.getchallenge' ) ) {
                                          $challenge = $this->ixr->getResponse();
                                      }
                                      if ( isset( $challenge['challenge'] ) ) {
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function step2 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  function step2() {
                                      set_time_limit( 0 );
                                      update_option( 'ljapi_step', 2 );
                                      $this->username = get_option( 'ljapi_username' );
                                      $this->password = get_option( 'ljapi_password' );
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              Function dispatch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  function dispatch() {
                                      if ( empty( $_REQUEST['step'] ) )
                                          $step = 0;
                                      else
                                          $step = (int) $_REQUEST['step'];
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/import/livejournal.php - About 25 mins to fix

                              Cognitive Complexity

                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                              A method's cognitive complexity is based on a few simple rules:

                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                              • Code is considered more complex for each "break in the linear flow of the code"
                              • Code is considered more complex when "flow breaking structures are nested"

                              Further reading

                              There are no issues that match your filters.

                              Category
                              Status