felixarntz/wpdlib

View on GitHub

Showing 160 of 160 total issues

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

      Avoid deeply nested control flow statements.
      Open

                                      if ( $parent === null ) {
                                          $found = false;
                                          break;
                                      }
      Severity: Major
      Found in inc/WPDLib/Components/Base.php - About 45 mins to fix

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

                public static function mod( $divident, $divisor ) {
                    if ( is_int( $divident ) && is_int( $divisor ) ) {
                        // prevent division by zero
                        if ( 0 === $divisor ) {
                            return 0;
        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

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

                public function parse( $val, $formatted = false ) {
                    if ( ! $val ) {
                        return '';
                    }
        
        
        Severity: Minor
        Found in inc/WPDLib/FieldTypes/Color.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

        Consider simplifying this complex logical expression.
        Open

                    if ( ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) && ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) ) {
                        return 0;
                    } elseif ( ! isset( $a->$sort_by ) || null === $a->$sort_by ) {
                        return 1;
                    } elseif ( ! isset( $b->$sort_by ) || null === $b->$sort_by ) {
        Severity: Major
        Found in inc/WPDLib/Util/Util.php - About 40 mins to fix

          Method format_unit has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  public static function format_unit( $value, $units, $base, $base_unit = '', $decimals = 2 ) {
          Severity: Minor
          Found in inc/WPDLib/Util/Util.php - About 35 mins to fix

            Function check_for_admin_page_func has a Cognitive Complexity of 7 (exceeds 5 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 35 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 get_children has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function get_children( $class = '' ) {
                        $children = array();
            
                        if ( $class && '*' !== $class ) {
                            if ( isset( $this->children[ $class ] ) ) {
            Severity: Minor
            Found in inc/WPDLib/Components/Base.php - About 35 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 add_menu_page has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    protected function add_menu_page( $menu_item ) {
                        $status = false;
                        if ( is_callable( array( $menu_item, 'add_to_menu' ) ) ) {
                            $status = $menu_item->add_to_menu( array(
                                'mode'            => 'menu',
            Severity: Minor
            Found in inc/WPDLib/Components/Menu.php - About 35 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 display has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function display( $val, $echo = true ) {
                        $args = array(
                            'id'    => $this->args['id'],
                            'class' => $this->args['class'],
                        );
            Severity: Minor
            Found in inc/WPDLib/FieldTypes/Radio.php - About 35 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 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function parse( $val, $formatted = false ) {
                        if ( ! $val ) {
                            return '';
                        }
            
            
            Severity: Minor
            Found in inc/WPDLib/FieldTypes/Datetime.php - About 35 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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                    public function __construct( $type, $args ) {
                        $args = wp_parse_args( $args, array(
                            'options' => array(),
                        ) );
                        parent::__construct( $type, $args );
            Severity: Minor
            Found in inc/WPDLib/FieldTypes/Radio.php - About 35 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

            Avoid too many return statements within this method.
            Open

                                return true;
            Severity: Major
            Found in inc/WPDLib/FieldTypes/Media.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                                  return wp_mime_type_icon( $id );
              Severity: Major
              Found in inc/WPDLib/FieldTypes/Media.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return '';
                Severity: Major
                Found in inc/WPDLib/FieldTypes/Media.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $id;
                  Severity: Major
                  Found in inc/WPDLib/FieldTypes/Media.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                            return $this->get_attachment_path( $id, 'path', substr( $field, 0, -5 ) );
                    Severity: Major
                    Found in inc/WPDLib/FieldTypes/Media.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language