felixarntz/post-types-definitely

View on GitHub
inc/WPPTD/Utility.php

Summary

Maintainability
F
6 days
Test Coverage

Function get_related_objects has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
            // specify variables depending on the base mode
            switch ( $mode ) {
                case 'post':
                    $get_func = 'get_post';
Severity: Minor
Found in inc/WPPTD/Utility.php - About 1 day 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 get_related_objects has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
            // specify variables depending on the base mode
            switch ( $mode ) {
                case 'post':
                    $get_func = 'get_post';
Severity: Major
Found in inc/WPPTD/Utility.php - About 5 hrs to fix

    Function validate_labels has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function validate_labels( $args, $key, $mode ) {
                if ( false === $args[ $key ] ) {
                    $args[ $key ] = array();
                    return $args;
                }
    Severity: Minor
    Found in inc/WPPTD/Utility.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

    File Utility.php has 333 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * @package WPPTD
     * @version 0.6.4
     * @author Felix Arntz <felix-arntz@leaves-and-love.net>
    Severity: Minor
    Found in inc/WPPTD/Utility.php - About 4 hrs to fix

      Function maybe_register_related_objects_field has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function maybe_register_related_objects_field( $object, $args, $component, $component_parent ) {
                  if ( ! isset( $args['options'] ) || ! is_array( $args['options'] ) || 1 !== count( $args['options'] ) ) {
                      return;
                  }
      
      
      Severity: Minor
      Found in inc/WPPTD/Utility.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 parse_meta_value has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function parse_meta_value( $meta_value, $field, $single = null, $formatted = false ) {
                  $_meta_value = $meta_value;
                  $meta_value = null;
      
                  $type_hint = $field->validate_meta_value( null, true );
      Severity: Minor
      Found in inc/WPPTD/Utility.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 validate_labels has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public static function validate_labels( $args, $key, $mode ) {
                  if ( false === $args[ $key ] ) {
                      $args[ $key ] = array();
                      return $args;
                  }
      Severity: Minor
      Found in inc/WPPTD/Utility.php - About 1 hr to fix

        Function validate_titles has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                public static function validate_titles( $args, $slug, $mode ) {
                    if ( empty( $args['title'] ) && isset( $args['label'] ) ) {
                        $args['title'] = $args['label'];
                        unset( $args['label'] );
                    }
        Severity: Minor
        Found in inc/WPPTD/Utility.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 maybe_register_related_objects_field has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static function maybe_register_related_objects_field( $object, $args, $component, $component_parent ) {
                    if ( ! isset( $args['options'] ) || ! is_array( $args['options'] ) || 1 !== count( $args['options'] ) ) {
                        return;
                    }
        
        
        Severity: Minor
        Found in inc/WPPTD/Utility.php - About 1 hr to fix

          Function validate_help_args has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  public static function validate_help_args( $args, $key ) {
                      if( ! is_array( $args[ $key ] ) ) {
                          $args[ $key ] = array();
                      }
                      if ( ! isset( $args[ $key ]['tabs'] ) || ! is_array( $args[ $key ]['tabs'] ) ) {
          Severity: Minor
          Found in inc/WPPTD/Utility.php - About 55 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

          Method get_related_objects has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
          Severity: Minor
          Found in inc/WPPTD/Utility.php - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                            return array();
            Severity: Major
            Found in inc/WPPTD/Utility.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return null;
              Severity: Major
              Found in inc/WPPTD/Utility.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return array();
                Severity: Major
                Found in inc/WPPTD/Utility.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return array();
                  Severity: Major
                  Found in inc/WPPTD/Utility.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                        return null;
                    Severity: Major
                    Found in inc/WPPTD/Utility.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                          return null;
                      Severity: Major
                      Found in inc/WPPTD/Utility.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                        return $objects[0];
                        Severity: Major
                        Found in inc/WPPTD/Utility.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return array();
                          Severity: Major
                          Found in inc/WPPTD/Utility.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return $objects;
                            Severity: Major
                            Found in inc/WPPTD/Utility.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                              return array();
                              Severity: Major
                              Found in inc/WPPTD/Utility.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return null;
                                Severity: Major
                                Found in inc/WPPTD/Utility.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                      return null;
                                  Severity: Major
                                  Found in inc/WPPTD/Utility.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                    return array();
                                    Severity: Major
                                    Found in inc/WPPTD/Utility.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                          return null;
                                      Severity: Major
                                      Found in inc/WPPTD/Utility.php - About 30 mins to fix

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

                                                public static function get_default_formatted( $type ) {
                                                    $formatted = true;
                                        
                                                    switch ( $type ) {
                                                        case 'checkbox':
                                        Severity: Minor
                                        Found in inc/WPPTD/Utility.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

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

                                                public static function validate_ui_args( $args ) {
                                                    if ( null === $args['show_ui'] ) {
                                                        $args['show_ui'] = $args['public'];
                                                    }
                                                    if ( null === $args['show_in_menu'] ) {
                                        Severity: Minor
                                        Found in inc/WPPTD/Utility.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