felixarntz/theme-boilerplate

View on GitHub

Showing 194 of 194 total issues

Function get_fonts_url has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_fonts_url( array $fonts ) {
        $font_families = array();

        foreach ( $fonts as $font ) {
            if ( ! $font['family'] instanceof Super_Awesome_Theme_Webfont_Family ) {
Severity: Minor
Found in inc/library/fonts/class-google-webfont-api.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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

<?php
/**
 * Template Name: Landing Page
 *
 * Landing page template that uses a simplified layout with a separate
Severity: Major
Found in templates/landing-page.php and 2 other locations - About 2 hrs to fix
templates/full-width.php on lines 1..44
singular.php on lines 1..41

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

<?php
/**
 * Template Name: Full Width Page
 *
 * The full width template does not display any sidebar.
Severity: Major
Found in templates/full-width.php and 2 other locations - About 2 hrs to fix
templates/landing-page.php on lines 1..45
singular.php on lines 1..41

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

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

Identical blocks of code found in 3 locations. Consider refactoring.
Open

<?php
/**
 * The template for displaying any single post
 *
 * @package Super_Awesome_Theme
Severity: Major
Found in singular.php and 2 other locations - About 2 hrs to fix
templates/full-width.php on lines 1..44
templates/landing-page.php on lines 1..45

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

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

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

    protected function register_customize_controls_js( $assets ) {
        $data = array(
            'groups'           => array(),
            'fonts'            => array(),
            'fontFamilyGroups' => array(),
Severity: Major
Found in inc/library/fonts/class-fonts.php - About 2 hrs to fix

    Method handle_ajax_comment has 54 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function handle_ajax_comment( $id, $status ) {
            if ( empty( $_GET['is_ajax'] ) || 'true' !== $_GET['is_ajax'] ) {
                return;
            }
    
    
    Severity: Major
    Found in inc/library/comments/class-comments.php - About 2 hrs to fix

      Function option has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        Results.prototype.option = function (data) {
          var option = document.createElement('li');
          option.className = 'select2-results__option';
      
          var attrs = {
      Severity: Major
      Found in assets/vendor/selectWoo/dist/js/selectWoo.full.js - About 2 hrs to fix

        Method get_for_post has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_for_post( $post = null ) {
                $post = get_post( $post );
                if ( ! $post ) {
                    return false;
                }
        Severity: Major
        Found in inc/library/content-types/class-attachment-metadata.php - About 2 hrs to fix

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

              protected function register_customize_partial( $customizer ) {
                  $partial_fonts     = array();
                  $has_default_group = false;
                  foreach ( $this->fonts as $id => $font ) {
                      if ( $font->get_prop( Super_Awesome_Theme_Font::PROP_LIVE_PREVIEW ) ) {
          Severity: Major
          Found in inc/library/fonts/class-fonts.php - About 2 hrs to fix

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

                protected function register_customize_partial( $customizer ) {
                    $partial_fonts     = array();
                    $has_default_group = false;
                    foreach ( $this->fonts as $id => $font ) {
                        if ( $font->get_prop( Super_Awesome_Theme_Font::PROP_LIVE_PREVIEW ) ) {
            Severity: Minor
            Found in inc/library/fonts/class-fonts.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

            Function _positionDropdown has 52 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              AttachBody.prototype._positionDropdown = function () {
                var $window = $(window);
            
                var isCurrentlyAbove = this.$dropdown.hasClass('select2-dropdown--above');
                var isCurrentlyBelow = this.$dropdown.hasClass('select2-dropdown--below');
            Severity: Major
            Found in assets/vendor/selectWoo/dist/js/selectWoo.full.js - About 2 hrs to fix

              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

                Consider simplifying this complex logical expression.
                Open

                var S2;(function () { if (!S2 || !S2.requirejs) {
                if (!S2) { S2 = {}; } else { require = S2; }
                /**
                 * @license almond 0.3.3 Copyright jQuery Foundation and other contributors.
                 * Released under MIT license, http://github.com/requirejs/almond/LICENSE
                Severity: Critical
                Found in assets/vendor/selectWoo/dist/js/selectWoo.full.js - About 2 hrs to fix

                  Method add_control has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function add_control( $setting_id, $control_args = array() ) {
                          if ( ! isset( $this->wp_customize ) ) {
                              throw Super_Awesome_Theme_Customizer_Not_Loaded_Exception::from_method_and_id( __METHOD__, $setting_id );
                          }
                  
                  
                  Severity: Minor
                  Found in inc/library/customizer/class-customizer.php - About 1 hr to fix

                    Function query has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      AjaxAdapter.prototype.query = function (params, callback) {
                        var matches = [];
                        var self = this;
                    
                        if (this._request != null) {
                    Severity: Minor
                    Found in assets/vendor/selectWoo/dist/js/selectWoo.full.js - About 1 hr to fix

                      Function add_field has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          protected function add_field( $id, array $args = array() ) {
                              if ( ! isset( $args[ self::FIELD_ARG_TYPE ] ) ) {
                                  $args[ self::FIELD_ARG_TYPE ] = self::FIELD_TYPE_TEXT;
                              }
                      
                      
                      Severity: Minor
                      Found in inc/library/widgets/class-widget.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 addRemoveStickyContainer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                      Open

                          addRemoveStickyContainer( selector, location, remove ) {
                              const container = document.querySelector( selector );
                              let selectorsHandle, containersHandle, offsetsHandle, exists;
                              if ( 'top' === location ) {
                                  selectorsHandle  = 'stickToTopSelectors';
                      Severity: Minor
                      Found in assets/src/js/theme/sticky.js - 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

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

                          protected function register_customize_controls_js( $assets ) {
                              $assets->register_asset( new Super_Awesome_Theme_Script(
                                  'super-awesome-theme-custom-header-customize-controls',
                                  get_theme_file_uri( '/assets/dist/js/custom-header.customize-controls.js' ),
                                  array(
                      Severity: Major
                      Found in inc/library/custom-header/class-custom-header.php and 1 other location - About 1 hr to fix
                      inc/library/navbar/class-navbar.php on lines 278..294

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

                      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

                          protected function register_customize_controls_js( $assets ) {
                              $assets->register_asset( new Super_Awesome_Theme_Script(
                                  'super-awesome-theme-navbar-customize-controls',
                                  get_theme_file_uri( '/assets/dist/js/navbar.customize-controls.js' ),
                                  array(
                      Severity: Major
                      Found in inc/library/navbar/class-navbar.php and 1 other location - About 1 hr to fix
                      inc/library/custom-header/class-custom-header.php on lines 188..204

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

                      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

                      Function _registerDomEvents has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        Select2.prototype._registerDomEvents = function () {
                          var self = this;
                      
                          this.$element.on('change.select2', function () {
                            self.dataAdapter.current(function (data) {
                      Severity: Minor
                      Found in assets/vendor/selectWoo/dist/js/selectWoo.full.js - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language