gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

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

readmeContents.split( '\n' ).forEach( ( line ) => {
    if ( line === startToken ) {
        newReadme.push( line );
        newReadme.push( docsToken );
        addLine = false;
Severity: Major
Found in packages/icons/docs/generate.js and 1 other location - About 3 hrs to fix
packages/dev/src/cmds/docgen.js on lines 51..63

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

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

LLMS_Abstract_Notification_Controller has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class LLMS_Abstract_Notification_Controller extends LLMS_Abstract_Options_Data implements LLMS_Interface_Notification_Controller {

    /**
     * Trigger Identifier
     *
Severity: Minor
Found in includes/abstracts/llms.abstract.notification.controller.php - About 3 hrs to fix

    Method parse_args has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function parse_args() {
    
            // Sanitize post & user ids.
            foreach ( array( 'post_id', 'user_id' ) as $key ) {
    
    
    Severity: Major
    Found in includes/class.llms.query.user.postmeta.php - About 3 hrs to fix

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

      <?php
      /**
       * LifterLMS Course Model
       *
       * @package LifterLMS/Models/Classes
      Severity: Minor
      Found in includes/models/model.llms.course.php - About 3 hrs to fix

        Method get_settings has 82 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_settings() {
        
                /**
                 * Filter the course settings.
                 *
        Severity: Major
        Found in includes/admin/settings/class.llms.settings.courses.php - About 3 hrs to fix

          Method get_settings has 82 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function get_settings() {
          
                  return apply_filters(
                      'lifterlms_membership_settings',
                      array(
          Severity: Major
          Found in includes/admin/settings/class.llms.settings.memberships.php - About 3 hrs to fix

            Method select2_query_posts has 82 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function select2_query_posts() {
            
                    global $wpdb;
            
                    // Grab the search term if it exists.
            Severity: Major
            Found in includes/class.llms.ajax.handler.php - About 3 hrs to fix

              File llms-analytics.js has 303 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              ;/**
               * LifterLMS Admin Reporting Widgets & Charts
               *
               * @since 3.0.0
               * @since 3.17.2 Unknown.
              Severity: Minor
              Found in assets/js/llms-analytics.js - About 3 hrs to fix

                Function save has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function save( $post_id ) {
                
                        if ( ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
                            return -1;
                        }

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

                    private function update_completion_status( $status, $object_id, $object_type, $trigger = 'unspecified' ) {
                
                        $student_id = $this->get_id();
                
                        /**
                Severity: Minor
                Found in includes/models/model.llms.student.php - About 3 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_setup_pending_order has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                Open

                function llms_setup_pending_order( $data = array() ) {
                
                    /**
                     * Filters the order data before setting up the pending order.
                     *
                Severity: Minor
                Found in includes/functions/llms.functions.order.php - About 3 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_update_3160_update_question_data has 81 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

                  Method llms_update_3160_attempt_migration has 80 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function llms_update_3160_attempt_migration() {
                  
                      global $wpdb;
                      $query = $wpdb->get_results( "SELECT user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'llms_quiz_data' LIMIT 100;" ); // db call ok; no-cache ok.
                  
                  
                  Severity: Major
                  Found in includes/functions/updates/llms-functions-updates-3160.php - About 3 hrs to fix

                    File class.llms.template.loader.php has 299 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /**
                     * Template loader
                     *
                     * @package LifterLMS/Classes
                    Severity: Minor
                    Found in includes/class.llms.template.loader.php - About 3 hrs to fix

                      LLMS_Course has 27 functions (exceeds 20 allowed). Consider refactoring.
                      Open

                      class LLMS_Course extends LLMS_Post_Model implements LLMS_Interface_Post_Instructors {
                      
                          use LLMS_Trait_Audio_Video_Embed;
                          use LLMS_Trait_Sales_Page;
                      
                      
                      Severity: Minor
                      Found in includes/models/model.llms.course.php - About 3 hrs to fix

                        Function Edit has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const Edit = ( props ) => {
                            const { attributes, setAttributes } = props;
                            const blockProps = useBlockProps();
                            const isLlmsPostType = useLlmsPostType();
                            const courseOptions = usePostOptions();
                        Severity: Major
                        Found in src/blocks/course-outline/index.jsx - About 3 hrs to fix

                          Method lifterlms_template_student_dashboard_my_grades has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              function lifterlms_template_student_dashboard_my_grades() {
                          
                                  $student = llms_get_student();
                                  if ( ! $student ) {
                                      return;
                          Severity: Major
                          Found in includes/functions/llms.functions.templates.dashboard.php - About 3 hrs to fix

                            File class-llms-block-templates.php has 298 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            /**
                             * LLMS_Block_Templates class file
                             *
                             * @package LifterLMS/Classes
                            Severity: Minor
                            Found in includes/class-llms-block-templates.php - About 3 hrs to fix

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

                                              <PanelRow>
                                                  <NumberControl
                                                      label={ __( 'Per Page', 'lifterlms' ) }
                                                      value={ attributes.posts_per_page }
                                                      min={ -1 }
                              Severity: Major
                              Found in src/blocks/courses/index.jsx and 1 other location - About 3 hrs to fix
                              src/blocks/memberships/index.jsx on lines 123..132

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

                              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

                                              <PanelRow>
                                                  <NumberControl
                                                      label={ __( 'Per Page', 'lifterlms' ) }
                                                      value={ attributes.posts_per_page }
                                                      min={ -1 }
                              Severity: Major
                              Found in src/blocks/memberships/index.jsx and 1 other location - About 3 hrs to fix
                              src/blocks/courses/index.jsx on lines 197..206

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

                              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

                              Severity
                              Category
                              Status
                              Source
                              Language