gocodebox/lifterlms-rest

View on GitHub

Showing 156 of 191 total issues

Avoid too many return statements within this method.
Open

        return 0;
Severity: Major
Found in includes/abstracts/class-llms-rest-controller-stubs.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return true;
    Severity: Major
    Found in includes/models/class-llms-rest-webhook.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return $user_id;
      Severity: Major
      Found in includes/class-llms-rest-authentication.php - About 30 mins to fix

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

            protected function maybe_add_removed_filters_for_response( $filters_removed ) {
        
                if ( ! empty( $filters_removed ) ) {
                    foreach ( $filters_removed as $hook => $filters ) {
                        foreach ( $filters as $filter_data ) {
        Severity: Minor
        Found in includes/abstracts/class-llms-rest-posts-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 is_data_valid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function is_data_valid( $data ) {
        
                // Validate Status.
                if ( isset( $data['status'] ) && ! in_array( $data['status'], array_keys( $this->get_statuses() ), true ) ) {
                    // Translators: %s = Invalid permission string.
        Severity: Minor
        Found in includes/class-llms-rest-webhooks.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function save( $obj, $data ) {
        
                if ( isset( $data['delivery_url'] ) && ( ! $obj->exists() || $obj->exists() && $data['delivery_url'] !== $obj->get( 'delivery_url' ) ) ) {
                    $obj->set( 'delivery_url', $data['delivery_url'] );
                    $ping = $obj->ping();
        Severity: Minor
        Found in includes/class-llms-rest-webhooks.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 prepare_collection_items_for_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function prepare_collection_items_for_response( $objects, $request ) {
        
                $items = array();
        
                foreach ( $objects as $object ) {
        Severity: Minor
        Found in includes/abstracts/class-llms-rest-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 get_objects_query_pre has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_objects_query_pre( $query ) {
        
                $query->query_where .= ' Having 1 ';
        
                if ( ! empty( $this->prepared_query_args['enrolled_in'] ) ) {
        Severity: Minor
        Found in includes/server/class-llms-rest-students-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 update_object has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function update_object( $prepared, $request ) {
        
                if ( in_array( get_post_type( $prepared['post_id'] ), array( 'course', 'section' ), true ) ) {
                    $post    = llms_get_post( $prepared['post_id'] );
                    $lessons = $post->get_lessons( 'ids' );
        Severity: Minor
        Found in includes/server/class-llms-rest-students-progress-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 create_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function create_item( $request ) {
        
                $user_id = (int) $request['id'];
                $post_id = (int) $request['post_id'];
        
        
        Severity: Minor
        Found in includes/server/class-llms-rest-enrollments-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 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

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

            protected function prepare_collection_query_args( $request ) {
        
                $query_args = parent::prepare_collection_query_args( $request );
                if ( is_wp_error( $query_args ) ) {
                    return $query_args;
        Severity: Minor
        Found in includes/server/class-llms-rest-sections-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 prepare_collection_items_for_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function prepare_collection_items_for_response( $objects, $request ) {
        
                $items = array();
        
                foreach ( $objects as $object ) {
        Severity: Minor
        Found in includes/server/class-llms-rest-enrollments-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 prepare_collection_query_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function prepare_collection_query_args( $request ) {
        
                $query_args = parent::prepare_collection_query_args( $request );
                if ( is_wp_error( $query_args ) ) {
                    return $query_args;
        Severity: Minor
        Found in includes/server/class-llms-rest-lessons-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 handle_terms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function handle_terms( $object_id, $request ) {
        
                $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_llms_rest' => true ) );
        
                foreach ( $taxonomies as $taxonomy ) {
        Severity: Minor
        Found in includes/abstracts/class-llms-rest-posts-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 is_data_valid has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function is_data_valid( $data ) {
        
                // First conditions prevents '', '0', 0, etc... & second prevents invalid / non existant user ids.
                if ( ( isset( $data['user_id'] ) && empty( $data['user_id'] ) ) || ( ! empty( $data['user_id'] ) && ! get_user_by( 'id', $data['user_id'] ) ) ) {
                    // Translators: %s = Invalid user id.
        Severity: Minor
        Found in includes/class-llms-rest-api-keys.php - About 25 mins to fix

        Cognitive Complexity

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

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

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

        Further reading

        Severity
        Category
        Status
        Source
        Language