felixarntz/wp-encrypt

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

Summary

Maintainability
D
2 days
Test Coverage

Function generate_certificate has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

        public function generate_certificate( $domain, $addon_domains = array(), $dn_args = array() ) {
            $account_keypair = AccountKeyPair::get();

            $account_key_details = $account_keypair->get_private_details();
            if ( is_wp_error( $account_key_details ) ) {
Severity: Minor
Found in inc/WPENC/Core/CertificateManager.php - About 5 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 generate_certificate has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function generate_certificate( $domain, $addon_domains = array(), $dn_args = array() ) {
            $account_keypair = AccountKeyPair::get();

            $account_key_details = $account_keypair->get_private_details();
            if ( is_wp_error( $account_key_details ) ) {
Severity: Major
Found in inc/WPENC/Core/CertificateManager.php - About 2 hrs to fix

    Function reset has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

            public function reset() {
                $filesystem = Util::get_filesystem();
    
                $paths = array(
                    Util::get_letsencrypt_certificates_dir_path(),
    Severity: Minor
    Found in inc/WPENC/Core/CertificateManager.php - About 2 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

    Function register_account has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            public function register_account() {
                $account_keypair = AccountKeyPair::get();
                if ( ! $account_keypair->exists() ) {
                    $status = $account_keypair->generate();
                    if ( is_wp_error( $status ) ) {
    Severity: Minor
    Found in inc/WPENC/Core/CertificateManager.php - About 2 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

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

            private function parse_wp_error( $response, $code = false, $message = false, $data = '' ) {
                if ( ! $code ) {
                    $code = 'letsencrypt_error';
                }
    
    
    Severity: Minor
    Found in inc/WPENC/Core/CertificateManager.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 revoke_certificate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            public function revoke_certificate( $domain ) {
                $certificate = Certificate::get( $domain );
                if ( ! $certificate->exists() ) {
                    return new WP_Error( 'cert_not_exist', sprintf( __( 'The certificate <code>%s</code> does not exist.', 'wp-encrypt' ), $domain_path . '/cert.pem' ) );
                }
    Severity: Minor
    Found in inc/WPENC/Core/CertificateManager.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 $result;
    Severity: Major
    Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                          return $result;
      Severity: Major
      Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return $status;
        Severity: Major
        Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $this->parse_wp_error( $result, 'new_cert_invalid_response_code', __( 'Invalid response code for new certificate request.', 'wp-encrypt' ) );
          Severity: Major
          Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return $csr;
            Severity: Major
            Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return new WP_Error( 'new_cert_fail', __( 'No certificates generated.', 'wp-encrypt' ) );
              Severity: Major
              Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return array(
                                'domains'    => $all_domains,
                            );
                Severity: Major
                Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

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

                    Avoid too many return statements within this method.
                    Open

                                                return $result;
                    Severity: Major
                    Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return $this->parse_wp_error( $result, 'new_cert_invalid_response_code', __( 'Invalid response code for new certificate request.', 'wp-encrypt' ) );
                      Severity: Major
                      Found in inc/WPENC/Core/CertificateManager.php - About 30 mins to fix

                        There are no issues that match your filters.

                        Category
                        Status