gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

File model.llms.user.certificate.php has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LLMS_User_Certificate model class
 *
 * @package LifterLMS/Models/Classes
Severity: Minor
Found in includes/models/model.llms.user.certificate.php - About 2 hrs to fix

    Method get_fields has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_fields() {
    
            $voucher = new LLMS_Voucher( $this->post->ID );
    
            $selected_couses      = $voucher->get_products( 'course' );
    Severity: Major
    Found in includes/admin/post-types/meta-boxes/class.llms.meta.box.voucher.php - About 2 hrs to fix

      Method set_columns has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function set_columns() {
              $cols = array(
                  'id'          => array(
                      'exportable' => true,
                      'sortable'   => true,
      Severity: Major
      Found in includes/admin/reporting/tables/llms.table.course.students.php - About 2 hrs to fix

        Method llms_update_300_update_orders has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function llms_update_300_update_orders() {
        
            $args = array(
                'post_type'      => array( 'llms_order' ),
                'posts_per_page' => -1,
        Severity: Major
        Found in includes/functions/updates/llms-functions-updates-300.php - About 2 hrs to fix

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

              private function output_section( $section, $which ) {
          
                  $url = false;
          
                  if ( 'previous' === $which ) {

          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_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_data( $key, $achievement ) {
          
                  // Handle old object being passed in.
                  if ( ! is_a( $achievement, 'LLMS_User_Achievement' ) && property_exists( $achievement, 'achievement_id' ) ) {
                      $achievement = new LLMS_User_Achievement( $achievement->certificate_id );
          Severity: Minor
          Found in includes/admin/reporting/tables/llms.table.achievements.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 get_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function get_data( $key, $student ) {
          
                  $value = '';
          
                  switch ( $key ) {
          Severity: Minor
          Found in includes/admin/reporting/tables/llms.table.course.students.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 save has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function save( $post_id ) {
          
                  if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) || ! current_user_can( $this->capability, $post_id ) ) {
                      return -1;
                  }
          Severity: Minor
          Found in includes/abstracts/abstract.llms.admin.metabox.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 toArray has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function toArray() {
          
                  $arr = array(
                      'id' => $this->get( 'id' ),
                  );
          Severity: Minor
          Found in includes/abstracts/abstract.llms.post.model.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 prepare_data_for_insert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function prepare_data_for_insert( $posted_data, $fields, $action ) {
          
                  $prepared = array();
          
                  foreach ( $fields as $field ) {
          Severity: Minor
          Found in includes/forms/class-llms-form-handler.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 handle_caps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              public function handle_caps( $allcaps, $cap, $args ) {
          
                  /**
                   * Modify the list of post types that users may not own but can still edit based on instructor permissions on the course
                   *
          Severity: Minor
          Found in includes/class.llms.user.permissions.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 set_merge_data has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function set_merge_data( $code ) {
          
                  $transaction = $this->post;
                  $order       = $transaction->get_order();
          
          

          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 checkout has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

              private static function checkout( $atts ) {
          
                  // if there are membership restrictions, check the user is in at least one membership.
                  // this is to combat CHEATERS.
                  if ( $atts['plan']->has_availability_restrictions() ) {
          Severity: Minor
          Found in includes/shortcodes/class.llms.shortcode.checkout.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 llms_get_date_diff has 56 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function llms_get_date_diff( $time1, $time2, $precision = 2 ) {
              // If not numeric then convert timestamps.
              if ( ! is_numeric( $time1 ) ) {
                  $time1 = strtotime( $time1 );
              }
          Severity: Major
          Found in includes/llms.functions.core.php - About 2 hrs to fix

            Method get_fields has 56 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_fields() {
            
                    $post     = llms_get_post( $this->post );
                    $defaults = llms_get_instructors_defaults();
            
            

              Method get_views has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function get_views( $views ) {
              
                      $post_type       = llms_filter_input_sanitize_string( INPUT_GET, 'post_type' );
                      $current_user_id = get_current_user_id();
                      $exclude_states  = get_post_stati(

                Method get_results has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_results( $args = array() ) {
                
                        $this->title = __( 'Quizzes', 'lifterlms' );
                
                        $args = $this->clean_args( $args );
                Severity: Major
                Found in includes/admin/reporting/tables/llms.table.quizzes.php - About 2 hrs to fix

                  Method llms_update_300_migrate_course_postmeta has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function llms_update_300_migrate_course_postmeta() {
                  
                      global $wpdb;
                  
                      // Rekey meta fields.
                  Severity: Major
                  Found in includes/functions/updates/llms-functions-updates-300.php - About 2 hrs to fix

                    Method lifterlms_template_my_courses_loop has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        function lifterlms_template_my_courses_loop( $student = null, $preview = false ) {
                    
                            $student = llms_get_student( $student );
                            if ( ! $student ) {
                                return;
                    Severity: Major
                    Found in includes/functions/llms.functions.templates.dashboard.php - About 2 hrs to fix

                      File class.llms.controller.orders.php has 259 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * Order processing and related actions controller.
                       *
                       * @package LifterLMS/Controllers/Classes
                      Severity: Minor
                      Found in includes/controllers/class.llms.controller.orders.php - About 2 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language