gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

File _Editable.js has 326 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Handles UX and Events for inline editing of views
 *
 * Use with a Model's View
 * Allows editing model.title field via .llms-editable-title elements
Severity: Minor
Found in assets/js/builder/Views/_Editable.js - About 3 hrs to fix

    File llms.abstract.notification.view.php has 326 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Notification View Abstract
     *
     * @package LifterLMS/Abstracts/Classes
    Severity: Minor
    Found in includes/abstracts/llms.abstract.notification.view.php - About 3 hrs to fix

      Function llms_update_300_update_orders has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      function llms_update_300_update_orders() {
      
          $args = array(
              'post_type'      => array( 'llms_order' ),
              'posts_per_page' => -1,
      Severity: Minor
      Found in includes/functions/updates/llms-functions-updates-300.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_current_user_can has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      function llms_current_user_can( $cap, $obj_id = null ) {
      
          $caps  = LLMS_Roles::get_all_core_caps();
          $grant = false;
      
      
      Severity: Minor
      Found in includes/functions/llms.functions.person.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

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

          it( 'should return errors when an array is not submitted for the attributions list', () => {
              const { valid, errors, warnings } = getChangelogValidationIssues( { attributions: 1, type: 'changed', significance: 'patch', entry: 'Valid.' }, false );
      
              expect( valid ).toStrictEqual( false );
              expect( warnings ).toStrictEqual( [] );
      Severity: Major
      Found in packages/dev/test/utils/validate-changelog.test.js and 1 other location - About 3 hrs to fix
      packages/dev/test/utils/validate-changelog.test.js on lines 138..144

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

      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

          it( 'should return errors when an array is not submitted for the links list', () => {
              const { valid, errors, warnings } = getChangelogValidationIssues( { links: 1, type: 'changed', significance: 'patch', entry: 'Valid.' }, false );
      
              expect( valid ).toStrictEqual( false );
              expect( warnings ).toStrictEqual( [] );
      Severity: Major
      Found in packages/dev/test/utils/validate-changelog.test.js and 1 other location - About 3 hrs to fix
      packages/dev/test/utils/validate-changelog.test.js on lines 130..136

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

      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 get_transactions has 92 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_transactions( $args = array() ) {
      
              extract(
                  wp_parse_args(
                      $args,
      Severity: Major
      Found in includes/models/model.llms.order.php - About 3 hrs to fix

        Method get_tabs has 92 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function get_tabs() {
        
                $tabs = array(
                    'dashboard'         => array(
                        'content'  => 'lifterlms_template_student_dashboard_home',
        Severity: Major
        Found in includes/class.llms.student.dashboard.php - About 3 hrs to fix

          LLMS_Access_Plan has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class LLMS_Access_Plan extends LLMS_Post_Model {
          
              /**
               * Map of meta properties => type.
               *
          Severity: Minor
          Found in includes/models/model.llms.access.plan.php - About 3 hrs to fix

            File Sync.js has 318 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /**
             * Sync builder data to the server
             *
             * @since 3.16.0
             * @version 4.17.0
            Severity: Minor
            Found in assets/js/builder/Controllers/Sync.js - About 3 hrs to fix

              File class-llms-privacy-exporters.php has 318 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * LifterLMS Privacy Exporter
               *
               * @package LifterLMS/Privacy/Classes
              Severity: Minor
              Found in includes/privacy/class-llms-privacy-exporters.php - About 3 hrs to fix

                Method save_fields has 90 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function save_fields( $settings ) {
                
                        // phpcs:disable WordPress.Security.NonceVerification.Missing -- nonce is checked in self::save().
                        if ( empty( $_POST ) ) {
                            return false;
                Severity: Major
                Found in includes/admin/class.llms.admin.settings.php - About 3 hrs to fix

                  Method get_data has 89 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function get_data( $key, $data ) {
                  
                          $quiz = llms_get_post( $data );
                  
                          switch ( $key ) {
                  Severity: Major
                  Found in includes/admin/reporting/tables/llms.table.quizzes.php - About 3 hrs to fix

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

                        public static function output() {
                    
                            global $post;
                    
                            $course_id = isset( $_GET['course_id'] ) ? absint( $_GET['course_id'] ) : null;
                    Severity: Major
                    Found in includes/admin/class.llms.admin.builder.php - About 3 hrs to fix

                      File abstract.llms.payment.gateway.php has 315 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * LifterLMS Payment Gateways Abstract
                       *
                       * @package LifterLMS/Abstracts/Classes
                      Severity: Minor
                      Found in includes/abstracts/abstract.llms.payment.gateway.php - About 3 hrs to fix

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

                                $strings = array(
                        
                                    'active'           => __( 'Active', 'lifterlms' ),
                                    'inactive'         => __( 'Inactive', 'lifterlms' ),
                        
                        
                        Severity: Major
                        Found in includes/models/model.llms.add-on.php and 1 other location - About 3 hrs to fix
                        includes/class-llms-block-templates.php on lines 678..689

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

                        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

                                return array(
                                    'archive-course'             => esc_html__( 'LifterLMS Course Catalog Template', 'lifterlms' ),
                                    'archive-llms_membership'    => esc_html__( 'LifterLMS Membership Catalog Template', 'lifterlms' ),
                                    'single-certificate'         => esc_html__( 'LifterLMS Certificate Template', 'lifterlms' ),
                                    'single-no-access'           => esc_html__( 'LifterLMS Single Template Access Restricted', 'lifterlms' ),
                        Severity: Major
                        Found in includes/class-llms-block-templates.php and 1 other location - About 3 hrs to fix
                        includes/models/model.llms.add-on.php on lines 212..229

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

                        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.accounts.php has 314 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

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

                          Method set_order_data_query has 88 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function set_order_data_query( $args = array() ) {
                          
                                  extract(
                                      wp_parse_args(
                                          $args,
                          Severity: Major
                          Found in includes/abstracts/abstract.llms.analytics.widget.php - About 3 hrs to fix

                            LLMS_Question has 29 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class LLMS_Question extends LLMS_Post_Model {
                            
                                /**
                                 * Database post type name
                                 *
                            Severity: Minor
                            Found in includes/models/model.llms.question.php - About 3 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language