felixarntz/wp-site-identity

View on GitHub
src/class-wp-site-identity-bootstrap-customizer.php

Summary

Maintainability
D
2 days
Test Coverage

File class-wp-site-identity-bootstrap-customizer.php has 372 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WP_Site_Identity_Bootstrap_Customizer class
 *
 * @package WPSiteIdentity
Severity: Minor
Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 hrs to fix

    Function set_default_control_args_for_setting has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        private function set_default_control_args_for_setting( array $control_args, WP_Site_Identity_Setting $setting ) {
            $type = $setting->get_type();
    
            switch ( $type ) {
                case 'boolean':
    Severity: Minor
    Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 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 add_owner_data_content has 102 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function add_owner_data_content( $wp_customize, $setting_registry, $panel_slug ) {
            $registry     = $setting_registry->get_setting( 'owner_data' );
            $data         = $this->plugin->owner_data();
            $section_slug = 'owner_data';
    
    
    Severity: Major
    Found in src/class-wp-site-identity-bootstrap-customizer.php - About 4 hrs to fix

      The class WP_Site_Identity_Bootstrap_Customizer has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
      Open

      final class WP_Site_Identity_Bootstrap_Customizer {
      
          /**
           * Plugin bootstrap instance.
           *

      Method add_brand_data_content has 69 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function add_brand_data_content( $wp_customize, $setting_registry, $panel_slug ) {
              $registry     = $setting_registry->get_setting( 'brand_data' );
              $data         = $this->plugin->brand_data();
              $section_slug = 'brand_data';
      
      
      Severity: Major
      Found in src/class-wp-site-identity-bootstrap-customizer.php - About 2 hrs to fix

        Method set_default_control_args_for_setting has 58 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function set_default_control_args_for_setting( array $control_args, WP_Site_Identity_Setting $setting ) {
                $type = $setting->get_type();
        
                switch ( $type ) {
                    case 'boolean':
        Severity: Major
        Found in src/class-wp-site-identity-bootstrap-customizer.php - About 2 hrs to fix

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

              private function add_owner_data_content( $wp_customize, $setting_registry, $panel_slug ) {
                  $registry     = $setting_registry->get_setting( 'owner_data' );
                  $data         = $this->plugin->owner_data();
                  $section_slug = 'owner_data';
          
          
          Severity: Minor
          Found in src/class-wp-site-identity-bootstrap-customizer.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 add_brand_data_content has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function add_brand_data_content( $wp_customize, $setting_registry, $panel_slug ) {
                  $registry     = $setting_registry->get_setting( 'brand_data' );
                  $data         = $this->plugin->brand_data();
                  $section_slug = 'brand_data';
          
          
          Severity: Minor
          Found in src/class-wp-site-identity-bootstrap-customizer.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

          The method add_owner_data_content() has 127 lines of code. Current threshold is set to 100. Avoid really long methods.
          Open

              private function add_owner_data_content( $wp_customize, $setting_registry, $panel_slug ) {
                  $registry     = $setting_registry->get_setting( 'owner_data' );
                  $data         = $this->plugin->owner_data();
                  $section_slug = 'owner_data';
          
          

          The method set_default_control_args_for_setting() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
          Open

              private function set_default_control_args_for_setting( array $control_args, WP_Site_Identity_Setting $setting ) {
                  $type = $setting->get_type();
          
                  switch ( $type ) {
                      case 'boolean':

          CyclomaticComplexity

          Since: 0.1

          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

          Example

          // Cyclomatic Complexity = 11
          class Foo {
          1   public function example() {
          2       if ($a == $b) {
          3           if ($a1 == $b1) {
                          fiddle();
          4           } elseif ($a2 == $b2) {
                          fiddle();
                      } else {
                          fiddle();
                      }
          5       } elseif ($c == $d) {
          6           while ($c == $d) {
                          fiddle();
                      }
          7        } elseif ($e == $f) {
          8           for ($n = 0; $n < $h; $n++) {
                          fiddle();
                      }
                  } else {
                      switch ($z) {
          9               case 1:
                              fiddle();
                              break;
          10              case 2:
                              fiddle();
                              break;
          11              case 3:
                              fiddle();
                              break;
                          default:
                              fiddle();
                              break;
                      }
                  }
              }
          }

          Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

          Missing class import via use statement (line '414', column '39').
          Open

                              $control                   = new WP_Customize_Media_Control( $wp_customize, $setting_name, $control_args );

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '279', column '20').
          Open

                          $control = new WP_Customize_Control( $wp_customize, $setting_name, $control_args );

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '419', column '34').
          Open

                              $control              = new WP_Customize_Color_Control( $wp_customize, $setting_name, $control_args );

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '421', column '21').
          Open

                              $control = new WP_Customize_Control( $wp_customize, $setting_name, $control_args );

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Avoid unused local variables such as '$validated_value'.
          Open

                      $validated_value = $setting_registry->validator()->validate( $value, $setting );

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

          Avoid unused local variables such as '$data'.
          Open

                  $data         = $this->plugin->brand_data();

          UnusedLocalVariable

          Since: 0.2

          Detects when a local variable is declared and/or assigned, but not used.

          Example

          class Foo {
              public function doSomething()
              {
                  $i = 5; // Unused
              }
          }

          Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

          Avoid excessively long variable names like $address_single_settings. Keep variable name length under 20.
          Open

                  $address_single_settings = $address_fields;

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $aggregate_setting_name. Keep variable name length under 20.
          Open

              private function print_partial( $aggregate_setting_name, $setting_name ) {

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $address_multi_settings. Keep variable name length under 20.
          Open

                  $address_multi_settings  = $address_fields;

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $aggregate_setting_name. Keep variable name length under 20.
          Open

                  $aggregate_setting_name = $matches[2];

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $custom_css_properties. Keep variable name length under 20.
          Open

                      $custom_css_properties = array_filter( array_combine( $css_properties, $colors ) );

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $aggregate_setting_name. Keep variable name length under 20.
          Open

              private function validate_setting( $validity, $value, $aggregate_setting_name, $setting_name ) {

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $aggregate_setting_name. Keep variable name length under 20.
          Open

              private function sanitize_setting( $value, $aggregate_setting_name, $setting_name ) {

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          Avoid excessively long variable names like $title_tagline_section. Keep variable name length under 20.
          Open

                  $title_tagline_section = $wp_customize->get_section( 'title_tagline' );

          LongVariable

          Since: 0.2

          Detects when a field, formal or local variable is declared with a long name.

          Example

          class Something {
              protected $reallyLongIntName = -3; // VIOLATION - Field
              public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                  $otherReallyLongName = -5; // VIOLATION - Local
                  for ($interestingIntIndex = 0; // VIOLATION - For
                       $interestingIntIndex < 10;
                       $interestingIntIndex++ ) {
                  }
              }
          }

          Source https://phpmd.org/rules/naming.html#longvariable

          There are no issues that match your filters.

          Category
          Status