woothemes/woocommerce

View on GitHub
includes/data-stores/class-wc-webhook-data-store.php

Summary

Maintainability
D
2 days
Test Coverage

Method search_webhooks has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function search_webhooks( $args ) {
        global $wpdb;

        $args = wp_parse_args(
            $args,
Severity: Major
Found in includes/data-stores/class-wc-webhook-data-store.php - About 4 hrs to fix

    File class-wc-webhook-data-store.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Webhook Data Store
     *
     * @version  3.3.0
    Severity: Minor
    Found in includes/data-stores/class-wc-webhook-data-store.php - About 3 hrs to fix

      Method update has 41 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function update( &$webhook ) {
              global $wpdb;
      
              $changes = $webhook->get_changes();
              $trigger = isset( $changes['delivery_url'] );
      Severity: Minor
      Found in includes/data-stores/class-wc-webhook-data-store.php - About 1 hr to fix

        Method create has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function create( &$webhook ) {
                global $wpdb;
        
                $changes = $webhook->get_changes();
                if ( isset( $changes['date_created'] ) ) {
        Severity: Minor
        Found in includes/data-stores/class-wc-webhook-data-store.php - About 1 hr to fix

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

              public function read( &$webhook ) {
                  global $wpdb;
          
                  $data = wp_cache_get( $webhook->get_id(), 'webhooks' );
          
          
          Severity: Minor
          Found in includes/data-stores/class-wc-webhook-data-store.php - About 1 hr to fix

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

                public function search_webhooks( $args ) {
                    global $wpdb;
            
                    $args = wp_parse_args(
                        $args,
            Severity: Minor
            Found in includes/data-stores/class-wc-webhook-data-store.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 delete_transients has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                private function delete_transients( $status = '' ) {
            
                    // Always delete the non-filtered cache.
                    delete_transient( $this->get_transient_key( '' ) );
            
            
            Severity: Minor
            Found in includes/data-stores/class-wc-webhook-data-store.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function update( &$webhook ) {
                    global $wpdb;
            
                    $changes = $webhook->get_changes();
                    $trigger = isset( $changes['delivery_url'] );
            Severity: Minor
            Found in includes/data-stores/class-wc-webhook-data-store.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

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

                    if ( ! empty( $args['after'] ) || ! empty( $args['before'] ) ) {
                        $args['after']  = empty( $args['after'] ) ? '0000-00-00' : $args['after'];
                        $args['before'] = empty( $args['before'] ) ? current_time( 'mysql', 1 ) : $args['before'];
            
                        $date_created = "AND `date_created_gmt` BETWEEN STR_TO_DATE('" . esc_sql( $args['after'] ) . "', '%Y-%m-%d %H:%i:%s') and STR_TO_DATE('" . esc_sql( $args['before'] ) . "', '%Y-%m-%d %H:%i:%s')";
            Severity: Major
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 2 hrs to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 302..307

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

            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 ( ! empty( $args['modified_after'] ) || ! empty( $args['modified_before'] ) ) {
                        $args['modified_after']  = empty( $args['modified_after'] ) ? '0000-00-00' : $args['modified_after'];
                        $args['modified_before'] = empty( $args['modified_before'] ) ? current_time( 'mysql', 1 ) : $args['modified_before'];
            
                        $date_modified = "AND `date_modified_gmt` BETWEEN STR_TO_DATE('" . esc_sql( $args['modified_after'] ) . "', '%Y-%m-%d %H:%i:%s') and STR_TO_DATE('" . esc_sql( $args['modified_before'] ) . "', '%Y-%m-%d %H:%i:%s')";
            Severity: Major
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 2 hrs to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 295..300

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

            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

                    $data = array(
                        'status'            => $webhook->get_status( 'edit' ),
                        'name'              => $webhook->get_name( 'edit' ),
                        'user_id'           => $webhook->get_user_id( 'edit' ),
                        'delivery_url'      => $webhook->get_delivery_url( 'edit' ),
            Severity: Major
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 2 hrs to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 42..54

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

            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

                    $data = array(
                        'status'           => $webhook->get_status( 'edit' ),
                        'name'             => $webhook->get_name( 'edit' ),
                        'user_id'          => $webhook->get_user_id( 'edit' ),
                        'delivery_url'     => $webhook->get_delivery_url( 'edit' ),
            Severity: Major
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 2 hrs to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 131..143

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

            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 ( isset( $changes['date_created'] ) ) {
                        $date_created     = $webhook->get_date_created()->date( 'Y-m-d H:i:s' );
                        $date_created_gmt = gmdate( 'Y-m-d H:i:s', $webhook->get_date_created()->getTimestamp() );
                    } else {
                        $date_created     = current_time( 'mysql' );
            Severity: Minor
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 40 mins to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 122..129

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

            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 ( isset( $changes['date_modified'] ) ) {
                        $date_modified     = $webhook->get_date_modified()->date( 'Y-m-d H:i:s' );
                        $date_modified_gmt = gmdate( 'Y-m-d H:i:s', $webhook->get_date_modified()->getTimestamp() );
                    } else {
                        $date_modified     = current_time( 'mysql' );
            Severity: Minor
            Found in includes/data-stores/class-wc-webhook-data-store.php and 1 other location - About 40 mins to fix
            includes/data-stores/class-wc-webhook-data-store.php on lines 28..35

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

            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

            There are no issues that match your filters.

            Category
            Status