felixarntz/wp-encrypt

View on GitHub

Showing 86 of 92 total issues

Function set has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        public function set( $certs ) {
            $filesystem = Util::get_filesystem();

            $status = Util::maybe_create_letsencrypt_certificates_dir();
            if ( is_wp_error( $status ) ) {
Severity: Minor
Found in inc/WPENC/Core/Certificate.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 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

Function schedule_autogenerate_event has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        public static function schedule_autogenerate_event( $generate_timestamp = null, $reschedule = false ) {
            $timestamp = wp_next_scheduled( 'wp_encrypt_generate_certificate' );
            if ( $timestamp && $reschedule ) {
                wp_unschedule_event( $timestamp, 'wp_encrypt_generate_certificate' );
                $timestamp = false;
Severity: Minor
Found in inc/WPENC/Util.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 maybe_create_dir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        private static function maybe_create_dir( $path ) {
            $filesystem = self::get_filesystem();

            if ( ! $filesystem->is_dir( $path ) ) {
                if ( ! $filesystem->is_dir( dirname( $path ) ) ) {
Severity: Minor
Found in inc/WPENC/Core/Util.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

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

        public function check_valid( $options ) {
            $required_fields = array( 'country_code', 'country_name', 'organization' );
            $valid = true;
            foreach ( $required_fields as $required_field ) {
                if ( ! isset( $options[ $required_field ] ) || empty( $options[ $required_field ] ) ) {
Severity: Minor
Found in inc/WPENC/Admin.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 get_network_domain has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get_network_domain( $network_id = null ) {
            if ( version_compare( get_bloginfo( 'version' ), '4.6', '<' ) ) {
                if ( ! $network_id ) {
                    $network = get_current_site();
                } else {
Severity: Minor
Found in inc/WPENC/Util.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 request has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

        public function request( $endpoint, $method = 'GET', $data = null ) {
            if ( is_array( $data ) ) {
                $data = json_encode( $data );
            }

Severity: Minor
Found in inc/WPENC/Core/Client.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

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 $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 new WP_Error( 'csr_cannot_write', sprintf( __( 'Could not write CSR into file <code>%s</code>. Please check your filesystem permissions.', 'wp-encrypt' ), $this->path . '/last.csr' ) );
      Severity: Major
      Found in inc/WPENC/Core/Certificate.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 absint( $options[ $field ] );
            Severity: Major
            Found in inc/WPENC/Util.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 $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 $options[ $field ];
                  Severity: Major
                  Found in inc/WPENC/Util.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( 'private_key_cannot_write', sprintf( __( 'Could not write private key into file <code>%s</code>. Please check your filesystem permissions.', 'wp-encrypt' ), $this->path . '/' . self::PRIVATE_NAME ) );
                      Severity: Major
                      Found in inc/WPENC/Core/KeyPair.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return true;
                        Severity: Major
                        Found in inc/WPENC/Core/Certificate.php - About 30 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language