petenelson/wp-rest-api-toolbox

View on GitHub

Showing 14 of 47 total issues

Function exports has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function( grunt ) {

    'use strict';
    var banner = '/**\n * <%= pkg.homepage %>\n * Copyright (c) <%= grunt.template.today("yyyy") %>\n * This file is generated automatically. Do not edit.\n */\n';
    // Project configuration
Severity: Major
Found in Gruntfile.js - About 4 hrs to fix

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

            static public function endpoint_requires_authentication_filter( $result, $rest_server, $request ) {
    
                // Get the route for the request.
                $route = $request->get_route();
    
    
    Severity: Minor
    Found in includes/class-rest-api-toolbox-common.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 remove_selected_endpoints_filter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            static public function remove_selected_endpoints_filter( $routes ) {
    
                // Get the list of core endpoints.
                $core_settings = get_option( REST_API_Toolbox_Settings::options_key( 'core' ) );
                $core_settings = ! is_array( $core_settings ) ? array() : $core_settings;
    Severity: Minor
    Found in includes/class-rest-api-toolbox-common.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

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

            static public function remove_wordpress_core_namespace_filter( $response ) {
    
                $remove_all = REST_API_Toolbox_Settings::setting_is_enabled( 'core', 'remove-all-core-routes' );
                if ( $remove_all ) {
                    if ( ! empty( $response->data ) && ! empty( $response->data['namespaces'] ) ) {
    Severity: Minor
    Found in includes/class-rest-api-toolbox-common.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 settings_input has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            static public function settings_input( $args ) {
    
                $args = wp_parse_args( $args,
                    array(
                        'name' => '',
    Severity: Minor
    Found in includes/settings/class-rest-api-toolbox-settings-base.php - About 1 hr to fix

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

          function status( $positional_args, $assoc_args = array() ) {
      
              if ( ! empty( $positional_args ) ) {
                  $core_endpoint = $positional_args[0];
      
      
      Severity: Minor
      Found in includes/wp-cli/class-rest-api-toolbox-rest-api-command.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 register_cpt_settings has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              static public function register_cpt_settings() {
                  $key = self::$settings_key;
      
                  register_setting( $key, $key, array( __CLASS__, 'sanitize_cpt_settings') );
      
      

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

                static public function endpoint_requires_authentication_filter( $result, $rest_server, $request ) {
        
                    // Get the route for the request.
                    $route = $request->get_route();
        
        
        Severity: Minor
        Found in includes/class-rest-api-toolbox-common.php - About 1 hr to fix

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

                  static public function register_core_settings() {
                      $key = self::$settings_key;
          
                      register_setting( $key, $key, array( __CLASS__, 'sanitize_core_settings') );
          
          
          Severity: Minor
          Found in includes/settings/class-rest-api-toolbox-settings-core.php - About 1 hr to fix

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

                    static public function settings_yes_no( $args ) {
            
                        $args = wp_parse_args( $args,
                            array(
                                'name' => '',
            Severity: Minor
            Found in includes/settings/class-rest-api-toolbox-settings-base.php - About 1 hr to fix

              Avoid deeply nested control flow statements.
              Open

                                      if ( self::core_namespace() === $response->data['namespaces'][ $i ] ) {
                                          unset( $response->data['namespaces'][ $i ] );
                                          $response->data['namespaces'] = array_values( $response->data['namespaces'] );
                                          break;
                                      }
              Severity: Major
              Found in includes/class-rest-api-toolbox-common.php - About 45 mins to fix

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

                        static public function register_cpt_settings() {
                            $key = self::$settings_key;
                
                            register_setting( $key, $key, array( __CLASS__, 'sanitize_cpt_settings') );
                
                
                Severity: Minor
                Found in includes/settings/class-rest-api-toolbox-settings-custom-post-types.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 change_setting has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        static public function change_setting( $key, $setting, $value, $sanitize_callback = null ) {
                            if ( ! self::settings_key_is_valid( $key ) ) {
                                return false;
                            }
                
                
                Severity: Minor
                Found in includes/settings/class-rest-api-toolbox-settings-base.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 endpoint_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                        static public function endpoint_exists( $endpoint ) {
                
                            rest_api_loaded();
                
                            $wp_rest_server = self::get_rest_api_server();
                Severity: Minor
                Found in includes/class-rest-api-toolbox-common.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

                Severity
                Category
                Status
                Source
                Language