gocodebox/lifterlms-rest

View on GitHub
includes/class-llms-rest-webhooks.php

Summary

Maintainability
C
1 day
Test Coverage
A
91%

Method get_hooks has 119 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_hooks() {

        $hooks = array(

            // Courses.
Severity: Major
Found in includes/class-llms-rest-webhooks.php - About 4 hrs to fix

    File class-llms-rest-webhooks.php has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * CRUD Webhooks
     *
     * @package LifterLMS_REST/Classes
    Severity: Minor
    Found in includes/class-llms-rest-webhooks.php - About 3 hrs to fix

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

          public function get_topics() {
      
              /**
               * Filter the available webhook topics.
               *
      Severity: Minor
      Found in includes/class-llms-rest-webhooks.php - About 1 hr to fix

        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

        There are no issues that match your filters.

        Category
        Status