woothemes/woocommerce

View on GitHub
includes/class-wc-order-item.php

Summary

Maintainability
B
6 hrs
Test Coverage

Function get_formatted_meta_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_formatted_meta_data( $hideprefix = '_', $include_all = false ) {
        $formatted_meta    = array();
        $meta_data         = $this->get_meta_data();
        $hideprefix_length = ! empty( $hideprefix ) ? strlen( $hideprefix ) : 0;
        $product           = is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false;
Severity: Minor
Found in includes/class-wc-order-item.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 get_formatted_meta_data has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_formatted_meta_data( $hideprefix = '_', $include_all = false ) {
        $formatted_meta    = array();
        $meta_data         = $this->get_meta_data();
        $hideprefix_length = ! empty( $hideprefix ) ? strlen( $hideprefix ) : 0;
        $product           = is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false;
Severity: Minor
Found in includes/class-wc-order-item.php - About 1 hr to fix

    Function offsetGet has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function offsetGet( $offset ) {
            $this->maybe_read_meta_data();
    
            if ( 'item_meta_array' === $offset ) {
                $return = array();
    Severity: Minor
    Found in includes/class-wc-order-item.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 calculate_taxes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function calculate_taxes( $calculate_tax_for = array() ) {
            if ( ! isset( $calculate_tax_for['country'], $calculate_tax_for['state'], $calculate_tax_for['postcode'], $calculate_tax_for['city'] ) ) {
                return false;
            }
            if ( '0' !== $this->get_tax_class() && 'taxable' === $this->get_tax_status() && wc_tax_enabled() ) {
    Severity: Minor
    Found in includes/class-wc-order-item.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

    Avoid too many return statements within this method.
    Open

                return $meta_values[ $offset ];
    Severity: Major
    Found in includes/class-wc-order-item.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return null;
      Severity: Major
      Found in includes/class-wc-order-item.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return $meta_values[ '_' . $offset ];
        Severity: Major
        Found in includes/class-wc-order-item.php - About 30 mins to fix

          Function offsetSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function offsetSet( $offset, $value ) {
                  if ( 'item_meta_array' === $offset ) {
                      foreach ( $value as $meta_id => $meta ) {
                          $this->update_meta_data( $meta->key, $meta->value, $meta_id );
                      }
          Severity: Minor
          Found in includes/class-wc-order-item.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

          There are no issues that match your filters.

          Category
          Status