felixarntz/wp-encrypt

View on GitHub
inc/WPENC/Admin.php

Summary

Maintainability
F
3 days
Test Coverage

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

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

                protected function render_apache_instructions( $site_domain, $site_dir, $certificate_dirs ) {
                    $config = '<VirtualHost 192.168.0.1:443>
        DocumentRoot ' . untrailingslashit( $site_dir ) . '
        ServerName ' . $site_domain . '
        SSLEngine on
        Severity: Minor
        Found in inc/WPENC/Admin.php - About 1 hr to fix

          Function validate_settings has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function validate_settings( $options = array() ) {
                      $options = array_map( 'strip_tags', array_map( 'trim', $options ) );
          
                      if ( isset( $options['country_code'] ) ) {
                          $options['country_code'] = strtoupper( substr( $options['country_code'], 0, 2 ) );
          Severity: Minor
          Found in inc/WPENC/Admin.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_show_expire_warning has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                  public function maybe_show_expire_warning() {
                      if ( ! Util::get_option( 'show_warning' ) ) {
                          return;
                      }
          
          
          Severity: Minor
          Found in inc/WPENC/Admin.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 maybe_show_expire_warning has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  public function maybe_show_expire_warning() {
                      if ( ! Util::get_option( 'show_warning' ) ) {
                          return;
                      }
          
          
          Severity: Minor
          Found in inc/WPENC/Admin.php - About 1 hr to fix

            Method render_help_getting_started has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    public function render_help_getting_started() {
                        ?>
                        <p><?php _e( 'To obtain your first SSL certificate, follow these steps:', 'wp-encrypt' ); ?></p>
            
                        <ol>
            Severity: Minor
            Found in inc/WPENC/Admin.php - About 1 hr to fix

              Method render_nginx_instructions has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      protected function render_nginx_instructions( $site_domain, $site_dir, $certificate_dirs ) {
                          $config = 'server {
              
                  listen   443;
              
              
              Severity: Minor
              Found in inc/WPENC/Admin.php - About 1 hr to fix

                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

                There are no issues that match your filters.

                Category
                Status