wp-plugins/all-in-one-seo-pack

View on GitHub
aioseop_importer_exporter.php

Summary

Maintainability
F
1 wk
Test Coverage

Function do_importer_exporter has a Cognitive Complexity of 143 (exceeds 5 allowed). Consider refactoring.
Open

        function do_importer_exporter( ) {
            $submit = null; $count = 0; $post_exists = null; $post_warning = null;
            global $aioseop_options, $aiosp, $aioseop_module_list;
            if ( isset( $_REQUEST['nonce-aioseop'] ) ) $nonce = $_REQUEST['nonce-aioseop'];
            $post_fields = Array( 'keywords', 'description', 'title', 'meta', 'disable', 'disable', 'disable_analytics', 'titleatr', 'menulabel', 'togglekeywords' );
Severity: Minor
Found in aioseop_importer_exporter.php - About 2 days 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 get_ini_file has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

        function get_ini_file( $assoc_arr, $has_sections=TRUE ) { 
            $content = ""; 
            if ($has_sections) { 
                foreach ($assoc_arr as $key=>$elem) { 
                    $content .= "[".$key."]\n"; 
Severity: Minor
Found in aioseop_importer_exporter.php - About 7 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

Function parse_ini_helper has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

        function parse_ini_helper( $array ) {
            $returnArray = array();
            if (is_array($array)) {
                foreach ($array as $key => $value) {
                    $e = explode(':', $key);
Severity: Minor
Found in aioseop_importer_exporter.php - About 5 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

Function recursive_parse has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

        function recursive_parse( $array ) {
            $returnArray = array();
            if (is_array($array)) {
                foreach ($array as $key => $value) {
                    if (is_array($value)) {
Severity: Minor
Found in aioseop_importer_exporter.php - About 5 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 do_importer_exporter has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        function do_importer_exporter( ) {
            $submit = null; $count = 0; $post_exists = null; $post_warning = null;
            global $aioseop_options, $aiosp, $aioseop_module_list;
            if ( isset( $_REQUEST['nonce-aioseop'] ) ) $nonce = $_REQUEST['nonce-aioseop'];
            $post_fields = Array( 'keywords', 'description', 'title', 'meta', 'disable', 'disable', 'disable_analytics', 'titleatr', 'menulabel', 'togglekeywords' );
Severity: Major
Found in aioseop_importer_exporter.php - About 3 hrs to fix

    File aioseop_importer_exporter.php has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @package All-in-One-SEO-Pack 
     */
    /**
    Severity: Minor
    Found in aioseop_importer_exporter.php - About 2 hrs to fix

      Function debug_post_types has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

              function debug_post_types( ) {
                  $post_types = $this->get_post_type_titles( );
                  $rempost = array( 'attachment' => 1, 'revision' => 1, 'nav_menu_item' => 1 );
                  $this->default_options['export_post_types']['initial_options']  = array_diff_key( $post_types, $rempost );
                  
      Severity: Minor
      Found in aioseop_importer_exporter.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 All_in_One_SEO_Pack_Importer_Exporter has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              function All_in_One_SEO_Pack_Importer_Exporter( ) {
                  $this->name = __( 'Importer & Exporter', 'all-in-one-seo-pack' );    // Human-readable name of the module
                  $this->prefix = 'aiosp_importer_exporter_';                        // option prefix
                  $this->file = __FILE__;
                  parent::__construct();
      Severity: Minor
      Found in aioseop_importer_exporter.php - About 1 hr to fix

        Method recursive_parse has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                function recursive_parse( $array ) {
                    $returnArray = array();
                    if (is_array($array)) {
                        foreach ($array as $key => $value) {
                            if (is_array($value)) {
        Severity: Minor
        Found in aioseop_importer_exporter.php - About 1 hr to fix

          Method parse_ini_helper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  function parse_ini_helper( $array ) {
                      $returnArray = array();
                      if (is_array($array)) {
                          foreach ($array as $key => $value) {
                              $e = explode(':', $key);
          Severity: Minor
          Found in aioseop_importer_exporter.php - About 1 hr to fix

            Method get_ini_file has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function get_ini_file( $assoc_arr, $has_sections=TRUE ) { 
                        $content = ""; 
                        if ($has_sections) { 
                            foreach ($assoc_arr as $key=>$elem) { 
                                $content .= "[".$key."]\n"; 
            Severity: Minor
            Found in aioseop_importer_exporter.php - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                              if( is_array( $module_options ) ) {
                                                  foreach( $module_options as $key => $value ) {
                                                      /* Update Post Data */
                                                      if( $label == 'post_data' ) {
                                                          $post_exists = post_exists( $module_options[$key]['post_title'], '', $module_options[$key]['post_date'] );
              Severity: Major
              Found in aioseop_importer_exporter.php - About 45 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                    foreach ($elem as $key2=>$elem2) { 
                                        if(is_array($elem2)) 
                                        { 
                                            for($i=0;$i<count($elem2);$i++) 
                                            { 
                Severity: Major
                Found in aioseop_importer_exporter.php and 1 other location - About 1 hr to fix
                aioseop_importer_exporter.php on lines 197..204

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 113.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                                foreach ($assoc_arr as $key=>$elem) { 
                                    if( is_array( $elem ) ) { 
                                        for($i=0;$i<count($elem);$i++) { 
                                            $content .= $key2."[] = \"".$elem[$i]."\"\n"; 
                                        } 
                Severity: Major
                Found in aioseop_importer_exporter.php and 1 other location - About 1 hr to fix
                aioseop_importer_exporter.php on lines 184..194

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 113.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                There are no issues that match your filters.

                Category
                Status