felixarntz/theme-boilerplate

View on GitHub
inc/library/content-types/class-content-types.php

Summary

Maintainability
F
3 days
Test Coverage

File class-content-types.php has 330 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Super_Awesome_Theme_Content_Types class
 *
 * @package Super_Awesome_Theme
Severity: Minor
Found in inc/library/content-types/class-content-types.php - About 3 hrs to fix

    Method register_customize_partials has 77 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function register_customize_partials( $customizer ) {
            $customizer->add_panel( 'content_types', array(
                Super_Awesome_Theme_Customize_Panel::PROP_TITLE    => __( 'Content Types', 'super-awesome-theme' ),
                Super_Awesome_Theme_Customize_Panel::PROP_PRIORITY => 140,
            ) );
    Severity: Major
    Found in inc/library/content-types/class-content-types.php - About 3 hrs to fix

      Function register_customize_partials has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function register_customize_partials( $customizer ) {
              $customizer->add_panel( 'content_types', array(
                  Super_Awesome_Theme_Customize_Panel::PROP_TITLE    => __( 'Content Types', 'super-awesome-theme' ),
                  Super_Awesome_Theme_Customize_Panel::PROP_PRIORITY => 140,
              ) );
      Severity: Minor
      Found in inc/library/content-types/class-content-types.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 __call has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __call( $method, $args ) {
              switch ( $method ) {
                  case 'register_settings':
                  case 'register_customize_partials':
                  case 'register_customize_controls_js':
      Severity: Major
      Found in inc/library/content-types/class-content-types.php - About 2 hrs to fix

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

            protected function register_settings() {
                $settings                  = $this->get_dependency( 'settings' );
                $this->attachment_metadata = new Super_Awesome_Theme_Attachment_Metadata( $settings );
        
                $boolean_settings = array();
        Severity: Minor
        Found in inc/library/content-types/class-content-types.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 register_customize_controls_js has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function register_customize_controls_js( $assets ) {
                $data = array(
                    'postTypes' => array(),
                );
        
        
        Severity: Minor
        Found in inc/library/content-types/class-content-types.php - About 1 hr to fix

          Function __call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              public function __call( $method, $args ) {
                  switch ( $method ) {
                      case 'register_settings':
                      case 'register_customize_partials':
                      case 'register_customize_controls_js':
          Severity: Minor
          Found in inc/library/content-types/class-content-types.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 register_settings has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function register_settings() {
                  $settings                  = $this->get_dependency( 'settings' );
                  $this->attachment_metadata = new Super_Awesome_Theme_Attachment_Metadata( $settings );
          
                  $boolean_settings = array();
          Severity: Minor
          Found in inc/library/content-types/class-content-types.php - About 1 hr to fix

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

                public function detect_post_type() {
                    switch ( true ) {
                        case is_front_page():
                            if ( is_home() ) {
                                return 'post';
            Severity: Minor
            Found in inc/library/content-types/class-content-types.php - About 1 hr to fix

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

                  public function detect_post_type() {
                      switch ( true ) {
                          case is_front_page():
                              if ( is_home() ) {
                                  return 'post';
              Severity: Minor
              Found in inc/library/content-types/class-content-types.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 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function register_customize_controls_js( $assets ) {
                      $data = array(
                          'postTypes' => array(),
                      );
              
              
              Severity: Minor
              Found in inc/library/content-types/class-content-types.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

              Avoid too many return statements within this method.
              Open

                                  return;
              Severity: Major
              Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return '';
                Severity: Major
                Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                          return reset( $taxonomy->object_type );
                  Severity: Major
                  Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return $post_types;
                    Severity: Major
                    Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return reset( $post_types );
                      Severity: Major
                      Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                            return;
                        Severity: Major
                        Found in inc/library/content-types/class-content-types.php - About 30 mins to fix

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

                                          $customizer->add_partial( $post_type->name . '_archive_content', array(
                                              Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS            => array( $post_type->name . '_use_excerpt' ),
                                              Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR            => '.type-' . $post_type->name . '.archive-view .entry-content',
                                              Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK     => array( $this, 'partial_entry_content' ),
                                              Super_Awesome_Theme_Customize_Partial::PROP_CONTAINER_INCLUSIVE => true,
                          Severity: Minor
                          Found in inc/library/content-types/class-content-types.php and 1 other location - About 1 hr to fix
                          inc/library/content-types/class-content-types.php on lines 425..432

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

                          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

                                          $customizer->add_partial( $post_type->name . '_entry_authorbox', array(
                                              Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS            => array( $post_type->name . '_show_authorbox' ),
                                              Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR            => '.type-' . $post_type->name . ' .entry-authorbox',
                                              Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK     => array( $this, 'partial_entry_authorbox' ),
                                              Super_Awesome_Theme_Customize_Partial::PROP_CONTAINER_INCLUSIVE => true,
                          Severity: Minor
                          Found in inc/library/content-types/class-content-types.php and 1 other location - About 1 hr to fix
                          inc/library/content-types/class-content-types.php on lines 394..401

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

                          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( $entry_attachment_meta_settings ) ) {
                                              $customizer->add_partial( $post_type->name . '_entry_attachment_meta', array(
                                                  Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS            => $entry_attachment_meta_settings,
                                                  Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR            => '.type-' . $post_type->name . ' .entry-attachment-meta',
                                                  Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK     => array( $this, 'partial_entry_attachment_meta' ),
                          Severity: Minor
                          Found in inc/library/content-types/class-content-types.php and 1 other location - About 55 mins to fix
                          inc/library/content-types/class-content-types.php on lines 444..453

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

                          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( $entry_terms_settings ) ) {
                                          $customizer->add_partial( $post_type->name . '_entry_terms', array(
                                              Super_Awesome_Theme_Customize_Partial::PROP_SETTINGS            => $entry_terms_settings,
                                              Super_Awesome_Theme_Customize_Partial::PROP_SELECTOR            => '.type-' . $post_type->name . ' .entry-terms',
                                              Super_Awesome_Theme_Customize_Partial::PROP_RENDER_CALLBACK     => array( $this, 'partial_entry_terms' ),
                          Severity: Minor
                          Found in inc/library/content-types/class-content-types.php and 1 other location - About 55 mins to fix
                          inc/library/content-types/class-content-types.php on lines 461..470

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

                          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-content-types-customize-controls',
                                      get_theme_file_uri( '/assets/dist/js/content-types.customize-controls.js' ),
                                      array(
                                          Super_Awesome_Theme_Script::PROP_DEPENDENCIES => array( 'customize-controls', 'wp-i18n' ),
                          Severity: Major
                          Found in inc/library/content-types/class-content-types.php and 4 other locations - About 40 mins to fix
                          inc/library/colors/class-colors.php on lines 384..395
                          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

                          There are no issues that match your filters.

                          Category
                          Status