gocodebox/lifterlms-rest

View on GitHub
includes/server/class-llms-rest-access-plans-controller.php

Summary

Maintainability
D
2 days
Test Coverage
A
90%

Function update_additional_object_fields has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    protected function update_additional_object_fields( $access_plan, $request, $schema, $prepared_item, $creating = true ) {

        $error = new WP_Error();

        // Will contain the properties to set.
Severity: Minor
Found in includes/server/class-llms-rest-access-plans-controller.php - About 4 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

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

<?php
/**
 * REST Access Plans Controller
 *
 * @package LifterLMS_REST/Classes/Controllers
Severity: Minor
Found in includes/server/class-llms-rest-access-plans-controller.php - About 4 hrs to fix

    Method update_additional_object_fields has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function update_additional_object_fields( $access_plan, $request, $schema, $prepared_item, $creating = true ) {
    
            $error = new WP_Error();
    
            // Will contain the properties to set.
    Severity: Major
    Found in includes/server/class-llms-rest-access-plans-controller.php - About 3 hrs to fix

      Method prepare_object_for_response has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function prepare_object_for_response( $access_plan, $request ) {
      
              $data    = parent::prepare_object_for_response( $access_plan, $request );
              $context = $request->get_param( 'context' );
      
      
      Severity: Major
      Found in includes/server/class-llms-rest-access-plans-controller.php - About 2 hrs to fix

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

            protected function prepare_object_for_response( $access_plan, $request ) {
        
                $data    = parent::prepare_object_for_response( $access_plan, $request );
                $context = $request->get_param( 'context' );
        
        
        Severity: Minor
        Found in includes/server/class-llms-rest-access-plans-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 unset_subordinate_props has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private function unset_subordinate_props( &$to_set, $saved_props ) {
        
                // Merge new properties to set and saved props.
                $props = wp_parse_args( $to_set, $saved_props );
        
        
        Severity: Minor
        Found in includes/server/class-llms-rest-access-plans-controller.php - About 55 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Method update_additional_object_fields has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            protected function update_additional_object_fields( $access_plan, $request, $schema, $prepared_item, $creating = true ) {
        Severity: Minor
        Found in includes/server/class-llms-rest-access-plans-controller.php - About 35 mins to fix

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

              private function related_product_permissions_check( $has_permissions, $request ) {
          
                  if ( llms_rest_is_authorization_required_error( $has_permissions ) ) {
          
                      // `id` required on "reading/updating", `post_id` required on "creating".
          Severity: Minor
          Found in includes/server/class-llms-rest-access-plans-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

          There are no issues that match your filters.

          Category
          Status