felixarntz/wp-encrypt

View on GitHub
inc/WPENC/Util.php

Summary

Maintainability
C
1 day
Test Coverage

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

Method get_network_addon_domains has 37 lines of code (exceeds 25 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 1 hr to fix

    Function get_network_site_ids has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function get_network_site_ids( $global = false ) {
                $ids = array();
    
                if ( version_compare( get_bloginfo( 'version' ), '4.6', '<' ) ) {
                    $args = array();
    Severity: Minor
    Found in inc/WPENC/Util.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 get_option has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public static function get_option( $field ) {
                $options = get_site_option( 'wp_encrypt_settings', array() );
                if ( ! isset( $options[ $field ] ) ) {
                    switch ( $field ) {
                        case 'organization':
    Severity: Minor
    Found in inc/WPENC/Util.php - About 1 hr to fix

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

      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 $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 (bool) $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 '';
            Severity: Major
            Found in inc/WPENC/Util.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status