felixarntz/wpdlib

View on GitHub

Showing 156 of 160 total issues

Method format_item has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        protected function format_item( $val, $args = array() ) {
            $skip_formatting = false;

            if ( isset( $this->args['options'][ $val ] ) ) {
                if ( is_array( $this->args['options'][ $val ] ) ) {
Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.php - About 1 hr to fix

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

            public static function get_info( $field = '' ) {
                $composer_file = self::get_base_dir() . '/composer.json';
                if ( ! file_exists( $composer_file ) ) {
                    if ( ! empty( $field ) ) {
                        return false;
    Severity: Minor
    Found in inc/WPDLib/Components/Manager.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 get_users_options has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function get_users_options( $role = 'any' ) {
                if ( is_array( $role ) ) {
                    if ( count( $role ) > 0 ) {
                        $role = $role[0];
                    }
    Severity: Minor
    Found in inc/WPDLib/Util/Util.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 sort_html_data_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            private static function sort_html_data_attributes( $a, $b, $priorities = array() ) {
                if ( strpos( $a, 'data-' ) === 0 && strpos( $b, 'data-' ) !== 0 ) {
                    if ( in_array( $b, $priorities ) ) {
                        return 1;
                    }
    Severity: Minor
    Found in inc/WPDLib/FieldTypes/Manager.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 object_array_insert_sorted has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            private static function object_array_insert_sorted( $arr, $item, $sort_by, $key = 'slug' ) {
                $new_arr = array();
                $new_arr[ $item->$key ] = $item;
    
                $split_key = 0;
    Severity: Minor
    Found in inc/WPDLib/Util/Util.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_hierarchy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function register_hierarchy( $hierarchy, $toplevel = true ) {
                foreach ( $hierarchy as $class => $children ) {
                    if ( $toplevel && ! in_array( $class, self::$hierarchy_toplevel ) ) {
                        self::$hierarchy_toplevel[] = $class;
                    }
    Severity: Minor
    Found in inc/WPDLib/Components/Manager.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 object_array_merge_items has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            private static function object_array_merge_items( $items, $result, &$instance_counts, $key = 'slug' ) {
                foreach ( $items as $item ) {
                    if ( ! isset( $result[ $item->$key ] ) ) {
                        $result[ $item->$key ] = $item;
                    } else {
    Severity: Minor
    Found in inc/WPDLib/Util/Util.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 format_unit has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            public static function format_unit( $value, $units, $base, $base_unit = '', $decimals = 2 ) {
                $value = floatval( $value );
    
                if ( empty( $base_unit ) ) {
                    $base_unit = $units[0];
    Severity: Minor
    Found in inc/WPDLib/Util/Util.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 format has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            public static function format( $value, $type, $mode = 'input', $args = array() ) {
                $mode = 'output' === $mode ? 'output' : 'input';
    
                $formatted = $value;
    
    
    Severity: Minor
    Found in inc/WPDLib/FieldTypes/Manager.php - About 1 hr to fix

      Method make_html_attributes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public static function make_html_attributes( $atts, $html5 = true, $echo = true ) {
                  $output = '';
      
                  $bool_atts = array_filter( $atts, 'is_bool' );
      
      
      Severity: Minor
      Found in inc/WPDLib/FieldTypes/Manager.php - About 1 hr to fix

        Method parse_multi has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected function parse_multi( $val, $formatted = false ) {
                    $parsed = array();
                    if ( $formatted ) {
                        if ( ! is_array( $formatted ) ) {
                            $formatted = array();
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Radio.php - About 1 hr to fix

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

                  public function is_already_added( $screen_slug ) {
                      global $admin_page_hooks;
          
                      if ( $this->added ) {
                          return $this->added;
          Severity: Minor
          Found in inc/WPDLib/Components/Menu.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

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

                  protected function parse_template( $val, $template, $before = '', $after = '' ) {
                      $output = '';
          
                      if ( ! $this->is_empty( $val ) ) {
                          $output .= $before;
          Severity: Minor
          Found in inc/WPDLib/FieldTypes/Repeatable.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

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

                  private static function sort_html_priority_attributes( $a, $b, $priorities = array() ) {
                      if ( in_array( $a, $priorities ) && ! in_array( $b, $priorities ) ) {
                          return -1;
                      } elseif ( ! in_array( $a, $priorities ) && in_array( $b, $priorities ) ) {
                          return 1;
          Severity: Minor
          Found in inc/WPDLib/FieldTypes/Manager.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

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

                  protected function check_for_admin_page( $slug, $admin_page_hooks ) {
                      if ( isset( $admin_page_hooks[ $slug ] ) ) {
                          // check for the exact menu slug
                          return $slug;
                      }
          Severity: Minor
          Found in inc/WPDLib/Components/Menu.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

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

                  private static function sort_objects_callback( $a, $b ) {
                      $sort_by = self::$sort_by;
          
                      if ( ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) && ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) ) {
                          return 0;
          Severity: Minor
          Found in inc/WPDLib/Util/Util.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

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

                  public function parse( $val, $formatted = false ) {
                      if ( $formatted ) {
                          if ( ! is_array( $formatted ) ) {
                              $formatted = array();
                          }
          Severity: Minor
          Found in inc/WPDLib/FieldTypes/Checkbox.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 display_item has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
          Severity: Major
          Found in inc/WPDLib/FieldTypes/Radio.php - About 50 mins to fix

            Method display_item has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
            Severity: Major
            Found in inc/WPDLib/FieldTypes/Select.php - About 50 mins to fix

              Function is_rest_zero has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                      public static function is_rest_zero( $divident, $divisor ) {
                          $divident = abs( $divident );
                          $divisor = abs( $divisor );
              
                          if ( is_int( $divident ) && is_int( $divisor ) ) {
              Severity: Minor
              Found in inc/WPDLib/Util/Util.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

              Severity
              Category
              Status
              Source
              Language