gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

Method editable_roles has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function editable_roles( $all_roles ) {

        /**
         * Prevent issues when other plugins call get_editable_roles() before `init`.
         *
Severity: Minor
Found in includes/class.llms.user.permissions.php - About 1 hr to fix

    Method llms_is_post_restricted_by_sitewide_membership has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = null ) {
    
        $membership_id = absint( get_option( 'lifterlms_membership_required', '' ) );
    
        // site is restricted to a membership.
    Severity: Minor
    Found in includes/functions/llms.functions.access.php - About 1 hr to fix

      Method sql_where has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function sql_where() {
      
              global $wpdb;
      
              $where = 'WHERE 1';
      Severity: Minor
      Found in includes/notifications/class.llms.notifications.query.php - About 1 hr to fix

        Method lifterlms_template_achievements_loop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function lifterlms_template_achievements_loop( $student = null, $limit = false, $columns = null ) {
        
                // Get the current student if none supplied.
                if ( ! $student ) {
                    $student = llms_get_student();
        Severity: Minor
        Found in includes/functions/llms.functions.templates.achievements.php - About 1 hr to fix

          Method llms_get_endpoint_url has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function llms_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
          
              // Map endpoint to options.
              $vars     = llms()->query->get_query_vars();
              $endpoint = $vars[ $endpoint ] ?? $endpoint;
          Severity: Minor
          Found in includes/functions/llms.functions.page.php - About 1 hr to fix

            Method lifterlms_template_my_memberships_loop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function lifterlms_template_my_memberships_loop( $student = null ) {
            
                    $student = llms_get_student( $student );
                    if ( ! $student ) {
                        return;
            Severity: Minor
            Found in includes/functions/llms.functions.templates.dashboard.php - About 1 hr to fix

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

                              if ( 'remove' !== $btn.attr( 'data-action' ) ) {
              
                                  $btn.text( LLMS.l10n.translate( 'Cancel' ) );
                                  $btn.attr( 'data-action', 'remove' );
                                  $new_row.find( 'input' ).removeAttr( 'disabled' );
              Severity: Major
              Found in assets/js/private/llms-metaboxes.js and 1 other location - About 1 hr to fix
              assets/js/private/llms-metaboxes.js on lines 707..721

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

              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

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

                              if ( 'remove' !== $btn.attr( 'data-action' ) ) {
              
                                  $btn.text( LLMS.l10n.translate( 'Cancel' ) );
                                  $btn.attr( 'data-action', 'remove' );
                                  $new_row.find( 'input' ).removeAttr( 'disabled' );
              Severity: Major
              Found in assets/js/private/llms-metaboxes.js and 1 other location - About 1 hr to fix
              assets/js/private/llms-metaboxes.js on lines 675..696

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

              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

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

                  public function filter_nav_items( $items ) {
              
                      $urls = array(
                          '#llms-signout',
                          '#llms-signin',
              Severity: Minor
              Found in includes/class.llms.nav.menus.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

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

                  get_current_strength: function( format ) {
              
                      format   = format || 'int';
                      var pass = this.$pass.val(),
                          conf = this.$conf && this.$conf.length ? this.$conf.val() : '',
              Severity: Minor
              Found in assets/js/app/llms-password-strength.js - 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

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

                  public function get_results( $args = array() ) {
              
                      $this->title = __( 'Manage Existing Enrollments', 'lifterlms' );
              
                      if ( ! $args ) {

              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 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function save( $post_id ) {
              
                      if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
                          return;
                      }
              Severity: Minor
              Found in includes/admin/post-types/meta-boxes/class.llms.meta.box.coupon.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

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

                  protected function send_file( $file_name, $media_id ) {
                      $server_software = ( isset( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ) : '' );
              
                      if (
                          ( array_key_exists( 'MOD_X_SENDFILE_ENABLED', $_SERVER ) && '1' === $_SERVER['MOD_X_SENDFILE_ENABLED'] ) ||
              Severity: Minor
              Found in includes/class-llms-media-protector.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

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

                  public function get_products( $post_type = 'any' ) {
              
                      global $wpdb;
              
                      $table = $this->get_product_to_voucher_table_name();
              Severity: Minor
              Found in includes/class.llms.voucher.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

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

                  public static function hide_notices() {
                      if ( ( isset( $_GET['llms-hide-notice'] ) || isset( $_GET['llms-remind-notice'] ) ) && isset( $_GET['_llms_notice_nonce'] ) ) {
                          if ( ! llms_verify_nonce( '_llms_notice_nonce', 'llms_hide_notices_nonce', 'GET' ) ) {
                              wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'lifterlms' ) );
                          }
              Severity: Minor
              Found in includes/admin/class.llms.admin.notices.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

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

                  protected function get_data( $key, $data ) {
              
                      $course = llms_get_post( $data );
              
                      switch ( $key ) {
              Severity: Minor
              Found in includes/admin/reporting/tables/llms.table.courses.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

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

                  private function get_table_html() {
              
                      $integrations = llms()->integrations()->get_integrations();
                      ob_start();
                      ?>
              Severity: Minor
              Found in includes/admin/settings/class.llms.settings.integrations.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

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

                  public function output_instructors_assistant_fields( $user ) {
              
                      if ( is_numeric( $user ) || is_a( $user, 'WP_User' ) ) {
                          $instructor = llms_get_instructor( $user );
                          $selected   = $instructor->get( 'parent_instructors' );
              Severity: Minor
              Found in includes/admin/class.llms.admin.user.custom.fields.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

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

                  public function get_results( $args = array() ) {
              
                      $this->title = __( 'Students', 'lifterlms' );
              
                      if ( ! $args ) {
              Severity: Minor
              Found in includes/admin/reporting/tables/llms.table.membership.students.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

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

                  private function get_notification_settings( $controller ) {
              
                      $settings = array();
              
                      // Setup vars.
              Severity: Minor
              Found in includes/admin/settings/class.llms.settings.notifications.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

              Severity
              Category
              Status
              Source
              Language