gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

Function llms_expire_membership has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function llms_expire_membership() {
    global $wpdb;

    // find all memberships wth an expiration date
    $args = array(
Severity: Minor
Found in includes/functions/llms-functions-deprecated.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 llms_update_300_migrate_account_field_options has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

function llms_update_300_migrate_account_field_options() {

    $email_confirm = get_option( 'lifterlms_registration_confirm_email' );
    if ( 'yes' === $email_confirm ) {
        $email_confirm = 'yes';
Severity: Minor
Found in includes/functions/updates/llms-functions-updates-300.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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    public static function handle_page_header_wrappers() {

        /** This filter is documented in templates/loop.php */
        $show_title = apply_filters( 'lifterlms_show_page_title', true );

Severity: Major
Found in includes/theme-support/class-llms-twenty-twenty-two.php and 1 other location - About 2 hrs to fix
includes/theme-support/class-llms-twenty-twenty-one.php on lines 285..300

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

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

    public static function handle_page_header_wrappers() {

        /** This filter is documented in templates/loop.php */
        $show_title = apply_filters( 'lifterlms_show_page_title', true );

Severity: Major
Found in includes/theme-support/class-llms-twenty-twenty-one.php and 1 other location - About 2 hrs to fix
includes/theme-support/class-llms-twenty-twenty-two.php on lines 179..194

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

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

File class.llms.settings.checkout.php has 287 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Admin Settings Page, Checkout Tab
 *
 * @package LifterLMS/Admin/Settings/Classes
Severity: Minor
Found in includes/admin/settings/class.llms.settings.checkout.php - About 2 hrs to fix

    Function llmsPostsSelect2 has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.llmsPostsSelect2 = function( options ) {
    
            var self = this,
                options = options || {},
                defaults = {
    Severity: Major
    Found in assets/js/llms-admin.js - About 2 hrs to fix

      Method llms_update_3160_ensure_no_lesson_dupe_rels has 72 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function llms_update_3160_ensure_no_lesson_dupe_rels() {
      
          if ( 'complete' !== get_transient( 'llms_update_3160_ensure_no_dupe_question_rels_status' ) ) {
              return true;
          }
      Severity: Major
      Found in includes/functions/updates/llms-functions-updates-3160.php - About 2 hrs to fix

        Method get_existing_posts has 71 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function get_existing_posts( $post_type = '', $search_term = '', $page = 1 ) {
        
                $args = array(
                    'order'          => 'ASC',
                    'orderby'        => 'post_title',
        Severity: Major
        Found in includes/admin/class.llms.admin.builder.php - About 2 hrs to fix

          Method llms_get_restriction_message has 71 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function llms_get_restriction_message( $restriction ) {
          
              $msg = __( 'You do not have permission to access this content', 'lifterlms' );
          
              switch ( $restriction['reason'] ) {
          Severity: Major
          Found in includes/functions/llms.functions.access.php - About 2 hrs to fix

            LLMS_Email has 25 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class LLMS_Email {
            
                /**
                 * @var array
                 * @since 3.15.0
            Severity: Minor
            Found in includes/emails/class.llms.email.php - About 2 hrs to fix

              Method output has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function output( $atts ) {
              
                      global $wp;
              
                      $atts = $atts ? $atts : array();
              Severity: Major
              Found in includes/shortcodes/class.llms.shortcode.checkout.php - About 2 hrs to fix

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

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

                  Function menu_item_classes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function menu_item_classes( $menu_items ) {
                  
                          if ( ! function_exists( 'is_lifterlms' ) || ! is_lifterlms() ) {
                              return $menu_items;
                          }
                  Severity: Minor
                  Found in includes/class.llms.nav.menus.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 20 (exceeds 5 allowed). Consider refactoring.
                  Open

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

                      private function get_block_tree( $block, $block_list ) {
                  
                          foreach ( $block_list as &$_block ) {
                  
                              // Found the block.
                  Severity: Minor
                  Found in includes/forms/class-llms-forms.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_options has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function prepare_options( $raw ) {
                  
                          $prepared = array();
                  
                          foreach ( $raw as $key => $val ) {
                  Severity: Minor
                  Found in includes/forms/class-llms-form-field.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 llms_is_post_restricted_by_membership has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function llms_is_post_restricted_by_membership( $post_id, $user_id = null ) {
                  
                      // don't check these posts types.
                      $skip = apply_filters(
                          'llms_is_post_restricted_by_membership_skip_post_types',
                  Severity: Minor
                  Found in includes/functions/llms.functions.access.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 llms_update_3160_update_attempt_question_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function llms_update_3160_update_attempt_question_data() {
                  
                      if ( 'complete' !== get_transient( 'llms_update_3160_update_question_data' ) ) {
                          return true;
                      }
                  Severity: Minor
                  Found in includes/functions/updates/llms-functions-updates-3160.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 bind_llms_order has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          this.bind_llms_order = function() {
                  
                              $( 'button[name="llms-refund-toggle"]' ).on( 'click', function() {
                  
                                  var $btn              = $( this ),
                  Severity: Major
                  Found in assets/js/private/llms-metaboxes.js - About 2 hrs to fix

                    Function Tracking has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    LLMS.Tracking = function( settings ) {
                    
                        settings = settings || {};
                    
                        var self = this,
                    Severity: Major
                    Found in assets/js/app/llms-tracking.js - About 2 hrs to fix
                      Severity
                      Category
                      Status
                      Source
                      Language