CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/rewrite.php

Summary

Maintainability
F
1 wk
Test Coverage

File rewrite.php has 774 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress Rewrite API
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 day to fix

    Function generate_rewrite_rules has a Cognitive Complexity of 79 (exceeds 5 allowed). Consider refactoring.
    Open

        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
            //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
            $feedregex2 = '';
            foreach ( (array) $this->feeds as $feed_name) {
                $feedregex2 .= $feed_name . '|';
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 day 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 generate_rewrite_rules has 144 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
            //build a regex to match the feed section of URLs, something like (feed|atom|rss|rss2)/?
            $feedregex2 = '';
            foreach ( (array) $this->feeds as $feed_name) {
                $feedregex2 .= $feed_name . '|';
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 5 hrs to fix

      WP_Rewrite has 35 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WP_Rewrite {
          /**
           * Default permalink structure for WordPress.
           *
           * @since 1.5.0
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 4 hrs to fix

        Function url_to_postid has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function url_to_postid($url) {
            global $wp_rewrite;
        
            $url = apply_filters('url_to_postid', $url);
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 3 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 mod_rewrite_rules has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            function mod_rewrite_rules() {
                if ( ! $this->using_permalinks()) {
                    return '';
                }
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/rewrite.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 url_to_postid has 52 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function url_to_postid($url) {
            global $wp_rewrite;
        
            $url = apply_filters('url_to_postid', $url);
        
        
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 2 hrs to fix

          Method mod_rewrite_rules has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function mod_rewrite_rules() {
                  if ( ! $this->using_permalinks()) {
                      return '';
                  }
          
          
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                            if (strpos($struct, '%postname%') !== false || strpos($struct, '%post_id%') !== false
                                    || strpos($struct, '%pagename%') !== false
                                    || (strpos($struct, '%year%') !== false && strpos($struct, '%monthnum%') !== false && strpos($struct, '%day%') !== false && strpos($struct, '%hour%') !== false && strpos($struct, '%minute%') !== false && strpos($struct, '%second%') !== false)) {
                                $post = true;
                                if (strpos($struct, '%pagename%') !== false)
            Severity: Critical
            Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 hr to fix

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

                  function rewrite_rules() {
                      $rewrite = array();
              
                      if (empty($this->permalink_structure)) {
                          return $rewrite;
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 hr to fix

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

                    function get_date_permastruct() {
                        if (isset($this->date_structure)) {
                            return $this->date_structure;
                        }
                
                
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/rewrite.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 get_date_permastruct has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function get_date_permastruct() {
                        if (isset($this->date_structure)) {
                            return $this->date_structure;
                        }
                
                
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 hr to fix

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

                      function iis7_url_rewrite_rules($add_parent_tags = false, $indent = "  ", $end_of_line = "\n") {
                  
                          if ( ! $this->using_permalinks()) {
                              return '';
                          }
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 1 hr to fix

                    Method generate_rewrite_rules has 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        function generate_rewrite_rules($permalink_structure, $ep_mask = EP_NONE, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true, $endpoints = true) {
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 50 mins to fix

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

                          function page_rewrite_rules() {
                              $rewrite_rules = array();
                              $page_structure = $this->get_page_permastruct();
                      
                              if ( ! $this->use_verbose_page_rules ) {
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/rewrite.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

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

                          function page_uri_index() {
                              global $wpdb;
                      
                              //get pages in order of hierarchy, i.e. children after parents
                              $posts = get_page_hierarchy($wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_type = 'page'"));
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/rewrite.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 0;
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php - About 30 mins to fix

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

                            function get_tag_permastruct() {
                                if (isset($this->tag_structure)) {
                                    return $this->tag_structure;
                                }
                        
                        
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php and 1 other location - About 1 hr to fix
                        Web.Admin/2014/wordpress/wp-includes/rewrite.php on lines 1000..1018

                        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 118.

                        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

                            function get_category_permastruct() {
                                if (isset($this->category_structure)) {
                                    return $this->category_structure;
                                }
                        
                        
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/rewrite.php and 1 other location - About 1 hr to fix
                        Web.Admin/2014/wordpress/wp-includes/rewrite.php on lines 1033..1051

                        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 118.

                        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