gocodebox/lifterlms

View on GitHub
includes/class.llms.post.relationships.php

Summary

Maintainability
B
4 hrs
Test Coverage
A
96%

Method maybe_clean_earned_engagments_related_user_post_meta has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function maybe_clean_earned_engagments_related_user_post_meta( $post_id ) {

        $post_types = array(
            'llms_my_certificate',
            'llms_my_achievement',
Severity: Minor
Found in includes/class.llms.post.relationships.php - About 1 hr to fix

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

        public function maybe_update_relationships( $post_id ) {
    
            $post = get_post( $post_id );
            if ( ! in_array( $post->post_type, $this->get_post_types(), true ) ) {
                return;
    Severity: Minor
    Found in includes/class.llms.post.relationships.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 rest_filter_products_with_active_subscriptions_error_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function rest_filter_products_with_active_subscriptions_error_message( $response, $handler, $request ) {
    
            if ( is_wp_error( $response ) ) {
                foreach ( $response->errors as $code => &$data ) {
                    // Error code can be produced by our rest-api or by wp core.
    Severity: Minor
    Found in includes/class.llms.post.relationships.php - About 35 mins to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        private function unset_relationships( $post, $data ) {
    
            $relationships = $this->get_related_posts( $post->ID, $data['post_type'], $data['meta_key'] );
    
            foreach ( $relationships as $id ) {
    Severity: Minor
    Found in includes/class.llms.post.relationships.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