gocodebox/lifterlms

View on GitHub
includes/models/model.llms.order.php

Summary

Maintainability
F
6 days
Test Coverage
A
90%

File model.llms.order.php has 908 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LLMS_Order class/model file
 *
 * @package LifterLMS/Models/Classes
Severity: Major
Found in includes/models/model.llms.order.php - About 2 days to fix

    LLMS_Order has 57 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LLMS_Order extends LLMS_Post_Model {
    
        /**
         * Database post type.
         *
    Severity: Major
    Found in includes/models/model.llms.order.php - About 1 day to fix

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

          public function get_transactions( $args = array() ) {
      
              extract(
                  wp_parse_args(
                      $args,
      Severity: Major
      Found in includes/models/model.llms.order.php - About 3 hrs to fix

        Method init has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function init( $user_data, $plan, $gateway, $coupon = false ) {
        
                $this->set_user_data( $user_data );
        
                // Access plan data.
        Severity: Major
        Found in includes/models/model.llms.order.php - About 2 hrs to fix

          Function get_transactions has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_transactions( $args = array() ) {
          
                  extract(
                      wp_parse_args(
                          $args,
          Severity: Minor
          Found in includes/models/model.llms.order.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 init has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              public function init( $user_data, $plan, $gateway, $coupon = false ) {
          
                  $this->set_user_data( $user_data );
          
                  // Access plan data.
          Severity: Minor
          Found in includes/models/model.llms.order.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 add_note has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function add_note( $note, $added_by_user = false ) {
          
                  if ( ! $note ) {
                      return;
                  }
          Severity: Minor
          Found in includes/models/model.llms.order.php - About 1 hr to fix

            Method set_user_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function set_user_data( $user_or_data ) {
            
                    $to_set = array(
                        'user_id'            => '',
                        'billing_email'      => '',
            Severity: Minor
            Found in includes/models/model.llms.order.php - About 1 hr to fix

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

                  public function maybe_schedule_retry() {
              
                      if ( ! $this->can_be_retried() ) {
                          return null;
                      }
              Severity: Minor
              Found in includes/models/model.llms.order.php - About 1 hr to fix

                Method get_transaction_total has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_transaction_total( $type = 'amount' ) {
                
                        $statuses = array( 'llms-txn-refunded' );
                
                        if ( 'amount' === $type ) {
                Severity: Minor
                Found in includes/models/model.llms.order.php - About 1 hr to fix

                  Method record_transaction has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function record_transaction( $data = array() ) {
                  
                          extract(
                              array_merge(
                                  array(
                  Severity: Minor
                  Found in includes/models/model.llms.order.php - About 1 hr to fix

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

                        private function calculate_next_payment_date( $format = 'Y-m-d H:i:s' ) {
                    
                            // If the limited plan has already ended return early.
                            $remaining = $this->get_remaining_payments();
                            if ( 0 === $remaining ) {
                    Severity: Minor
                    Found in includes/models/model.llms.order.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 calculate_next_payment_date has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function calculate_next_payment_date( $format = 'Y-m-d H:i:s' ) {
                    
                            // If the limited plan has already ended return early.
                            $remaining = $this->get_remaining_payments();
                            if ( 0 === $remaining ) {
                    Severity: Minor
                    Found in includes/models/model.llms.order.php - About 1 hr to fix

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

                          public function get_access_expiration_date( $format = 'Y-m-d' ) {
                      
                              $type = $this->get( 'access_expiration' );
                      
                              $ret = $this->get_date( 'date_access_expires', $format );
                      Severity: Minor
                      Found in includes/models/model.llms.order.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 maybe_schedule_payment has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function maybe_schedule_payment( $recalc = true ) {
                      
                              if ( ! $this->is_recurring() ) {
                                  return;
                              }
                      Severity: Minor
                      Found in includes/models/model.llms.order.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 get_recurring_payment_due_date_for_scheduler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function get_recurring_payment_due_date_for_scheduler( $next_payment_date = false, $gmt = false ) {
                      
                              $date = false === $next_payment_date ? $this->get_next_payment_due_date() : $next_payment_date;
                      
                              if ( ! $date ) {
                      Severity: Minor
                      Found in includes/models/model.llms.order.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

                              return apply_filters(
                                  "llms_{$this->model_post_type}_get_creation_args",
                                  array(
                                      'comment_status' => 'closed',
                                      'ping_status'    => 'closed',
                      Severity: Minor
                      Found in includes/models/model.llms.order.php and 1 other location - About 1 hr to fix
                      includes/models/model.llms.transaction.php on lines 193..208

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

                      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