felixarntz/wp-encrypt

View on GitHub
inc/WPENC/ActionHandler.php

Summary

Maintainability
C
1 day
Test Coverage

Function handle_request has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

        protected function handle_request( $mode = 'admin' ) {
            $ajax = false;
            $prefix = 'admin_action_wpenc_';
            $args = $_REQUEST;

Severity: Minor
Found in inc/WPENC/ActionHandler.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 maybe_request_filesystem_credentials has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        protected function maybe_request_filesystem_credentials( $network_wide = false ) {
            if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
                $credentials = array();

                $fields = array( 'hostname', 'port', 'username', 'password', 'public_key', 'private_key', 'connection_type' );
Severity: Minor
Found in inc/WPENC/ActionHandler.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 handle_request has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function handle_request( $mode = 'admin' ) {
            $ajax = false;
            $prefix = 'admin_action_wpenc_';
            $args = $_REQUEST;

Severity: Minor
Found in inc/WPENC/ActionHandler.php - About 1 hr to fix

    Function check_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function check_request( $action, $mode = 'admin', $args = array() ) {
                if ( ! isset( $args['_wpnonce'] ) ) {
                    return new WP_Error( 'nonce_missing', __( 'Missing nonce.', 'wp-encrypt' ) );
                }
    
    
    Severity: Minor
    Found in inc/WPENC/ActionHandler.php - About 55 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_account has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function register_account( $data = array(), $network_wide = false ) {
                $filesystem_check = $this->maybe_request_filesystem_credentials( $network_wide );
                if ( false === $filesystem_check ) {
                    return new WP_Error( 'invalid_filesystem_credentials', __( 'Invalid or missing filesystem credentials.', 'wp-encrypt' ), 'error' );
                }
    Severity: Minor
    Found in inc/WPENC/ActionHandler.php - About 45 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 generate_certificate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function generate_certificate( $data = array(), $network_wide = false ) {
                if ( ! Util::can_generate_certificate() ) {
                    return new WP_Error( 'domain_cannot_sign', __( 'Domain cannot be signed. Either the account is not registered yet or the settings are not valid.', 'wp-encrypt' ) );
                }
    
    
    Severity: Minor
    Found in inc/WPENC/ActionHandler.php - About 45 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

    Avoid too many return statements within this method.
    Open

                return true;
    Severity: Major
    Found in inc/WPENC/ActionHandler.php - About 30 mins to fix

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

              protected function revoke_certificate( $data = array(), $network_wide = false ) {
                  $filesystem_check = $this->maybe_request_filesystem_credentials( $network_wide );
                  if ( false === $filesystem_check ) {
                      return new WP_Error( 'invalid_filesystem_credentials', __( 'Invalid or missing filesystem credentials.', 'wp-encrypt' ), 'error' );
                  }
      Severity: Minor
      Found in inc/WPENC/ActionHandler.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