gocodebox/lifterlms-rest

View on GitHub
includes/abstracts/class-llms-rest-users-controller.php

Summary

Maintainability
D
2 days
Test Coverage
A
96%

Method get_item_schema_base has 163 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function get_item_schema_base() {

        $schema = array(
            '$schema'    => 'http://json-schema.org/draft-04/schema#',
            'title'      => $this->resource_name,
Severity: Major
Found in includes/abstracts/class-llms-rest-users-controller.php - About 6 hrs to fix

    File class-llms-rest-users-controller.php has 417 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Base users controller class
     *
     * @package  LifterLMS_REST/Abstracts
    Severity: Minor
    Found in includes/abstracts/class-llms-rest-users-controller.php - About 6 hrs to fix

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

          protected function check_roles_permissions( $request ) {
      
              global $wp_roles;
      
              $schema = $this->get_item_schema();
      Severity: Minor
      Found in includes/abstracts/class-llms-rest-users-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_objects_query has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function get_objects_query( $prepared, $request ) {
      
              if ( 'id' === $prepared['orderby'] ) {
                  $prepared['orderby'] = 'ID';
              } elseif ( 'registered_date' === $prepared['orderby'] ) {
      Severity: Minor
      Found in includes/abstracts/class-llms-rest-users-controller.php - About 1 hr to fix

        Method check_roles_permissions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function check_roles_permissions( $request ) {
        
                global $wp_roles;
        
                $schema = $this->get_item_schema();
        Severity: Minor
        Found in includes/abstracts/class-llms-rest-users-controller.php - About 1 hr to fix

          Method update_additional_data has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function update_additional_data( $object_id, $prepared, $request ) {
          
                  $object = $this->get_object( $object_id );
          
                  if ( is_wp_error( $object ) ) {
          Severity: Minor
          Found in includes/abstracts/class-llms-rest-users-controller.php - About 1 hr to fix

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

                protected function update_additional_data( $object_id, $prepared, $request ) {
            
                    $object = $this->get_object( $object_id );
            
                    if ( is_wp_error( $object ) ) {
            Severity: Minor
            Found in includes/abstracts/class-llms-rest-users-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 get_objects_query has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function get_objects_query( $prepared, $request ) {
            
                    if ( 'id' === $prepared['orderby'] ) {
                        $prepared['orderby'] = 'ID';
                    } elseif ( 'registered_date' === $prepared['orderby'] ) {
            Severity: Minor
            Found in includes/abstracts/class-llms-rest-users-controller.php - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            There are no issues that match your filters.

            Category
            Status