felixarntz/widgets-definitely

View on GitHub

Showing 12 of 16 total issues

Function validate_widget_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate_widget_options( $widget_options, $widget_options_old ) {
            $widget_options_validated = array();

            $errors = array();

Severity: Minor
Found in inc/WPWD/Components/Widget.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 get_template_part has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

        protected function get_template_part( $args, $instance ) {
            $sidebar_slug = $args['id'];

            do_action( 'get_template_part_' . $this->slug, $this->slug, $sidebar_slug );

Severity: Minor
Found in inc/WPWD/Widget.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 has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

        public function validate( $parent = null ) {
            $status = parent::validate( $parent );

            if ( $status === true ) {
                if ( is_array( $this->args['class'] ) ) {
Severity: Minor
Found in inc/WPWD/Components/Field.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 render has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        public function render( $widget_options, $parent_widget = null ) {
            if ( null === $parent_widget ) {
                $parent_widget = $this->get_parent();
            }

Severity: Minor
Found in inc/WPWD/Components/Section.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 validate_widget_options has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function validate_widget_options( $widget_options, $widget_options_old ) {
            $widget_options_validated = array();

            $errors = array();

Severity: Minor
Found in inc/WPWD/Components/Widget.php - About 1 hr to fix

    Method get_template_part has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            protected function get_template_part( $args, $instance ) {
                $sidebar_slug = $args['id'];
    
                do_action( 'get_template_part_' . $this->slug, $this->slug, $sidebar_slug );
    
    
    Severity: Minor
    Found in inc/WPWD/Widget.php - About 1 hr to fix

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

              public function render_form( $widget_options ) {
                  //TODO: of course the following does not work; create manual errors here
                  settings_errors( $this->slug );
      
                  /**
      Severity: Minor
      Found in inc/WPWD/Components/Widget.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 add_sections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              protected function add_sections( $sections, $widget ) {
                  foreach ( $sections as $section_slug => $section_args ) {
                      $section = $widget->add( new Section( $section_slug, $section_args ) );
                      if ( is_wp_error( $section ) ) {
                          self::doing_it_wrong( __METHOD__, $section->get_error_message(), '0.5.0' );
      Severity: Minor
      Found in inc/WPWD/App.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 validate_widget_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              public function validate_widget_option( $widget_option = null, $skip_required = false ) {
                  if ( $this->args['required'] && ! $skip_required ) {
                      if ( $widget_option === null || $this->_field->is_empty( $widget_option ) ) {
                          return new WPError( 'invalid_empty_value', __( 'No value was provided for the required field.', 'widgets-definitely' ) );
                      }
      Severity: Minor
      Found in inc/WPWD/Components/Field.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_widgets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              protected function add_widgets( $widgets ) {
                  foreach ( $widgets as $widget_slug => $widget_args ) {
                      $widget = $this->add( new Widget( $widget_slug, $widget_args ) );
                      if ( is_wp_error( $widget ) ) {
                          self::doing_it_wrong( __METHOD__, $widget->get_error_message(), '0.5.0' );
      Severity: Minor
      Found in inc/WPWD/App.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 render has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              public function render( $widget_option, $parent_widget = null, $parent_section = null ) {
                  if ( null === $parent_section ) {
                      $parent_section = $this->get_parent();
                  }
                  if ( null === $parent_widget ) {
      Severity: Minor
      Found in inc/WPWD/Components/Field.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 maybe_enqueue_assets has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

              public function maybe_enqueue_assets() {
                  if ( is_active_widget( false, false, $this->id_base, true ) ) {
                      if ( is_callable( $this->args['enqueue_callback'] ) ) {
                          call_user_func( $this->args['enqueue_callback'] );
                      } else {
      Severity: Minor
      Found in inc/WPWD/Widget.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