woothemes/woocommerce

View on GitHub
includes/legacy/api/v3/class-wc-api-taxes.php

Summary

Maintainability
D
2 days
Test Coverage

File class-wc-api-taxes.php has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce API Taxes Class
 *
 * Handles requests to the /taxes endpoint
Severity: Minor
Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 5 hrs to fix

    Function bulk has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function bulk( $data ) {
            try {
                if ( ! isset( $data['taxes'] ) ) {
                    throw new WC_API_Exception( 'woocommerce_api_missing_taxes_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'taxes' ), 400 );
                }
    Severity: Minor
    Found in includes/legacy/api/v3/class-wc-api-taxes.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 edit_tax has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        public function edit_tax( $id, $data ) {
            try {
                if ( ! isset( $data['tax'] ) ) {
                    throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'tax' ), 400 );
                }
    Severity: Minor
    Found in includes/legacy/api/v3/class-wc-api-taxes.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

    Method edit_tax has 52 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function edit_tax( $id, $data ) {
            try {
                if ( ! isset( $data['tax'] ) ) {
                    throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'tax' ), 400 );
                }
    Severity: Major
    Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 2 hrs to fix

      Method create_tax has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function create_tax( $data ) {
              try {
                  if ( ! isset( $data['tax'] ) ) {
                      throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'tax' ), 400 );
                  }
      Severity: Minor
      Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 1 hr to fix

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

            public function bulk( $data ) {
                try {
                    if ( ! isset( $data['taxes'] ) ) {
                        throw new WC_API_Exception( 'woocommerce_api_missing_taxes_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'taxes' ), 400 );
                    }
        Severity: Minor
        Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 1 hr to fix

          Method get_tax has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_tax( $id, $fields = null ) {
                  global $wpdb;
          
                  try {
                      $id = absint( $id );
          Severity: Minor
          Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 1 hr to fix

            Function create_tax has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function create_tax( $data ) {
                    try {
                        if ( ! isset( $data['tax'] ) ) {
                            throw new WC_API_Exception( 'woocommerce_api_missing_tax_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'tax' ), 400 );
                        }
            Severity: Minor
            Found in includes/legacy/api/v3/class-wc-api-taxes.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 register_routes has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function register_routes( $routes ) {
            
                    # GET/POST /taxes
                    $routes[ $this->base ] = array(
                        array( array( $this, 'get_taxes' ), WC_API_Server::READABLE ),
            Severity: Minor
            Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 1 hr to fix

              Method query_tax_rates has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function query_tax_rates( $args, $count_only = false ) {
                      global $wpdb;
              
                      $results = '';
              
              
              Severity: Minor
              Found in includes/legacy/api/v3/class-wc-api-taxes.php - About 1 hr to fix

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

                    public function get_tax( $id, $fields = null ) {
                        global $wpdb;
                
                        try {
                            $id = absint( $id );
                Severity: Minor
                Found in includes/legacy/api/v3/class-wc-api-taxes.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

                There are no issues that match your filters.

                Category
                Status