felixarntz/plugin-lib

View on GitHub
src/ajax.php

Summary

Maintainability
A
2 hrs
Test Coverage

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

        public function request() {
            $request_data = wp_unslash( $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification

            $name = str_replace( $this->get_prefix(), '', $request_data['action'] );

Severity: Minor
Found in src/ajax.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 get_nonce has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        public function get_nonce( $action ) {
            if ( ! isset( $this->ajax_actions[ $action ] ) ) {
                return '';
            }

Severity: Minor
Found in src/ajax.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 add_ajax_actions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        protected function add_ajax_actions() {
            if ( ! wp_doing_ajax() ) {
                return;
            }

Severity: Minor
Found in src/ajax.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 register_action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        public function register_action( $name, $callback, $args = array() ) {
            if ( doing_action( 'admin_init' ) || did_action( 'admin_init' ) ) {
                return new WP_Error( 'ajax_registered_too_late', sprintf( $this->get_translation( 'ajax_registered_too_late' ), '<code>admin_init</code>' ) );
            }

Severity: Minor
Found in src/ajax.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