woothemes/woocommerce

View on GitHub
includes/class-wc-structured-data.php

Summary

Maintainability
D
2 days
Test Coverage

Method generate_product_data has 126 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function generate_product_data( $product = null ) {
        if ( ! is_object( $product ) ) {
            global $product;
        }

Severity: Major
Found in includes/class-wc-structured-data.php - About 5 hrs to fix

    File class-wc-structured-data.php has 355 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Structured data's handler and generator using JSON-LD format.
     *
     * @package WooCommerce\Classes
    Severity: Minor
    Found in includes/class-wc-structured-data.php - About 4 hrs to fix

      Method generate_order_data has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generate_order_data( $order, $sent_to_admin = false, $plain_text = false ) {
              if ( $plain_text || ! is_a( $order, 'WC_Order' ) ) {
                  return;
              }
      
      
      Severity: Major
      Found in includes/class-wc-structured-data.php - About 3 hrs to fix

        Function generate_product_data has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generate_product_data( $product = null ) {
                if ( ! is_object( $product ) ) {
                    global $product;
                }
        
        
        Severity: Minor
        Found in includes/class-wc-structured-data.php - About 3 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 generate_order_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generate_order_data( $order, $sent_to_admin = false, $plain_text = false ) {
                if ( $plain_text || ! is_a( $order, 'WC_Order' ) ) {
                    return;
                }
        
        
        Severity: Minor
        Found in includes/class-wc-structured-data.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 generate_breadcrumblist_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function generate_breadcrumblist_data( $breadcrumbs ) {
                $crumbs = $breadcrumbs->get_breadcrumb();
        
                if ( empty( $crumbs ) || ! is_array( $crumbs ) ) {
                    return;
        Severity: Minor
        Found in includes/class-wc-structured-data.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 get_structured_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_structured_data( $types ) {
                $data = array();
        
                // Put together the values of same type of structured data.
                foreach ( $this->get_data() as $value ) {
        Severity: Minor
        Found in includes/class-wc-structured-data.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