felixarntz/wpdlib

View on GitHub

Showing 160 of 160 total issues

Function check_extension has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        protected function check_extension( $extension, $accepted_types = 'all' ) {
            if ( 'all' == $accepted_types || ! $accepted_types ) {
                return true;
            }

Severity: Minor
Found in inc/WPDLib/FieldTypes/Media.php - About 2 hrs 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_multi has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        protected function validate_multi( $val = null ) {
            if ( ! $val ) {
                return array();
            }

Severity: Minor
Found in inc/WPDLib/FieldTypes/Radio.php - About 2 hrs 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 _setupRepeatable has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        _setupRepeatable: function( selector ) {
            var self = WPDLibFieldManager;
            var $fields = this._getJQuery( selector );

            $fields.each(function() {
Severity: Major
Found in assets/src/js/fields.js - About 2 hrs to fix

    Function _setupRepeatable has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            _setupRepeatable: function( selector ) {
                var self = WPDLibFieldManager;
                var $fields = this._getJQuery( selector );
    
                $fields.each(function() {
    Severity: Major
    Found in assets/dist/js/fields.js - About 2 hrs to fix

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

              public function parse( $val, $formatted = false ) {
                  if ( 'url' === $this->args['store'] ) {
                      $val = FieldManager::format( $val, 'url', 'input' );
                  } else {
                      $val = absint( $val );
      Severity: Minor
      Found in inc/WPDLib/FieldTypes/Media.php - About 2 hrs 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if ( -90.0 > $val[0] || 90.0 < $val[0] ) {
                          return new WPError( 'invalid_map_coords_latitude', sprintf( __( 'The latitude %1$s is invalid. It must be between %2$s and %3$s.', 'wpdlib' ), FieldManager::format( $val[0], 'float', 'output', array( 'decimals' => 10 ) ), FieldManager::format( -90.0, 'float', 'output' ), FieldManager::format( 90.0, 'float', 'output' ) ) );
                      }
      Severity: Major
      Found in inc/WPDLib/FieldTypes/Map.php and 1 other location - About 1 hr to fix
      inc/WPDLib/FieldTypes/Map.php on lines 120..122

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 120.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if ( -180.0 > $val[0] || 180.0 < $val[0] ) {
                          return new WPError( 'invalid_map_coords_longitude', sprintf( __( 'The longitude %1$s is invalid. It must be between %2$s and %3$s.', 'wpdlib' ), FieldManager::format( $val[0], 'float', 'output', array( 'decimals' => 10 ) ), FieldManager::format( -180.0, 'float', 'output' ), FieldManager::format( 180.0, 'float', 'output' ) ) );
                      }
      Severity: Major
      Found in inc/WPDLib/FieldTypes/Map.php and 1 other location - About 1 hr to fix
      inc/WPDLib/FieldTypes/Map.php on lines 116..118

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 120.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function get_components_results has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              private static function get_components_results( $component_path, $current_children, $class_path_children ) {
                  $results = array();
      
                  if ( '*' == $component_path[0] ) {
                      if ( isset( $component_path[1] ) ) {
      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 validate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              public function validate( $val = null ) {
                  if ( ! $val ) {
                      if ( 'url' === $this->args['store'] ) {
                          return '';
                      }
      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 get has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function get( $component_path, $class_path = '', $single = false ) {
                  $component_path = explode( '.', $component_path, 2 );
                  $class_path = explode( '.', $class_path, 2 );
      
                  $toplevel_components = 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

      Function __construct has a Cognitive Complexity of 15 (exceeds 5 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

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

              public static function add( $component ) {
                  if ( self::is_too_late() ) {
                      return new UtilError( 'too_late_component', sprintf( __( 'Components must not be added later than the %s hook.', 'wpdlib' ), '<code>init</code>' ), '', self::$current_scope );
                  }
      
      
      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 parse has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              public function parse( $val, $formatted = false ) {
                  if ( 'coords' === $this->args['store'] ) {
                      $val = explode( '|', $val );
                      if ( 2 !== count( $val ) ) {
                          return '';
      Severity: Minor
      Found in inc/WPDLib/FieldTypes/Map.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 __construct has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              public function __construct( $type, $args ) {
                  $args = wp_parse_args( $args, array(
                      'repeatable' => array(),
                  ) );
                  if ( ! is_array( $args['repeatable'] ) ) {
      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 parse_bool has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

              private static function parse_bool( $value ) {
                  if ( is_int( $value ) ) {
                      if ( $value > 0 ) {
                          return true;
                      }
      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 init has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              init: function() {
                  var self = WPDLibFieldManager;
      
                  self.select2_args = {
                      width: 'element',
      Severity: Minor
      Found in assets/dist/js/fields.js - About 1 hr to fix

        Function init has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                init: function() {
                    var self = WPDLibFieldManager;
        
                    self.select2_args = {
                        width: 'element',
        Severity: Minor
        Found in assets/src/js/fields.js - About 1 hr to fix

          Method verify_mime_types has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  protected function verify_mime_types( $accepted_types ) {
                      if ( 'all' === $accepted_types ) {
                          return array();
                      }
          
          
          Severity: Minor
          Found in inc/WPDLib/FieldTypes/Media.php - About 1 hr to fix

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

                    public function add( $component ) {
                        if ( ComponentManager::is_too_late() ) {
                            return new UtilError( 'too_late_component', sprintf( __( 'Components must not be added later than the %s hook.', 'wpdlib' ), '<code>init</code>' ), '', ComponentManager::get_scope() );
                        }
            
            
            Severity: Minor
            Found in inc/WPDLib/Components/Base.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 12 (exceeds 5 allowed). Consider refactoring.
            Open

                    protected function display_item( $value, $label, $single_type, $id, $name, $current = '', $echo = true ) {
                        $option_atts = array(
                            'value'    => $value,
                            'selected' => $this->is_value_checked_or_selected( $current, $value ),
                        );
            Severity: Minor
            Found in inc/WPDLib/FieldTypes/Select.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