felixarntz/theme-boilerplate

View on GitHub
inc/library/colors/class-colors.php

Summary

Maintainability
F
4 days
Test Coverage

File class-colors.php has 626 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Super_Awesome_Theme_Colors class
 *
 * @package Super_Awesome_Theme
Severity: Major
Found in inc/library/colors/class-colors.php - About 1 day to fix

    Method print_base_color_style_general has 134 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function print_base_color_style_general() {
            $text_color            = $this->get( 'text_color' );
            $text_focus_color      = $this->util()->darken_color( $text_color, 25 );
            $text_light_color      = $this->util()->lighten_color( $text_color, 100 );
            $link_color            = $this->get( 'link_color' );
    Severity: Major
    Found in inc/library/colors/class-colors.php - About 5 hrs to fix

      Method print_base_color_style_button has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function print_base_color_style_button() {
              $button_text_color                     = $this->get( 'button_text_color' );
              $button_background_color               = $this->get( 'button_background_color' );
              $button_background_focus_color         = $this->util()->darken_color( $button_background_color, 25 );
              $button_primary_text_color             = $this->get( 'button_primary_text_color' );
      Severity: Major
      Found in inc/library/colors/class-colors.php - About 2 hrs to fix

        Method print_color_style_css has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function print_color_style_css() {
        
                /**
                 * Fires when the custom color styles are printed inside a style tag.
                 *
        Severity: Major
        Found in inc/library/colors/class-colors.php - About 2 hrs to fix

          Super_Awesome_Theme_Colors has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          final class Super_Awesome_Theme_Colors extends Super_Awesome_Theme_Theme_Component_Base {
          
              /**
               * Utility methods instance.
               *
          Severity: Minor
          Found in inc/library/colors/class-colors.php - About 2 hrs to fix

            Method register_customize_partial has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function register_customize_partial( $customizer ) {
                    $partial_colors = array();
            
                    if ( ! empty( $this->groups ) ) {
                        $customizer->add_panel( 'colors', array(
            Severity: Minor
            Found in inc/library/colors/class-colors.php - About 1 hr to fix

              Method print_base_color_style_footer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function print_base_color_style_footer() {
                      $footer_text_color       = $this->get( 'footer_text_color' );
                      $footer_link_color       = $this->get( 'footer_link_color' );
                      $footer_link_focus_color = $this->util()->darken_color( $footer_link_color, 25 );
                      $footer_background_color = $this->get( 'footer_background_color' );
              Severity: Minor
              Found in inc/library/colors/class-colors.php - About 1 hr to fix

                Method print_base_color_style_header has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function print_base_color_style_header() {
                        $header_text_color       = $this->get( 'header_textcolor' );
                        $header_link_color       = $this->get( 'header_link_color' );
                        $header_link_focus_color = $this->util()->darken_color( $header_link_color, 25 );
                        $header_background_color = $this->get( 'header_background_color' );
                Severity: Minor
                Found in inc/library/colors/class-colors.php - About 1 hr to fix

                  Method register_base_colors_general has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function register_base_colors_general() {
                          $this->register_group( 'general_colors', __( 'General Colors', 'super-awesome-theme' ) );
                  
                          $this->register_color( new Super_Awesome_Theme_Color( 'text_color', array(
                              Super_Awesome_Theme_Color::PROP_GROUP   => 'general_colors',
                  Severity: Minor
                  Found in inc/library/colors/class-colors.php - About 1 hr to fix

                    Method register_customize_controls_js has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function register_customize_controls_js( $assets ) {
                            $data = array(
                                'groups'            => array(),
                                'colors'            => array(),
                                'footerWidgetAreas' => super_awesome_theme( 'footer_widget_areas' )->get_widget_area_names(),
                    Severity: Minor
                    Found in inc/library/colors/class-colors.php - About 1 hr to fix

                      Function register_customize_partial has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function register_customize_partial( $customizer ) {
                              $partial_colors = array();
                      
                              if ( ! empty( $this->groups ) ) {
                                  $customizer->add_panel( 'colors', array(
                      Severity: Minor
                      Found in inc/library/colors/class-colors.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 register_customize_controls_js has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function register_customize_controls_js( $assets ) {
                              $data = array(
                                  'groups'            => array(),
                                  'colors'            => array(),
                                  'footerWidgetAreas' => super_awesome_theme( 'footer_widget_areas' )->get_widget_area_names(),
                      Severity: Minor
                      Found in inc/library/colors/class-colors.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

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

                              if ( ! empty( $button_primary_text_color ) && ! empty( $button_primary_background_color ) && ! empty( $button_primary_background_focus_color ) ) {
                                  ?>
                                  button.button-primary,
                                  input[type="button"].button-primary,
                                  input[type="reset"].button-primary,
                      Severity: Major
                      Found in inc/library/colors/class-colors.php and 1 other location - About 1 hr to fix
                      inc/library/colors/class-colors.php on lines 747..782

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

                      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

                              if ( ! empty( $button_text_color ) && ! empty( $button_background_color ) && ! empty( $button_background_focus_color ) ) {
                                  ?>
                                  button,
                                  input[type="button"],
                                  input[type="reset"],
                      Severity: Major
                      Found in inc/library/colors/class-colors.php and 1 other location - About 1 hr to fix
                      inc/library/colors/class-colors.php on lines 784..819

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

                      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 5 locations. Consider refactoring.
                      Open

                              $assets->register_asset( new Super_Awesome_Theme_Script(
                                  'super-awesome-theme-colors-customize-controls',
                                  get_theme_file_uri( '/assets/dist/js/colors.customize-controls.js' ),
                                  array(
                                      Super_Awesome_Theme_Script::PROP_DEPENDENCIES => array( 'customize-controls', 'wp-i18n' ),
                      Severity: Major
                      Found in inc/library/colors/class-colors.php and 4 other locations - About 40 mins to fix
                      inc/library/content-types/class-content-types.php on lines 521..532
                      inc/library/sidebar/class-sidebar.php on lines 317..328
                      inc/library/sticky-elements/class-sticky-elements.php on lines 145..156
                      inc/library/widgets/class-widgets.php on lines 437..448

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

                      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 register_color( Super_Awesome_Theme_Color $color ) {
                              $id = $color->get_prop( Super_Awesome_Theme_Color::PROP_ID );
                      
                              if ( isset( $this->colors[ $id ] ) ) {
                                  return false;
                      Severity: Minor
                      Found in inc/library/colors/class-colors.php and 1 other location - About 30 mins to fix
                      inc/library/fonts/class-fonts.php on lines 86..99

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

                      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

                      There are no issues that match your filters.

                      Category
                      Status