felixarntz/wpdlib

View on GitHub

Showing 160 of 160 total issues

Function get_dependency_info has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public static function get_dependency_info( $dependency, $field = '' ) {
            $bower_file = self::get_base_dir() . '/assets/vendor/' . $dependency . '/.bower.json';
            if ( ! file_exists( $bower_file ) ) {
                $bower_file = self::get_base_dir() . '/assets/vendor/' . $dependency . '/bower.json';
            }
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 maybe_generate_additional_item_output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        protected function maybe_generate_additional_item_output( $id, $data, $checked = false ) {
            $output = $class = $label = '';
            if ( isset( $data['image'] ) || isset( $data['color'] ) ) {
                $output = '<div id="' . $id . '-asset"';

Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.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 exists has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public static function exists( $slug, $class, $check_slug = '' ) {
            if ( ! isset( self::$component_finder[ $class ] ) ) {
                self::$component_finder[ $class ] = array();
            }

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

Method display has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function display( $val, $echo = true ) {
            if ( ! is_array( $val ) ) {
                $val = array();
            }

Severity: Minor
Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

    Method get_attachment_field has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            protected function get_attachment_field( $id, $field = 'url' ) {
                switch ( $field ) {
                    case 'id':
                    case 'ID':
                        return $id;
    Severity: Minor
    Found in inc/WPDLib/FieldTypes/Media.php - About 1 hr to fix

      Method validate has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public function validate( $val = null ) {
                  $format = 'float';
                  $zero = 0.0;
                  if ( is_int( $this->args['step'] ) ) {
                      $format = 'int';
      Severity: Minor
      Found in inc/WPDLib/FieldTypes/Number.php - About 1 hr to fix

        Method display_item has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                protected function display_item( $key, $values = array(), $echo = true ) {
                    $output = '<tr class="wpdlib-repeatable-row">';
        
                    $output .= '<td class="wpdlib-repeatable-number">';
                    if ( '{{' . 'KEY' . '}}' === $key ) {
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

          Function _datetimeOnShow has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  _datetimeOnShow: function( ct, $input ) {
                      var helper = '';
                      if ( $input.attr( 'min' ) ) {
                          helper = $input.attr( 'min' ).split( ' ' );
                          if ( helper.length === 2 ) {
          Severity: Minor
          Found in assets/dist/js/fields.js - About 1 hr to fix

            Function _datetimeOnShow has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    _datetimeOnShow: function( ct, $input ) {
                        var helper = '';
                        if ( $input.attr( 'min' ) ) {
                            helper = $input.attr( 'min' ).split( ' ' );
                            if ( helper.length === 2 ) {
            Severity: Minor
            Found in assets/src/js/fields.js - About 1 hr to fix

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

                      public function parse( $val, $formatted = false ) {
                          $parsed = array();
                          $items_formatted = false;
                          if ( $formatted ) {
                              $items_formatted = array( 'mode' => 'text', 'list' => true );
              Severity: Minor
              Found in inc/WPDLib/FieldTypes/Repeatable.php - About 1 hr to fix

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

                        protected function check_for_admin_page_func( $slug ) {
                            if ( function_exists( 'add_' . $slug . '_page' ) ) {
                                switch ( $slug ) {
                                    case 'dashboard':
                                        return 'index.php';
                Severity: Minor
                Found in inc/WPDLib/Components/Menu.php - About 1 hr to fix

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

                          private static function object_array_merge_split( $arrs, $sort_by ) {
                              $sortables = array();
                              $nulls = array();
                  
                              foreach ( $arrs as $arr ) {
                  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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function create() {
                              foreach ( $this->get_children() as $menu_item ) {
                                  if ( is_callable( array( $menu_item, 'add_to_menu' ) ) ) {
                                      if ( 'none' == $this->slug ) {
                                          $this->add_non_menu_page( $menu_item );
                  Severity: Minor
                  Found in inc/WPDLib/Components/Menu.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_float has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          private static function format_float( $value, $mode = 'input', $args = array() ) {
                              $positive_only = isset( $args['positive_only'] ) ? (bool) $args['positive_only'] : false;
                  
                              $formatted = self::parse_float( $value );
                              if ( $positive_only ) {
                  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 get_default_datetime_format has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          private static function get_default_datetime_format( $type, $mode = 'input' ) {
                              if ( 'output' === $mode ) {
                                  if ( $type == 'date' ) {
                                      return get_option( 'date_format' );
                                  } elseif ( $type == 'time' ) {
                  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 display_item has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function display_item( $key, $values = array(), $echo = true ) {
                              $output = '<tr class="wpdlib-repeatable-row">';
                  
                              $output .= '<td class="wpdlib-repeatable-number">';
                              if ( '{{' . 'KEY' . '}}' === $key ) {
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Repeatable.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 validate_single has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function validate_single( $val = null ) {
                              if ( ! $val ) {
                                  if ( count( $this->args['options'] ) > 0 ) {
                                      return key( $this->args['options'] );
                                  }
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Radio.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 display has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function display( $val, $echo = true ) {
                              if ( ! is_array( $val ) ) {
                                  $val = array();
                              }
                  
                  
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Repeatable.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_attachment_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function get_attachment_path( $id, $mode = 'url', $size = false ) {
                              $url = wp_get_attachment_url( $id );
                              if ( $size ) {
                                  $src = wp_get_attachment_image_src( $id, $size, false );
                                  if ( is_array( $src ) ) {
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Media.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 parse has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function parse( $val, $formatted = false ) {
                              if ( $formatted ) {
                                  $parsed = FieldManager::format( $val, 'html', 'input' );
                                  if ( ! is_array( $formatted ) ) {
                                      $formatted = array();
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Wysiwyg.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

                  Severity
                  Category
                  Status
                  Source
                  Language