felixarntz/plugin-lib

View on GitHub
src/db-objects/rest-models-controller.php

Summary

Maintainability
F
1 wk
Test Coverage

File rest-models-controller.php has 760 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * REST models controller class
 *
 * @package Leaves_And_Love\Plugin_Lib
Severity: Major
Found in src/db-objects/rest-models-controller.php - About 1 day to fix

    Function get_items has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

            public function get_items( $request ) {
                $registered_args = $this->get_collection_params();
    
                $args = array();
    
    
    Severity: Minor
    Found in src/db-objects/rest-models-controller.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

    Function prepare_item_for_database has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function prepare_item_for_database( $request ) {
                $primary_property = $this->manager->get_primary_property();
    
                if ( isset( $request[ $primary_property ] ) ) {
                    $model = $this->manager->get( $request[ $primary_property ] );
    Severity: Minor
    Found in src/db-objects/rest-models-controller.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

    Function get_items_permissions_check has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

            public function get_items_permissions_check( $request ) {
                $capabilities = $this->manager->capabilities();
    
                if ( 'edit' === $request['context'] ) {
                    if ( ! $capabilities || ! $capabilities->user_can_edit() ) {
    Severity: Minor
    Found in src/db-objects/rest-models-controller.php - About 5 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_collection_params has 121 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function get_collection_params() {
                $query_params = parent::get_collection_params();
    
                $primary_property = $this->manager->get_primary_property();
                $query_object     = $this->manager->create_query_object();
    Severity: Major
    Found in src/db-objects/rest-models-controller.php - About 4 hrs to fix

      Method get_item_schema has 100 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function get_item_schema() {
                  $schema = array(
                      '$schema'    => 'http://json-schema.org/schema#',
                      'title'      => $this->manager->get_singular_slug(),
                      'type'       => 'object',
      Severity: Major
      Found in src/db-objects/rest-models-controller.php - About 4 hrs to fix

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

                public function get_collection_params() {
                    $query_params = parent::get_collection_params();
        
                    $primary_property = $this->manager->get_primary_property();
                    $query_object     = $this->manager->create_query_object();
        Severity: Minor
        Found in src/db-objects/rest-models-controller.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

        The class REST_Models_Controller has 13 public methods. Consider refactoring REST_Models_Controller to keep number of public methods under 10.
        Open

            abstract class REST_Models_Controller extends WP_REST_Controller {
                /**
                 * The manager instance.
                 *
                 * @since 1.0.0

        TooManyPublicMethods

        Since: 0.1

        A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

        By default it ignores methods starting with 'get' or 'set'.

        Example

        Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

        The class REST_Models_Controller has an overall complexity of 165 which is very high. The configured complexity threshold is 50.
        Open

            abstract class REST_Models_Controller extends WP_REST_Controller {
                /**
                 * The manager instance.
                 *
                 * @since 1.0.0

        Method get_items has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public function get_items( $request ) {
                    $registered_args = $this->get_collection_params();
        
                    $args = array();
        
        
        Severity: Major
        Found in src/db-objects/rest-models-controller.php - About 3 hrs to fix

          Function get_item_schema has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_item_schema() {
                      $schema = array(
                          '$schema'    => 'http://json-schema.org/schema#',
                          'title'      => $this->manager->get_singular_slug(),
                          'type'       => 'object',
          Severity: Minor
          Found in src/db-objects/rest-models-controller.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 get_item_permissions_check has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function get_item_permissions_check( $request ) {
                      $primary_property = $this->manager->get_primary_property();
          
                      $model = $this->manager->get( $request[ $primary_property ] );
                      if ( ! $model ) {
          Severity: Minor
          Found in src/db-objects/rest-models-controller.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 register_routes has 59 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function register_routes() {
                      register_rest_route(
                          $this->namespace,
                          '/' . $this->rest_base,
                          array(
          Severity: Major
          Found in src/db-objects/rest-models-controller.php - About 2 hrs to fix

            REST_Models_Controller has 22 functions (exceeds 20 allowed). Consider refactoring.
            Open

                abstract class REST_Models_Controller extends WP_REST_Controller {
                    /**
                     * The manager instance.
                     *
                     * @since 1.0.0
            Severity: Minor
            Found in src/db-objects/rest-models-controller.php - About 2 hrs to fix

              Method prepare_item_for_database has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      protected function prepare_item_for_database( $request ) {
                          $primary_property = $this->manager->get_primary_property();
              
                          if ( isset( $request[ $primary_property ] ) ) {
                              $model = $this->manager->get( $request[ $primary_property ] );
              Severity: Minor
              Found in src/db-objects/rest-models-controller.php - About 1 hr to fix

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

                        public function sanitize_types( $types, $request, $parameter ) {
                            $capabilities = $this->manager->capabilities();
                
                            $public_types = $this->manager->types()->get_public();
                
                
                Severity: Minor
                Found in src/db-objects/rest-models-controller.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 sanitize_statuses has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function sanitize_statuses( $statuses, $request, $parameter ) {
                            $capabilities = $this->manager->capabilities();
                
                            $public_statuses = $this->manager->statuses()->get_public();
                
                
                Severity: Minor
                Found in src/db-objects/rest-models-controller.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_item_permissions_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function update_item_permissions_check( $request ) {
                            $primary_property = $this->manager->get_primary_property();
                
                            $model = $this->manager->get( $request[ $primary_property ] );
                            if ( ! $model ) {
                Severity: Minor
                Found in src/db-objects/rest-models-controller.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 create_item_permissions_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        public function create_item_permissions_check( $request ) {
                            $primary_property = $this->manager->get_primary_property();
                
                            if ( ! empty( $request[ $primary_property ] ) ) {
                                return new WP_Error( 'rest_item_exists', $this->manager->get_message( 'rest_item_exists' ), array( 'status' => 400 ) );
                Severity: Minor
                Found in src/db-objects/rest-models-controller.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_items_permissions_check has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        public function get_items_permissions_check( $request ) {
                            $capabilities = $this->manager->capabilities();
                
                            if ( 'edit' === $request['context'] ) {
                                if ( ! $capabilities || ! $capabilities->user_can_edit() ) {
                Severity: Minor
                Found in src/db-objects/rest-models-controller.php - About 1 hr to fix

                  Function prepare_links has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function prepare_links( $model ) {
                              $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
                  
                              $primary_property = $this->manager->get_primary_property();
                  
                  
                  Severity: Minor
                  Found in src/db-objects/rest-models-controller.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 prepare_links has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          protected function prepare_links( $model ) {
                              $base = sprintf( '%s/%s', $this->namespace, $this->rest_base );
                  
                              $primary_property = $this->manager->get_primary_property();
                  
                  
                  Severity: Minor
                  Found in src/db-objects/rest-models-controller.php - About 1 hr to fix

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

                            public function prepare_item_for_response( $model, $request ) {
                                $schema = $this->get_item_schema();
                    
                                if ( method_exists( $this, 'get_fields_for_response' ) ) {
                                    $fields = $this->get_fields_for_response( $request );
                    Severity: Minor
                    Found in src/db-objects/rest-models-controller.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 create_item has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                            public function create_item( $request ) {
                                $primary_property = $this->manager->get_primary_property();
                    
                                if ( ! empty( $request[ $primary_property ] ) ) {
                                    return new WP_Error( 'rest_item_exists', $this->manager->get_message( 'rest_item_exists' ), array( 'status' => 400 ) );
                    Severity: Minor
                    Found in src/db-objects/rest-models-controller.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_item_permissions_check has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            public function get_item_permissions_check( $request ) {
                                $primary_property = $this->manager->get_primary_property();
                    
                                $model = $this->manager->get( $request[ $primary_property ] );
                                if ( ! $model ) {
                    Severity: Minor
                    Found in src/db-objects/rest-models-controller.php - About 1 hr to fix

                      Function update_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                              public function update_item( $request ) {
                                  $model = $this->prepare_item_for_database( $request );
                                  if ( is_wp_error( $model ) ) {
                                      return $model;
                                  }
                      Severity: Minor
                      Found in src/db-objects/rest-models-controller.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 delete_item has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                              public function delete_item( $request ) {
                                  $primary_property = $this->manager->get_primary_property();
                      
                                  $model = $this->manager->get( $request[ $primary_property ] );
                                  if ( ! $model ) {
                      Severity: Minor
                      Found in src/db-objects/rest-models-controller.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

                      Avoid too many return statements within this method.
                      Open

                                  return true;
                      Severity: Major
                      Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return true;
                        Severity: Major
                        Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return true;
                          Severity: Major
                          Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                            return new WP_Error( 'rest_cannot_read_item', $this->manager->get_message( 'rest_cannot_read_item' ), array( 'status' => rest_authorization_required_code() ) );
                            Severity: Major
                            Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                  return new WP_Error( 'rest_cannot_read_others_items', $this->manager->get_message( 'rest_cannot_read_others_items' ), array( 'status' => rest_authorization_required_code() ) );
                              Severity: Major
                              Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                return new WP_Error( 'rest_cannot_read_items', $this->manager->get_message( 'rest_cannot_read_items' ), array( 'status' => rest_authorization_required_code() ) );
                                Severity: Major
                                Found in src/db-objects/rest-models-controller.php - About 30 mins to fix

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

                                          public function sanitize_set_status( $status, $request, $parameter ) {
                                              $capabilities = $this->manager->capabilities();
                                  
                                              $public_statuses = $this->manager->statuses()->get_public();
                                  
                                  
                                  Severity: Minor
                                  Found in src/db-objects/rest-models-controller.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 __construct has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                          public function __construct( $manager ) {
                                              $this->manager = $manager;
                                  
                                              $prefix = $this->manager->get_prefix();
                                              if ( '_' === substr( $prefix, -1 ) ) {
                                  Severity: Minor
                                  Found in src/db-objects/rest-models-controller.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

                                  The method get_items_permissions_check() has an NPath complexity of 1080. The configured NPath complexity threshold is 200.
                                  Open

                                          public function get_items_permissions_check( $request ) {
                                              $capabilities = $this->manager->capabilities();
                                  
                                              if ( 'edit' === $request['context'] ) {
                                                  if ( ! $capabilities || ! $capabilities->user_can_edit() ) {

                                  NPathComplexity

                                  Since: 0.1

                                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                  Example

                                  class Foo {
                                      function bar() {
                                          // lots of complicated code
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                  The method get_items() has an NPath complexity of 52560. The configured NPath complexity threshold is 200.
                                  Open

                                          public function get_items( $request ) {
                                              $registered_args = $this->get_collection_params();
                                  
                                              $args = array();
                                  
                                  

                                  NPathComplexity

                                  Since: 0.1

                                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                  Example

                                  class Foo {
                                      function bar() {
                                          // lots of complicated code
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                  The method get_collection_params() has an NPath complexity of 384. The configured NPath complexity threshold is 200.
                                  Open

                                          public function get_collection_params() {
                                              $query_params = parent::get_collection_params();
                                  
                                              $primary_property = $this->manager->get_primary_property();
                                              $query_object     = $this->manager->create_query_object();

                                  NPathComplexity

                                  Since: 0.1

                                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                  Example

                                  class Foo {
                                      function bar() {
                                          // lots of complicated code
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                  The method get_item_schema() has an NPath complexity of 256. The configured NPath complexity threshold is 200.
                                  Open

                                          public function get_item_schema() {
                                              $schema = array(
                                                  '$schema'    => 'http://json-schema.org/schema#',
                                                  'title'      => $this->manager->get_singular_slug(),
                                                  'type'       => 'object',

                                  NPathComplexity

                                  Since: 0.1

                                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                                  Example

                                  class Foo {
                                      function bar() {
                                          // lots of complicated code
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#npathcomplexity

                                  The method get_collection_params() has 146 lines of code. Current threshold is set to 100. Avoid really long methods.
                                  Open

                                          public function get_collection_params() {
                                              $query_params = parent::get_collection_params();
                                  
                                              $primary_property = $this->manager->get_primary_property();
                                              $query_object     = $this->manager->create_query_object();

                                  The method get_item_schema() has 123 lines of code. Current threshold is set to 100. Avoid really long methods.
                                  Open

                                          public function get_item_schema() {
                                              $schema = array(
                                                  '$schema'    => 'http://json-schema.org/schema#',
                                                  'title'      => $this->manager->get_singular_slug(),
                                                  'type'       => 'object',

                                  The class REST_Models_Controller has 1172 lines of code. Current threshold is 1000. Avoid really long classes.
                                  Open

                                      abstract class REST_Models_Controller extends WP_REST_Controller {
                                          /**
                                           * The manager instance.
                                           *
                                           * @since 1.0.0

                                  The method get_items() has 111 lines of code. Current threshold is set to 100. Avoid really long methods.
                                  Open

                                          public function get_items( $request ) {
                                              $registered_args = $this->get_collection_params();
                                  
                                              $args = array();
                                  
                                  

                                  The method get_items() has a Cyclomatic Complexity of 25. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          public function get_items( $request ) {
                                              $registered_args = $this->get_collection_params();
                                  
                                              $args = array();
                                  
                                  

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  The method prepare_item_for_database() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          protected function prepare_item_for_database( $request ) {
                                              $primary_property = $this->manager->get_primary_property();
                                  
                                              if ( isset( $request[ $primary_property ] ) ) {
                                                  $model = $this->manager->get( $request[ $primary_property ] );

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  The method get_items_permissions_check() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          public function get_items_permissions_check( $request ) {
                                              $capabilities = $this->manager->capabilities();
                                  
                                              if ( 'edit' === $request['context'] ) {
                                                  if ( ! $capabilities || ! $capabilities->user_can_edit() ) {

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  The method get_collection_params() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          public function get_collection_params() {
                                              $query_params = parent::get_collection_params();
                                  
                                              $primary_property = $this->manager->get_primary_property();
                                              $query_object     = $this->manager->create_query_object();

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  The method get_item_schema() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          public function get_item_schema() {
                                              $schema = array(
                                                  '$schema'    => 'http://json-schema.org/schema#',
                                                  'title'      => $this->manager->get_singular_slug(),
                                                  'type'       => 'object',

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  The method get_item_permissions_check() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
                                  Open

                                          public function get_item_permissions_check( $request ) {
                                              $primary_property = $this->manager->get_primary_property();
                                  
                                              $model = $this->manager->get( $request[ $primary_property ] );
                                              if ( ! $model ) {

                                  CyclomaticComplexity

                                  Since: 0.1

                                  Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                                  Example

                                  // Cyclomatic Complexity = 11
                                  class Foo {
                                  1   public function example() {
                                  2       if ($a == $b) {
                                  3           if ($a1 == $b1) {
                                                  fiddle();
                                  4           } elseif ($a2 == $b2) {
                                                  fiddle();
                                              } else {
                                                  fiddle();
                                              }
                                  5       } elseif ($c == $d) {
                                  6           while ($c == $d) {
                                                  fiddle();
                                              }
                                  7        } elseif ($e == $f) {
                                  8           for ($n = 0; $n < $h; $n++) {
                                                  fiddle();
                                              }
                                          } else {
                                              switch ($z) {
                                  9               case 1:
                                                      fiddle();
                                                      break;
                                  10              case 2:
                                                      fiddle();
                                                      break;
                                  11              case 3:
                                                      fiddle();
                                                      break;
                                                  default:
                                                      fiddle();
                                                      break;
                                              }
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

                                  Avoid using undefined variables such as '$capabilities' which will lead to PHP notices.
                                  Open

                                                  if ( ! $capabilities || ! $capabilities->current_user_can( 'read_others_items' ) ) {

                                  UndefinedVariable

                                  Since: 2.8.0

                                  Detects when a variable is used that has not been defined before.

                                  Example

                                  class Foo
                                  {
                                      private function bar()
                                      {
                                          // $message is undefined
                                          echo $message;
                                      }
                                  }

                                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                                  Avoid using undefined variables such as '$capabilities' which will lead to PHP notices.
                                  Open

                                                  if ( ! $capabilities || ! $capabilities->current_user_can( 'read_others_items' ) ) {

                                  UndefinedVariable

                                  Since: 2.8.0

                                  Detects when a variable is used that has not been defined before.

                                  Example

                                  class Foo
                                  {
                                      private function bar()
                                      {
                                          // $message is undefined
                                          echo $message;
                                      }
                                  }

                                  Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                                  Avoid unused parameters such as '$parameter'.
                                  Open

                                          public function sanitize_author( $author, $request, $parameter ) {

                                  UnusedFormalParameter

                                  Since: 0.2

                                  Avoid passing parameters to methods or constructors and then not using those parameters.

                                  Example

                                  class Foo
                                  {
                                      private function bar($howdy)
                                      {
                                          // $howdy is not used
                                      }
                                  }

                                  Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                                  Avoid unused parameters such as '$request'.
                                  Open

                                          public function sanitize_author( $author, $request, $parameter ) {

                                  UnusedFormalParameter

                                  Since: 0.2

                                  Avoid passing parameters to methods or constructors and then not using those parameters.

                                  Example

                                  class Foo
                                  {
                                      private function bar($howdy)
                                      {
                                          // $howdy is not used
                                      }
                                  }

                                  Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

                                  Avoid unused parameters such as '$parameter'.
                                  Open

                                          public function sanitize_set_status( $status, $request, $parameter ) {

                                  UnusedFormalParameter

                                  Since: 0.2

                                  Avoid passing parameters to methods or constructors and then not using those parameters.

                                  Example

                                  class Foo
                                  {
                                      private function bar($howdy)
                                      {
                                          // $howdy is not used
                                      }
                                  }

                                  Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

                                          public function sanitize_statuses( $statuses, $request, $parameter ) {
                                              $capabilities = $this->manager->capabilities();
                                  
                                              $public_statuses = $this->manager->statuses()->get_public();
                                  
                                  
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 4 hrs to fix
                                  src/db-objects/rest-models-controller.php on lines 1171..1194

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

                                  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

                                          public function sanitize_types( $types, $request, $parameter ) {
                                              $capabilities = $this->manager->capabilities();
                                  
                                              $public_types = $this->manager->types()->get_public();
                                  
                                  
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 4 hrs to fix
                                  src/db-objects/rest-models-controller.php on lines 1136..1159

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

                                  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

                                              if ( method_exists( $this->manager, 'get_type_property' ) ) {
                                                  $type_property = $this->manager->get_type_property();
                                  
                                                  $query_params[ $type_property ] = array(
                                                      'description'       => $this->manager->get_message( 'rest_collection_type_description' ),
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 1 hr to fix
                                  src/db-objects/rest-models-controller.php on lines 1013..1026

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

                                  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

                                              if ( method_exists( $this->manager, 'get_status_property' ) ) {
                                                  $status_property = $this->manager->get_status_property();
                                  
                                                  $query_params[ $status_property ] = array(
                                                      'description'       => $this->manager->get_message( 'rest_collection_status_description' ),
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 1 hr to fix
                                  src/db-objects/rest-models-controller.php on lines 998..1011

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                              if ( method_exists( $this->manager, 'get_author_property' ) ) {
                                                  $author_property = $this->manager->get_author_property();
                                  
                                                  if ( ! empty( $request[ $author_property ] ) && get_current_user_id() !== $request[ $author_property ] && ( ! $capabilities || ! $capabilities->current_user_can( 'read_others_items' ) ) ) {
                                                      return new WP_Error( 'rest_cannot_read_others_items', $this->manager->get_message( 'rest_cannot_read_others_items' ), array( 'status' => rest_authorization_required_code() ) );
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 2 other locations - About 1 hr to fix
                                  src/db-objects/rest-models-controller.php on lines 437..443
                                  src/db-objects/rest-models-controller.php on lines 513..519

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                              if ( method_exists( $this->manager, 'get_author_property' ) ) {
                                                  $author_property = $this->manager->get_author_property();
                                  
                                                  if ( ! empty( $request[ $author_property ] ) && get_current_user_id() !== $request[ $author_property ] && ( ! $capabilities || ! $capabilities->current_user_can( 'edit_others_items' ) ) ) {
                                                      return new WP_Error( 'rest_cannot_edit_others_item', $this->manager->get_message( 'rest_cannot_edit_others_item' ), array( 'status' => rest_authorization_required_code() ) );
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 2 other locations - About 1 hr to fix
                                  src/db-objects/rest-models-controller.php on lines 212..218
                                  src/db-objects/rest-models-controller.php on lines 437..443

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

                                  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 3 locations. Consider refactoring.
                                  Open

                                              if ( method_exists( $this->manager, 'get_author_property' ) ) {
                                                  $author_property = $this->manager->get_author_property();
                                  
                                                  if ( ! empty( $request[ $author_property ] ) && get_current_user_id() !== $request[ $author_property ] && ( ! $capabilities || ! $capabilities->current_user_can( 'edit_others_items' ) ) ) {
                                                      return new WP_Error( 'rest_cannot_create_others_items', $this->manager->get_message( 'rest_cannot_create_others_items' ), array( 'status' => rest_authorization_required_code() ) );
                                  Severity: Major
                                  Found in src/db-objects/rest-models-controller.php and 2 other locations - About 1 hr to fix
                                  src/db-objects/rest-models-controller.php on lines 212..218
                                  src/db-objects/rest-models-controller.php on lines 513..519

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

                                  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

                                              if ( method_exists( $this->manager, 'get_slug_property' ) ) {
                                                  $slug_property = $this->manager->get_slug_property();
                                  
                                                  $schema['properties'][ $slug_property ] = array(
                                                      'description' => $this->manager->get_message( 'rest_item_slug_description' ),
                                  Severity: Minor
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 45 mins to fix
                                  src/db-objects/rest-models-controller.php on lines 880..891

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

                                  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

                                              if ( method_exists( $this->manager, 'get_author_property' ) ) {
                                                  $author_property = $this->manager->get_author_property();
                                  
                                                  $schema['properties'][ $author_property ] = array(
                                                      'description' => $this->manager->get_message( 'rest_item_author_description' ),
                                  Severity: Minor
                                  Found in src/db-objects/rest-models-controller.php and 1 other location - About 45 mins to fix
                                  src/db-objects/rest-models-controller.php on lines 816..827

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

                                  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

                                  Avoid excessively long variable names like $secondary_date_property. Keep variable name length under 20.
                                  Open

                                                  foreach ( $this->manager->get_secondary_date_properties() as $secondary_date_property ) {

                                  LongVariable

                                  Since: 0.2

                                  Detects when a field, formal or local variable is declared with a long name.

                                  Example

                                  class Something {
                                      protected $reallyLongIntName = -3; // VIOLATION - Field
                                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                          $otherReallyLongName = -5; // VIOLATION - Local
                                          for ($interestingIntIndex = 0; // VIOLATION - For
                                               $interestingIntIndex < 10;
                                               $interestingIntIndex++ ) {
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/naming.html#longvariable

                                  Avoid excessively long variable names like $secondary_date_property. Keep variable name length under 20.
                                  Open

                                                  foreach ( $this->manager->get_secondary_date_properties() as $secondary_date_property ) {

                                  LongVariable

                                  Since: 0.2

                                  Detects when a field, formal or local variable is declared with a long name.

                                  Example

                                  class Something {
                                      protected $reallyLongIntName = -3; // VIOLATION - Field
                                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                          $otherReallyLongName = -5; // VIOLATION - Local
                                          for ($interestingIntIndex = 0; // VIOLATION - For
                                               $interestingIntIndex < 10;
                                               $interestingIntIndex++ ) {
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/naming.html#longvariable

                                  Avoid excessively long variable names like $statuses_controller_class_name. Keep variable name length under 20.
                                  Open

                                          protected $statuses_controller_class_name = REST_Model_Statuses_Controller::class;

                                  LongVariable

                                  Since: 0.2

                                  Detects when a field, formal or local variable is declared with a long name.

                                  Example

                                  class Something {
                                      protected $reallyLongIntName = -3; // VIOLATION - Field
                                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                          $otherReallyLongName = -5; // VIOLATION - Local
                                          for ($interestingIntIndex = 0; // VIOLATION - For
                                               $interestingIntIndex < 10;
                                               $interestingIntIndex++ ) {
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/naming.html#longvariable

                                  Avoid excessively long variable names like $types_controller_class_name. Keep variable name length under 20.
                                  Open

                                          protected $types_controller_class_name = REST_Model_Types_Controller::class;

                                  LongVariable

                                  Since: 0.2

                                  Detects when a field, formal or local variable is declared with a long name.

                                  Example

                                  class Something {
                                      protected $reallyLongIntName = -3; // VIOLATION - Field
                                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                                          $otherReallyLongName = -5; // VIOLATION - Local
                                          for ($interestingIntIndex = 0; // VIOLATION - For
                                               $interestingIntIndex < 10;
                                               $interestingIntIndex++ ) {
                                          }
                                      }
                                  }

                                  Source https://phpmd.org/rules/naming.html#longvariable

                                  There are no issues that match your filters.

                                  Category
                                  Status