felixarntz/wpdlib

View on GitHub

Showing 160 of 160 total issues

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 (bool) $value;
    Severity: Major
    Found in inc/WPDLib/FieldTypes/Manager.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                              return 'edit.php?post_type=page';
      Severity: Major
      Found in inc/WPDLib/Components/Menu.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                        return new WPError( 'invalid_number_step', sprintf( __( 'The number %1$s is invalid since it is not divisible by %2$s.', 'wpdlib' ), FieldManager::format( $val, $format, 'output' ), FieldManager::format( $this->args['step'], $format, 'output' ) ) );
        Severity: Major
        Found in inc/WPDLib/FieldTypes/Number.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return FieldManager::format( $val, 'string', 'input' );
          Severity: Major
          Found in inc/WPDLib/FieldTypes/Color.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                            return new WPError( 'invalid_number_too_small', sprintf( __( 'The number %1$s is invalid. It must be greater than or equal to %2$s.', 'wpdlib' ), FieldManager::format( $val, $format, 'output' ), FieldManager::format( $this->args['min'], $format, 'output' ) ) );
            Severity: Major
            Found in inc/WPDLib/FieldTypes/Number.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

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

                Avoid too many return statements within this method.
                Open

                                return new WPError( 'invalid_number_too_big', sprintf( __( 'The number %1$s is invalid. It must be lower than or equal to %2$s.', 'wpdlib' ), FieldManager::format( $val, $format, 'output' ), FieldManager::format( $this->args['max'], $format, 'output' ) ) );
                Severity: Major
                Found in inc/WPDLib/FieldTypes/Number.php - About 30 mins to fix

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

                          private static function format_bool( $value, $mode = 'input' ) {
                              $formatted = self::parse_bool( $value );
                  
                              if ( 'output' === $mode ) {
                                  if ( $formatted ) {
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Manager.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 get_posts_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public static function get_posts_options( $post_type = 'any' ) {
                              if ( ! is_string( $post_type ) && ! is_array( $post_type ) || empty( $post_type ) ) {
                                  $post_type = 'any';
                              }
                  
                  
                  Severity: Minor
                  Found in inc/WPDLib/Util/Util.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 parse has a Cognitive Complexity of 6 (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/Url.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 get_instance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public static function get_instance( $args, $repeatable = false ) {
                              if ( ! isset( $args['type'] ) ) {
                                  return null;
                              }
                  
                  
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Manager.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 get_parent has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function get_parent( $index = 0, $depth = 1 ) {
                              $current = $this;
                              for ( $i = 0; $i < $depth; $i++ ) {
                                  $parents = array_values( $current->parents );
                                  if ( isset( $parents[ $index ] ) ) {
                  Severity: Minor
                  Found in inc/WPDLib/Components/Base.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 enqueue_assets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function enqueue_assets() {
                              if ( self::is_enqueued( __CLASS__ ) ) {
                                  return array();
                              }
                  
                  
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Select.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 display_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
                              $option_atts = array(
                                  'id'        => $id . '-' . $value,
                                  'name'        => $name,
                                  'value'        => $value,
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Radio.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 object_array_sort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public static function object_array_sort( $arr, $sort_by, $associative = false ) {
                              if ( ! empty( $sort_by ) ) {
                                  self::$sort_by = $sort_by;
                  
                                  if ( $associative ) {
                  Severity: Minor
                  Found in inc/WPDLib/Util/Util.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 enqueue_assets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          public function enqueue_assets() {
                              global $post;
                  
                              if ( self::is_enqueued( __CLASS__ ) ) {
                                  return array();
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Media.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 is_value_checked_or_selected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function is_value_checked_or_selected( $val, $choice ) {
                              if ( isset( $this->args['multiple'] ) && $this->args['multiple'] ) {
                                  if ( ! is_array( $val ) ) {
                                      $val = array( $val );
                                  }
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Radio.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 get_sanitized_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                          protected function get_sanitized_name() {
                              $name = $this->args['name'];
                              if ( isset( $this->args['multiple'] ) && $this->args['multiple'] ) {
                                  if ( '[]' != substr( $name, -2 ) ) {
                                      $name .= '[]';
                  Severity: Minor
                  Found in inc/WPDLib/FieldTypes/Radio.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 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

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

                  Severity
                  Category
                  Status
                  Source
                  Language