felixarntz/wp-encrypt

View on GitHub
inc/WPENC/Core/Challenge.php

Summary

Maintainability
C
1 day
Test Coverage

Function validate has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

        public static function validate( $domain, $account_key_details ) {
            $filesystem = Util::get_filesystem();

            $status = Util::maybe_create_letsencrypt_challenges_dir();
            if ( is_wp_error( $status ) ) {
Severity: Minor
Found in inc/WPENC/Core/Challenge.php - About 3 hrs 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 validate has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static function validate( $domain, $account_key_details ) {
            $filesystem = Util::get_filesystem();

            $status = Util::maybe_create_letsencrypt_challenges_dir();
            if ( is_wp_error( $status ) ) {
Severity: Major
Found in inc/WPENC/Core/Challenge.php - About 2 hrs to fix

    Avoid too many return statements within this method.
    Open

                        return new WP_Error( 'challenge_remote_check_failed', sprintf( __( 'Challenge remote check failed for domain %s.', 'wp-encrypt' ), $domain ) );
    Severity: Major
    Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                      return new WP_Error( 'challenge_request_failed', sprintf( __( 'Challenge request failed for domain %s.', 'wp-encrypt' ), $domain ) );
      Severity: Major
      Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return new WP_Error( 'challenge_cannot_write_file', sprintf( __( 'Could not write challenge to file <code>%s</code>. Please check your filesystem permissions.', 'wp-encrypt' ), $token_path ) );
        Severity: Major
        Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return new WP_Error( 'challenge_self_check_failed', sprintf( __( 'Challenge self check failed for domain %s.', 'wp-encrypt' ), $domain ) );
          Severity: Major
          Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

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

              Avoid too many return statements within this method.
              Open

                              return new WP_Error( 'challenge_cannot_create_dir', sprintf( __( 'Could not create challenge directory <code>%s</code>. Please check your filesystem permissions.', 'wp-encrypt' ), $directory ) );
              Severity: Major
              Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return new WP_Error( 'challenge_remote_check_failed', sprintf( __( 'Challenge remote check failed for domain %s.', 'wp-encrypt' ), $domain ) );
                Severity: Major
                Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return false;
                  Severity: Major
                  Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return new WP_Error( 'no_challenge_available', sprintf( __( 'No HTTP challenge available for domain %1$s. Original response: %2$s', 'wp-encrypt' ), $domain, json_encode( $response ) ) );
                    Severity: Major
                    Found in inc/WPENC/Core/Challenge.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status