CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

Function get_themes has a Cognitive Complexity of 115 (exceeds 5 allowed). Consider refactoring.
Open

function get_themes() {
    global $wp_themes, $wp_broken_themes;

    if ( isset($wp_themes) )
        return $wp_themes;
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/theme.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 search_theme_directories has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
Open

function search_theme_directories() {
    global $wp_theme_directories, $wp_broken_themes;
    if ( empty( $wp_theme_directories ) )
        return false;

Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/theme.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

File theme.php has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Theme, template, and stylesheet functions.
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 1 day to fix

    Method get_themes has 132 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function get_themes() {
        global $wp_themes, $wp_broken_themes;
    
        if ( isset($wp_themes) )
            return $wp_themes;
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 5 hrs to fix

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

      function search_theme_directories() {
          global $wp_theme_directories, $wp_broken_themes;
          if ( empty( $wp_theme_directories ) )
              return false;
      
      
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 2 hrs to fix

        Method get_theme_data has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function get_theme_data( $theme_file ) {
            $default_headers = array( 
                'Name' => 'Theme Name', 
                'URI' => 'Theme URI', 
                'Description' => 'Description', 
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 2 hrs to fix

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

          function locate_template($template_names, $load = false) {
              if (!is_array($template_names))
                  return '';
          
              $located = '';
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/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_current_theme has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function get_current_theme() {
              if ( $theme = get_option('current_theme') )
                  return $theme;
          
              $themes = get_themes();
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/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 get_theme_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          function get_theme_data( $theme_file ) {
              $default_headers = array( 
                  'Name' => 'Theme Name', 
                  'URI' => 'Theme URI', 
                  'Description' => 'Description', 
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/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

          Avoid deeply nested control flow statements.
          Open

                                  if ( preg_match('|^\.+$|', $subfile) )
                                      continue;
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if ( is_dir( $subdir . '/' . $theme_subdir) && is_readable($subdir . '/' . $theme_subdir) ) {
                                        if ( $theme_subdir{0} == '.' || $theme_subdir == 'CVS' )
                                            continue;
            
                                        $stylish_dir = @opendir($subdir . '/' . $theme_subdir);
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ( preg_match('|\.php$|', $subfile) )
                                          $template_files[] = "$template_directory/$file/$subfile";
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 45 mins to fix

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

                function current_theme_supports( $feature ) {
                    global $_wp_theme_features;
                
                    if ( !isset( $_wp_theme_features[$feature] ) )
                        return false;
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/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

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

                function preview_theme() {
                    if ( ! (isset($_GET['template']) && isset($_GET['preview'])) )
                        return;
                
                    if ( !current_user_can( 'switch_themes' ) )
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/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 false;
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/theme.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

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

                    function preview_theme_ob_filter_callback( $matches ) {
                        if ( strpos($matches[4], 'onclick') !== false )
                            $matches[4] = preg_replace('#onclick=([\'"]).*?(?<!\\\)\\1#i', '', $matches[4]); //Strip out any onclicks from rest of <a>. (?<!\\\) means to ignore the '" if its escaped by \  to prevent breaking mid-attribute.
                        if (
                            ( false !== strpos($matches[3], '/wp-admin/') )
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/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