felixarntz/wpdlib

View on GitHub

Showing 156 of 160 total issues

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

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

                        protected static function maybe_init_locale() {
                            if ( self::$locale === null ) {
                                global $wp_locale;
                
                                self::$locale = array(
                Severity: Minor
                Found in inc/WPDLib/FieldTypes/Datetime.php - About 1 hr to fix

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

                          public function display( $val, $echo = true ) {
                              $args = $this->args;
                              $args['name'] = $this->get_sanitized_name();
                  
                              $args = array_merge( $args, $this->data_atts );
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Select.php - About 1 hr to fix

                    Method is_valid_slug has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            public function is_valid_slug( $parent = null ) {
                                if ( $this->valid_slug === null ) {
                                    $globalnames = $this->supports_globalslug();
                                    if ( $globalnames !== true ) {
                                        if ( $globalnames !== false ) {
                    Severity: Minor
                    Found in inc/WPDLib/Components/Base.php - About 1 hr to fix

                      Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              public function __construct( $type, $args ) {
                                  $this->type = $type;
                                  $this->args = wp_parse_args( $args, array(
                                      'id'          => '',
                                      'name'        => '',
                      Severity: Minor
                      Found in inc/WPDLib/FieldTypes/Base.php - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language