CaffGeek/MBACNationals

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

Summary

Maintainability
F
6 days
Test Coverage

File option.php has 553 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function get_option has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function get_option( $option, $default = false ) {
        global $wpdb;
    
        $option = trim( $option );
        if ( empty( $option ) )
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/option.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 set_transient has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function set_transient( $transient, $value, $expiration = 0 ) {
    
        /**
         * Filter a specific transient before its value is set.
         *
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/option.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_option has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function get_option( $option, $default = false ) {
        global $wpdb;
    
        $option = trim( $option );
        if ( empty( $option ) )
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

      Function get_transient has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function get_transient( $transient ) {
      
           /**
           * Filter the value of an existing transient.
           *
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/option.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 add_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
          global $wpdb;
      
          if ( !empty( $deprecated ) )
              _deprecated_argument( __FUNCTION__, '2.3' );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/option.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 add_site_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function add_site_option( $option, $value ) {
          global $wpdb;
      
          wp_protect_special_option( $option );
      
      
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/option.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_site_option has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

      function get_site_option( $option, $default = false, $use_cache = true ) {
          global $wpdb;
      
          /**
           * Filter an existing site option before it is retrieved.
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/option.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 add_option has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' ) {
          global $wpdb;
      
          if ( !empty( $deprecated ) )
              _deprecated_argument( __FUNCTION__, '2.3' );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

        Method update_option has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function update_option( $option, $value ) {
            global $wpdb;
        
            $option = trim($option);
            if ( empty($option) )
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

          Method set_transient has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function set_transient( $transient, $value, $expiration = 0 ) {
          
              /**
               * Filter a specific transient before its value is set.
               *
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

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

            function set_site_transient( $transient, $value, $expiration = 0 ) {
            
                /**
                 * Filter the value of a specific site transient before it is set.
                 *
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/option.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_site_transient has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function get_site_transient( $transient ) {
            
                /**
                 * Filter the value of an existing site transient.
                 *
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/option.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 delete_option has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function delete_option( $option ) {
                global $wpdb;
            
                $option = trim( $option );
                if ( empty( $option ) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/option.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 update_option has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function update_option( $option, $value ) {
                global $wpdb;
            
                $option = trim($option);
                if ( empty($option) )
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/option.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 update_site_option has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function update_site_option( $option, $value ) {
                global $wpdb;
            
                wp_protect_special_option( $option );
            
            
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

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

              function add_site_option( $option, $value ) {
                  global $wpdb;
              
                  wp_protect_special_option( $option );
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

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

                function get_site_option( $option, $default = false, $use_cache = true ) {
                    global $wpdb;
                
                    /**
                     * Filter an existing site option before it is retrieved.
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

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

                  function wp_user_settings() {
                  
                      if ( ! is_admin() )
                          return;
                  
                  
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/option.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 wp_load_alloptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function wp_load_alloptions() {
                      global $wpdb;
                  
                      if ( !defined( 'WP_INSTALLING' ) || !is_multisite() )
                          $alloptions = wp_cache_get( 'alloptions', 'options' );
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/option.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 delete_option has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function delete_option( $option ) {
                      global $wpdb;
                  
                      $option = trim( $option );
                      if ( empty( $option ) )
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 1 hr to fix

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

                    function get_all_user_settings() {
                        global $_updated_user_settings;
                    
                        if ( ! $user_id = get_current_user_id() )
                            return array();
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/option.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 update_site_option has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function update_site_option( $option, $value ) {
                        global $wpdb;
                    
                        wp_protect_special_option( $option );
                    
                    
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/option.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 too many return statements within this method.
                    Open

                            return get_option( 'siteurl' );
                    Severity: Major
                    Found in Web.Admin/2014/wordpress/wp-includes/option.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/option.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return apply_filters( 'default_option_' . $option, $default );
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/option.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/option.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                return apply_filters( 'option_' . $option, maybe_unserialize( $value ) );
                            Severity: Major
                            Found in Web.Admin/2014/wordpress/wp-includes/option.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/option.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return apply_filters( 'default_option_' . $option, $default );
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-includes/option.php - About 30 mins to fix

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

                                  function delete_site_option( $option ) {
                                      global $wpdb;
                                  
                                      // ms_protect_special_option( $option ); @todo
                                  
                                  
                                  Severity: Minor
                                  Found in Web.Admin/2014/wordpress/wp-includes/option.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 wp_set_all_user_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function wp_set_all_user_settings( $user_settings ) {
                                      global $_updated_user_settings;
                                  
                                      if ( ! $user_id = get_current_user_id() )
                                          return false;
                                  Severity: Minor
                                  Found in Web.Admin/2014/wordpress/wp-includes/option.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

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

                                  function delete_site_transient( $transient ) {
                                  
                                      /**
                                       * Fires immediately before a specific site transient is deleted.
                                       *
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/option.php and 1 other location - About 2 hrs to fix
                                  Web.Admin/2014/wordpress/wp-includes/option.php on lines 513..549

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

                                  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 delete_transient( $transient ) {
                                  
                                      /**
                                       * Fires immediately before a specific transient is deleted.
                                       *
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/option.php and 1 other location - About 2 hrs to fix
                                  Web.Admin/2014/wordpress/wp-includes/option.php on lines 1250..1285

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

                                  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