felixarntz/wp-encrypt

View on GitHub

Showing 86 of 92 total issues

Function render_page has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring.
Open

        public function render_page() {
            if ( CoreUtil::needs_filesystem_credentials() ) {
                ?>
                <div class="notice notice-warning">
                    <p><?php printf( __( 'The directories %1$s and %2$s that WP Encrypt needs access to are not automatically writable by the site. Unless you change this, it is not possible to auto-renew certificates.', 'wp-encrypt' ), '<code>' . CoreUtil::get_letsencrypt_certificates_dir_path() . '</code>', '<code>' . CoreUtil::get_letsencrypt_challenges_dir_path() . '</code>' ); ?></p>
Severity: Minor
Found in inc/WPENC/Admin.php - About 7 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

File Admin.php has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WPENC\Admin class
 *
 * @package WPENC
Severity: Minor
Found in inc/WPENC/Admin.php - About 7 hrs to fix

    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 render_page has 127 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public function render_page() {
                if ( CoreUtil::needs_filesystem_credentials() ) {
                    ?>
                    <div class="notice notice-warning">
                        <p><?php printf( __( 'The directories %1$s and %2$s that WP Encrypt needs access to are not automatically writable by the site. Unless you change this, it is not possible to auto-renew certificates.', 'wp-encrypt' ), '<code>' . CoreUtil::get_letsencrypt_certificates_dir_path() . '</code>', '<code>' . CoreUtil::get_letsencrypt_challenges_dir_path() . '</code>' ); ?></p>
    Severity: Major
    Found in inc/WPENC/Admin.php - About 5 hrs to fix

      Function get_network_addon_domains has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function get_network_addon_domains( $network_id = null, $global = false ) {
                  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 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

      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

      Function setup_filesystem has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function setup_filesystem( $form_post, $extra_fields = array() ) {
                  global $wp_filesystem;
      
                  $paths = self::get_filesystem_paths();
                  $type = 'direct';
      Severity: Minor
      Found in inc/WPENC/Core/Util.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

      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

        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

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

                  public function generate() {
                      $filesystem = Util::get_filesystem();
          
                      $status = Util::maybe_create_letsencrypt_certificates_dir();
                      if ( is_wp_error( $status ) ) {
          Severity: Minor
          Found in inc/WPENC/Core/KeyPair.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 render_settings_field has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function render_settings_field( $args = array() ) {
                      $value = Util::get_option( $args['id'] );
          
                      $type = 'text';
                      $more_args = '';
          Severity: Minor
          Found in inc/WPENC/Admin.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

          Method render_settings_field has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function render_settings_field( $args = array() ) {
                      $value = Util::get_option( $args['id'] );
          
                      $type = 'text';
                      $more_args = '';
          Severity: Minor
          Found in inc/WPENC/Admin.php - About 1 hr to fix

            Method generate_csr has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function generate_csr( $key_resource, $domains, $dn = array() ) {
                        $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 1 hr to fix

              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 signed_request has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      public function signed_request( $endpoint, $data = null ) {
                          $account_keypair = AccountKeyPair::get();
              
                          $account_key_resource = $account_keypair->read_private();
                          if ( is_wp_error( $account_key_resource ) ) {
              Severity: Minor
              Found in inc/WPENC/Core/Client.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 signed_request has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      public function signed_request( $endpoint, $data = null ) {
                          $account_keypair = AccountKeyPair::get();
              
                          $account_key_resource = $account_keypair->read_private();
                          if ( is_wp_error( $account_key_resource ) ) {
              Severity: Minor
              Found in inc/WPENC/Core/Client.php - About 1 hr to fix

                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 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

                Severity
                Category
                Status
                Source
                Language