connectors/class-connector-settings.php

Summary

Maintainability
F
4 days
Test Coverage
F
51%

File class-connector-settings.php has 541 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Connector for Settings
 *
 * @package WP_Stream
Severity: Major
Found in connectors/class-connector-settings.php - About 1 day to fix

    Function action_links has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        public function action_links( $links, $record ) {
            $context_labels = $this->get_context_labels();
            $plugin         = wp_stream_get_instance();
    
            $rules = array(
    Severity: Minor
    Found in connectors/class-connector-settings.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 action_links has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function action_links( $links, $record ) {
            $context_labels = $this->get_context_labels();
            $plugin         = wp_stream_get_instance();
    
            $rules = array(
    Severity: Major
    Found in connectors/class-connector-settings.php - About 4 hrs to fix

      Method register has 98 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function register() {
              parent::register();
      
              $this->labels = array(
                  // General.
      Severity: Major
      Found in connectors/class-connector-settings.php - About 3 hrs to fix

        Connector_Settings has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Connector_Settings extends Connector {
            /**
             * Prefix for the highlight URL hash
             *
             * @const string
        Severity: Minor
        Found in connectors/class-connector-settings.php - About 2 hrs to fix

          Method callback_updated_option has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function callback_updated_option( $option, $old_value, $value ) {
                  global $whitelist_options, $new_whitelist_options;
          
                  if ( $this->is_option_ignored( $option ) ) {
                      return;
          Severity: Major
          Found in connectors/class-connector-settings.php - About 2 hrs to fix

            Method highlight_field has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function highlight_field() {
                    ?>
                    <script>
                        (function ($) {
                            $(function () {
            Severity: Minor
            Found in connectors/class-connector-settings.php - About 2 hrs to fix

              Function callback_updated_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function callback_updated_option( $option, $old_value, $value ) {
                      global $whitelist_options, $new_whitelist_options;
              
                      if ( $this->is_option_ignored( $option ) ) {
                          return;
              Severity: Minor
              Found in connectors/class-connector-settings.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

              Avoid deeply nested control flow statements.
              Open

                                      if ( '' === $field_name ) {
                                          $field_name = $record->get_meta( 'option', true );
                                      }
              Severity: Major
              Found in connectors/class-connector-settings.php - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if ( '' !== $field_name ) {
                                            $url = sprintf( '%s#%s%s', rtrim( preg_replace( '/#.*/', '', $url ), '/' ), self::HIGHLIGHT_FIELD_URL_HASH_PREFIX, $field_name );
                                        }
                Severity: Major
                Found in connectors/class-connector-settings.php - About 45 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return call_user_func( $rule['applicable'], $submenu, $record );
                  Severity: Major
                  Found in connectors/class-connector-settings.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return $links;
                    Severity: Major
                    Found in connectors/class-connector-settings.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return sprintf( 'options-%s.php', $record->context );
                      Severity: Major
                      Found in connectors/class-connector-settings.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return ! empty( $submenu['options-general.php'] );
                        Severity: Major
                        Found in connectors/class-connector-settings.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                              return admin_url( $rule['submenu_slug']( $record ) );
                          Severity: Major
                          Found in connectors/class-connector-settings.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                return network_admin_url( $rule['menu_slug'] );
                            Severity: Major
                            Found in connectors/class-connector-settings.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                      return ! empty( $submenu['settings.php'] );
                              Severity: Major
                              Found in connectors/class-connector-settings.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                    return in_array( $record->context, array( 'custom_header', 'custom_background' ), true );
                                Severity: Major
                                Found in connectors/class-connector-settings.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return 'settings.php';
                                  Severity: Major
                                  Found in connectors/class-connector-settings.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                        return false;
                                    Severity: Major
                                    Found in connectors/class-connector-settings.php - About 30 mins to fix

                                      Function get_context_by_key has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function get_context_by_key( $option_name, $key ) {
                                              $contexts = array(
                                                  'theme_mods' => array(
                                                      'custom_background' => array(
                                                          'background_image',
                                      Severity: Minor
                                      Found in connectors/class-connector-settings.php - About 25 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