felixarntz/widgets-definitely

View on GitHub

Showing 16 of 16 total issues

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

var pluginheader =     'Plugin Name: ' + config.pluginName + '\n' +
                    'Plugin URI:  ' + config.pluginURI + '\n' +
                    'Description: ' + config.description + '\n' +
                    'Version:     ' + config.version + '\n' +
                    'Author:      ' + config.author + '\n' +
Severity: Major
Found in gulpfile.js and 1 other location - About 5 hrs to fix
gulpfile.js on lines 55..64

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 153.

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

var readmeheader =    'Plugin Name:       ' + config.pluginName + '\n' +
                    'Plugin URI:        ' + config.pluginURI + '\n' +
                    'Author:            ' + config.author + '\n' +
                    'Author URI:        ' + config.authorURI + '\n' +
                    'Contributors:      ' + config.contributors + '\n' +
Severity: Major
Found in gulpfile.js and 1 other location - About 5 hrs to fix
gulpfile.js on lines 43..52

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 153.

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 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

    Similar blocks of code found in 2 locations. 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: Major
    Found in inc/WPWD/App.php and 1 other location - About 1 hr to fix
    inc/WPWD/App.php on lines 218..227

    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 104.

    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

            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: Major
    Found in inc/WPWD/App.php and 1 other location - About 1 hr to fix
    inc/WPWD/App.php on lines 199..208

    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 104.

    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

    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