gocodebox/lifterlms

View on GitHub

Showing 1,386 of 1,391 total issues

File llms-functions-updates-300.php has 428 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Update functions for version 3.0.0
 *
 * @package LifterLMS/Functions/Updates
Severity: Minor
Found in includes/functions/updates/llms-functions-updates-300.php - About 6 hrs to fix

    Method get_settings_default has 156 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function get_settings_default() {
    
            $currency_code_options = get_lifterlms_currencies();
            foreach ( $currency_code_options as $code => $name ) {
                $currency_code_options[ $code ] = $name . ' (' . get_lifterlms_currency_symbol( $code ) . ')';
    Severity: Major
    Found in includes/admin/settings/class.llms.settings.checkout.php - About 6 hrs to fix

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

      const Edit = ( props ) => {
          const { attributes, setAttributes } = props;
          const blockProps = useBlockProps();
          const [ accessPlans, setAccessPlans ] = useState( [
              {
      Severity: Major
      Found in src/blocks/access-plan-button/index.jsx - About 6 hrs to fix

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

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

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

            private static function update_lessons( $lessons, $section ) {
        
                $ret = array();
        
                foreach ( $lessons as $lesson_data ) {
        Severity: Minor
        Found in includes/admin/class.llms.admin.builder.php - About 6 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

        LLMS_Admin_Table has 44 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class LLMS_Admin_Table extends LLMS_Abstract_Exportable_Admin_Table {
        
            /**
             * Unique ID for the Table.
             *
        Severity: Minor
        Found in includes/abstracts/abstract.llms.admin.table.php - About 6 hrs to fix

          File llms-metabox-product.js has 415 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          /**
           * Product Options MetaBox.
           *
           * Displays on Course & Membership Post Types.
           *
          Severity: Minor
          Found in assets/js/llms-metabox-product.js - About 5 hrs to fix

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

                public function get_fields() {
            
                    $triggers = llms_get_engagement_triggers();
            
                    $types = llms_get_engagement_types();

              Method llms_update_300_create_access_plans has 149 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function llms_update_300_create_access_plans() {
              
                  $courses = new WP_Query(
                      array(
                          'post_type'      => array( 'course', 'llms_membership' ),
              Severity: Major
              Found in includes/functions/updates/llms-functions-updates-300.php - About 5 hrs to fix

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

                            array(
                                'name'               => __( 'Awarded Certificates', 'lifterlms' ),
                                'singular_name'      => __( 'Awarded Certificate', 'lifterlms' ),
                                'add_new'            => __( 'Award Certificate', 'lifterlms' ),
                                'add_new_item'       => __( 'Award New Certificate', 'lifterlms' ),
                Severity: Major
                Found in includes/class.llms.post-types.php and 1 other location - About 5 hrs to fix
                includes/class.llms.post-types.php on lines 888..902

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

                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

                            array(
                                'name'               => __( 'Certificate Templates', 'lifterlms' ),
                                'singular_name'      => __( 'Certificate Template', 'lifterlms' ),
                                'add_new'            => __( 'Add Certificate Template', 'lifterlms' ),
                                'add_new_item'       => __( 'Add New Certificate Template', 'lifterlms' ),
                Severity: Major
                Found in includes/class.llms.post-types.php and 1 other location - About 5 hrs to fix
                includes/class.llms.post-types.php on lines 920..934

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

                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

                Method query_students has 144 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function query_students() {
                
                        _deprecated_function( __METHOD__, '6.2.0', 'the REST API list students endpoint' );
                
                        // Grab the search term if it exists.
                Severity: Major
                Found in includes/class.llms.ajax.handler.php - About 5 hrs to fix

                  Function update_custom_schemas has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function update_custom_schemas( $type, $post, $post_data ) {
                  
                          $schemas = self::get_custom_schemas();
                          if ( empty( $schemas[ $type ] ) ) {
                              return;
                  Severity: Minor
                  Found in includes/admin/class.llms.admin.builder.php - About 5 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

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

                          return array(
                              '{{CUSTOMER_ADDRESS}}'   => __( 'Customer Address', 'lifterlms' ),
                              '{{CUSTOMER_NAME}}'      => __( 'Customer Name', 'lifterlms' ),
                              '{{CUSTOMER_PHONE}}'     => __( 'Customer Phone', 'lifterlms' ),
                              '{{ORDER_ID}}'           => __( 'Order ID', 'lifterlms' ),
                  includes/llms.functions.core.php on lines 464..479

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

                  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

                          array(
                              'user_registration'      => __( 'Student creates a new account', 'lifterlms' ),
                              'access_plan_purchased'  => __( 'Student Purchases an Access Plan', 'lifterlms' ),
                              'course_enrollment'      => __( 'Student enrolls in a course', 'lifterlms' ),
                              'course_purchased'       => __( 'Student purchases a course', 'lifterlms' ),
                  Severity: Major
                  Found in includes/llms.functions.core.php and 1 other location - About 5 hrs to fix
                  includes/notifications/views/class.llms.notification.view.purchase.receipt.php on lines 88..102

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

                  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_Payment_Gateway has 42 functions (exceeds 20 allowed). Consider refactoring.
                  Open

                  abstract class LLMS_Payment_Gateway extends LLMS_Abstract_Options_Data {
                  
                      /**
                       * Optional gateway description for the admin panel
                       *
                  Severity: Minor
                  Found in includes/abstracts/abstract.llms.payment.gateway.php - About 5 hrs to fix

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

                        public function get_fields() {
                    
                            $lesson = llms_get_post( $this->post );
                    
                            $methods = array(
                    Severity: Major
                    Found in includes/admin/post-types/meta-boxes/class.llms.meta.box.lesson.php - About 5 hrs to fix

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

                          public function save( $post_id ) {
                      
                              if ( ! empty( llms_filter_input( INPUT_POST, 'llms_generate_export' ) ) || ! llms_verify_nonce( 'lifterlms_meta_nonce', 'lifterlms_save_data' ) ) {
                                  return false;
                              }
                      Severity: Minor
                      Found in includes/admin/post-types/meta-boxes/class.llms.meta.box.voucher.php - About 5 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

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

                      ;/* global LLMS, $ */
                      /* jshint strict: true */
                      
                      /**
                       * Front End Quiz Class
                      Severity: Minor
                      Found in assets/js/llms-quiz.js - About 5 hrs to fix

                        File class.llms.install.php has 395 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * LLMS_Install class file
                         *
                         * @package LifterLMS/Classes
                        Severity: Minor
                        Found in includes/class.llms.install.php - About 5 hrs to fix
                          Severity
                          Category
                          Status
                          Source
                          Language