felixarntz/wp-encrypt

View on GitHub

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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  public function get_private( $force_refresh = false ) {
                      $filesystem = Util::get_filesystem();
          
                      if ( null === $this->private_key || $force_refresh ) {
                          $path = $this->path . '/' . self::PRIVATE_NAME;
          Severity: Major
          Found in inc/WPENC/Core/KeyPair.php and 1 other location - About 2 hrs to fix
          inc/WPENC/Core/KeyPair.php on lines 176..187

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 128.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  public function get_public( $force_refresh = false ) {
                      $filesystem = Util::get_filesystem();
          
                      if ( null === $this->public_key || $force_refresh ) {
                          $path = $this->path . '/' . self::PUBLIC_NAME;
          Severity: Major
          Found in inc/WPENC/Core/KeyPair.php and 1 other location - About 2 hrs to fix
          inc/WPENC/Core/KeyPair.php on lines 198..209

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 128.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          var readmeheader =    'Plugin Name:       ' + config.pluginName + '\n' +
                              'Plugin URI:        ' + config.pluginURI + '\n' +
                              'Author:            ' + config.author + '\n' +
                              'Author URI:        ' + config.authorURI + '\n' +
                              'Contributors:      ' + config.contributors + '\n' +
          Severity: Major
          Found in gulpfile.js and 1 other location - About 2 hrs to fix
          gulpfile.js on lines 46..51

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          var pluginheader =     'Plugin Name: ' + config.pluginName + '\n' +
                              'Plugin URI:  ' + config.pluginURI + '\n' +
                              'Description: ' + config.description + '\n' +
                              'Version:     ' + config.version + '\n' +
                              'Author:      ' + config.author + '\n' +
          Severity: Major
          Found in gulpfile.js and 1 other location - About 2 hrs to fix
          gulpfile.js on lines 59..64

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 78.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          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

              Severity
              Category
              Status
              Source
              Language