CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

File class-wp-theme.php has 606 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WP_Theme Class
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 day to fix

    Function __construct has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __construct( $theme_dir, $theme_root, $_child = null ) {
            global $wp_theme_directories;
    
            // Initialize caching on first run.
            if ( ! isset( self::$persistently_cache ) ) {
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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

    WP_Theme has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    final class WP_Theme implements ArrayAccess {
    
        /**
         * Headers for style.css files.
         *
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 5 hrs to fix

      Function get_allowed_on_site has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_allowed_on_site( $blog_id = null ) {
              static $allowed_themes = array();
      
              if ( ! $blog_id || ! is_multisite() )
                  $blog_id = get_current_blog_id();
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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

      Method __construct has 93 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __construct( $theme_dir, $theme_root, $_child = null ) {
              global $wp_theme_directories;
      
              // Initialize caching on first run.
              if ( ! isset( self::$persistently_cache ) ) {
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 3 hrs to fix

        Function scandir has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function scandir( $path, $extensions = null, $depth = 0, $relative_path = '' ) {
                if ( ! is_dir( $path ) )
                    return false;
        
                if ( $extensions ) {
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 get_allowed_on_site has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function get_allowed_on_site( $blog_id = null ) {
                static $allowed_themes = array();
        
                if ( ! $blog_id || ! is_multisite() )
                    $blog_id = get_current_blog_id();
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

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

              public function offsetGet( $offset ) {
                  switch ( $offset ) {
                      case 'Name' :
                      case 'Title' :
                          // See note above about using translated data. get() is not ideal.
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

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

                public function get_page_templates( $post = null ) {
                    // If you screw up your current theme and we invalidate your parent, most things still work. Let it slide.
                    if ( $this->errors() && $this->errors()->get_error_codes() !== array( 'theme_parent_invalid' ) )
                        return array();
            
            
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 sanitize_header has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function sanitize_header( $header, $value ) {
                    switch ( $header ) {
                        case 'Status' :
                            if ( ! $value ) {
                                $value = 'publish';
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

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

                  private function markup_header( $header, $value, $translate ) {
                      switch ( $header ) {
                          case 'Name' :
                              if ( empty( $value ) )
                                  $value = $this->get_stylesheet();
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 translate_header has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function translate_header( $header, $value ) {
                      switch ( $header ) {
                          case 'Name' :
                              // Cached for sorting reasons.
                              if ( isset( $this->name_translated ) )
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 markup_header has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private function markup_header( $header, $value, $translate ) {
                      switch ( $header ) {
                          case 'Name' :
                              if ( empty( $value ) )
                                  $value = $this->get_stylesheet();
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

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

                    public function __get( $offset ) {
                        switch ( $offset ) {
                            case 'name' :
                            case 'title' :
                                return $this->get('Name');
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

                  Method translate_header has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function translate_header( $header, $value ) {
                          switch ( $header ) {
                              case 'Name' :
                                  // Cached for sorting reasons.
                                  if ( isset( $this->name_translated ) )
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 1 hr to fix

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

                        public function get_screenshot( $uri = 'uri' ) {
                            $screenshot = $this->cache_get( 'screenshot' );
                            if ( $screenshot ) {
                                if ( 'relative' == $uri )
                                    return $screenshot;
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function get( $header ) {
                            if ( ! isset( $this->headers[ $header ] ) )
                                return false;
                    
                            if ( ! isset( $this->headers_sanitized ) ) {
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 is_allowed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function is_allowed( $check = 'both', $blog_id = null ) {
                            if ( ! is_multisite() )
                                return true;
                    
                            if ( 'both' == $check || 'network' == $check ) {
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 45 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 sanitize_header has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function sanitize_header( $header, $value ) {
                            switch ( $header ) {
                                case 'Status' :
                                    if ( ! $value ) {
                                        $value = 'publish';
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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 $this->display('Description');
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $this->get_screenshot( 'relative' );
                      Severity: Major
                      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $this->get_screenshot( 'relative' );
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $this->get('Tags');
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return $this->get_template();
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return $this->get_template();
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return $this->get_files( 'php', 1, true );
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                  return null;
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return $this->get_stylesheet_directory_uri() . '/' . 'screenshot.' . $ext;
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                      return $this->get_theme_root_uri();
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                        return $this->get_stylesheet();
                                        Severity: Major
                                        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                          return;
                                          Severity: Major
                                          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                            return $this->get_theme_root_uri();
                                            Severity: Major
                                            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                              return $this->get_files( 'css', 0, false );
                                              Severity: Major
                                              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                return $this->get_theme_root();
                                                Severity: Major
                                                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                  return $this->get_stylesheet_directory();
                                                  Severity: Major
                                                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                    return $this->get_stylesheet_directory();
                                                    Severity: Major
                                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                      return $this->get_stylesheet();
                                                      Severity: Major
                                                      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                        return $this->display('Author');
                                                        Severity: Major
                                                        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                          return $this->display( 'Description');
                                                          Severity: Major
                                                          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                            return $this->get( 'Tags' );
                                                            Severity: Major
                                                            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                              return $this->get_theme_root();
                                                              Severity: Major
                                                              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                                return $this->parent() ? $this->parent()->get('Name') : '';
                                                                Severity: Major
                                                                Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                          return false;
                                                                  Severity: Major
                                                                  Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                                    return;
                                                                    Severity: Major
                                                                    Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                      return $this->get_template_directory();
                                                                      Severity: Major
                                                                      Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                        return $this->offsetGet( $offset );
                                                                        Severity: Major
                                                                        Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                  return $value;
                                                                          Severity: Major
                                                                          Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                            return $this->get( $offset );
                                                                            Severity: Major
                                                                            Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.php - About 30 mins to fix

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

                                                                                  public function display( $header, $markup = true, $translate = true ) {
                                                                                      $value = $this->get( $header );
                                                                                      if ( false === $value ) {
                                                                                          return false;
                                                                                      }
                                                                              Severity: Minor
                                                                              Found in Web.Admin/2014/wordpress/wp-includes/class-wp-theme.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