woocommerce/woocommerce

View on GitHub
includes/admin/reports/class-wc-report-sales-by-date.php

Summary

Maintainability
F
1 wk
Test Coverage

Method query_report_data has 347 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function query_report_data() {
        $this->report_data = new stdClass();

        $this->report_data->order_counts = (array) $this->get_order_report_data(
            array(
Severity: Major
Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

    File class-wc-report-sales-by-date.php has 719 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * WC_Report_Sales_By_Date
     *
     * @package     WooCommerce\Admin\Reports
    Severity: Major
    Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

      Method get_main_chart has 203 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_main_chart() {
              global $wp_locale;
      
              // Prepare data for report.
              $data = array(
      Severity: Major
      Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

        Method get_chart_legend has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_chart_legend() {
                $legend = array();
                $data   = $this->get_report_data();
        
                switch ( $this->chart_groupby ) {
        Severity: Major
        Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 4 hrs to fix

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

                          'data'                => array(
                              'ID'                  => array(
                                  'type'     => 'post_data',
                                  'function' => '',
                                  'name'     => 'refund_id',
          Severity: Major
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 1 other location - About 6 hrs to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 267..318

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

          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

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

                          'data'                => array(
                              'ID'                  => array(
                                  'type'     => 'post_data',
                                  'function' => '',
                                  'name'     => 'refund_id',
          Severity: Major
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 1 other location - About 6 hrs to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 337..388

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

          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 3 locations. Consider refactoring.
          Open

                          'data'         => array(
                              '_order_total'        => array(
                                  'type'     => 'meta',
                                  'function' => 'SUM',
                                  'name'     => 'total_sales',
          Severity: Major
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 2 other locations - About 1 hr to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 218..244
          includes/legacy/api/v1/class-wc-api-reports.php on lines 89..115

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

          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 3 locations. Consider refactoring.
          Open

                          'data'                => array(
                              '_order_total'        => array(
                                  'type'     => 'parent_meta',
                                  'function' => '',
                                  'name'     => 'total_refund',
          Severity: Major
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 2 other locations - About 1 hr to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 176..202
          includes/legacy/api/v1/class-wc-api-reports.php on lines 89..115

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

          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

                      default:
                          $average_total_sales_title = sprintf(
                              /* translators: %s: average total sales */
                              __( '%s average gross monthly sales', 'woocommerce' ),
                              '<strong>' . wc_price( $data->average_total_sales ) . '</strong>'
          Severity: Minor
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 1 other location - About 30 mins to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 457..468

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

          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

                      case 'day':
                          $average_total_sales_title = sprintf(
                              /* translators: %s: average total sales */
                              __( '%s average gross daily sales', 'woocommerce' ),
                              '<strong>' . wc_price( $data->average_total_sales ) . '</strong>'
          Severity: Minor
          Found in includes/admin/reports/class-wc-report-sales-by-date.php and 1 other location - About 30 mins to fix
          includes/admin/reports/class-wc-report-sales-by-date.php on lines 470..481

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

          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