gocodebox/lifterlms

View on GitHub
includes/class-llms-events.php

Summary

Maintainability
B
6 hrs
Test Coverage
B
83%

Function should_track_client_events has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function should_track_client_events() {

        $ret = false;

        /**
Severity: Minor
Found in includes/class-llms-events.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 record has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function record( $args = array() ) {

        $err = new WP_Error();

        foreach ( array( 'actor_id', 'object_type', 'object_id', 'event_type', 'event_action' ) as $key ) {
Severity: Minor
Found in includes/class-llms-events.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 store_tracking_events has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    public function store_tracking_events( $tracking ) {

        $tracking = json_decode( $tracking, true );

        if ( ! empty( $tracking['nonce'] ) && wp_verify_nonce( $tracking['nonce'], 'llms-tracking' ) && get_current_user_id() ) {
Severity: Minor
Found in includes/class-llms-events.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 record has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function record( $args = array() ) {

        $err = new WP_Error();

        foreach ( array( 'actor_id', 'object_type', 'object_id', 'event_type', 'event_action' ) as $key ) {
Severity: Minor
Found in includes/class-llms-events.php - About 1 hr to fix

    Function prepare_event has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function prepare_event( $raw_event = array() ) {
    
            if ( ! isset( $raw_event['event'] ) ) {
                // Translators: %s = Event field key.
                return new WP_Error( 'llms_events_missing_event', sprintf( __( 'The event is missing the "%s" field.', 'lifterlms' ), 'event' ) );
    Severity: Minor
    Found in includes/class-llms-events.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