gocodebox/lifterlms

View on GitHub

Showing 1,386 of 1,391 total issues

Function bind_llms_membership has 114 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        this.bind_llms_membership = function() {

            var $table = $( '.llms-mb-list._llms_content_table' );

            /**
Severity: Major
Found in assets/js/private/llms-metaboxes.js - About 4 hrs to fix

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

        public function get_certificates( $args_or_orderby = 'updated_date', $order = 'DESC', $return = 'obj' ) {
    
            // New behavior.
            if ( is_array( $args_or_orderby ) ) {
                return $this->get_awards( $args_or_orderby, 'certificate' );
    Severity: Major
    Found in includes/traits/llms-trait-student-awards.php and 1 other location - About 4 hrs to fix
    includes/traits/llms-trait-student-awards.php on lines 37..70

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

    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

        public function get_achievements( $args_or_orderby = 'updated_date', $order = 'DESC', $return = 'obj' ) {
    
            // New behavior.
            if ( is_array( $args_or_orderby ) ) {
                return $this->get_awards( $args_or_orderby, 'achievement' );
    Severity: Major
    Found in includes/traits/llms-trait-student-awards.php and 1 other location - About 4 hrs to fix
    includes/traits/llms-trait-student-awards.php on lines 131..164

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

    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 3 locations. Consider refactoring.
    Open

        protected function set_merge_codes() {
            return array(
                '{{CUSTOMER_ADDRESS}}'   => __( 'Customer Address', 'lifterlms' ),
                '{{CUSTOMER_NAME}}'      => __( 'Customer Name', 'lifterlms' ),
                '{{CUSTOMER_PHONE}}'     => __( 'Customer Phone', 'lifterlms' ),
    includes/notifications/views/class.llms.notification.view.manual.payment.due.php on lines 126..140
    includes/notifications/views/class.llms.notification.view.upcoming.payment.reminder.php on lines 146..160

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

    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 3 locations. Consider refactoring.
    Open

        protected function set_merge_codes() {
            return array(
                '{{CUSTOMER_ADDRESS}}'   => __( 'Customer Address', 'lifterlms' ),
                '{{CUSTOMER_NAME}}'      => __( 'Customer Name', 'lifterlms' ),
                '{{CUSTOMER_PHONE}}'     => __( 'Customer Phone', 'lifterlms' ),
    includes/notifications/views/class.llms.notification.view.manual.payment.due.php on lines 126..140
    includes/notifications/views/class.llms.notification.view.payment.retry.php on lines 130..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 173.

    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 3 locations. Consider refactoring.
    Open

        protected function set_merge_codes() {
            return array(
                '{{CUSTOMER_ADDRESS}}'   => __( 'Customer Address', 'lifterlms' ),
                '{{CUSTOMER_NAME}}'      => __( 'Customer Name', 'lifterlms' ),
                '{{CUSTOMER_PHONE}}'     => __( 'Customer Phone', 'lifterlms' ),
    includes/notifications/views/class.llms.notification.view.payment.retry.php on lines 130..144
    includes/notifications/views/class.llms.notification.view.upcoming.payment.reminder.php on lines 146..160

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

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

    class LLMS_AJAX_Handler {
        /**
         * Queue all members of a membership to be enrolled into a specific course
         *
         * Triggered from the auto-enrollment tab of a membership.
    Severity: Minor
    Found in includes/class.llms.ajax.handler.php - About 4 hrs to fix

      File model.llms.quiz.attempt.php has 354 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * Quiz Attempt Model
       *
       * @package LifterLMS/Models/Classes
      Severity: Minor
      Found in includes/models/model.llms.quiz.attempt.php - About 4 hrs to fix

        Function get_existing_posts has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function get_existing_posts( $post_type = '', $search_term = '', $page = 1 ) {
        
                $args = array(
                    'order'          => 'ASC',
                    'orderby'        => 'post_title',
        Severity: Minor
        Found in includes/admin/class.llms.admin.builder.php - About 4 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 lifterlms_course_continue_button has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
        Open

            function lifterlms_course_continue_button( $post_id = null, $student = null, $progress = null ) {
        
                if ( ! $post_id ) {
                    $post_id = get_the_ID();
                    if ( ! $post_id ) {
        Severity: Minor
        Found in includes/llms.template.functions.php - About 4 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 Edit has 108 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const Edit = ( props ) => {
            const { attributes, setAttributes } = props;
            const blockProps = useBlockProps();
        
            const { categories, memberships } = useSelect( ( select ) => {
        Severity: Major
        Found in src/blocks/memberships/index.jsx - About 4 hrs to fix

          Method get_schema has 108 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function get_schema() {
          
                  global $wpdb;
          
                  $collate = '';
          Severity: Major
          Found in includes/class.llms.install.php - About 4 hrs to fix

            File llms.functions.access.php has 346 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Functions used for managing page / post access
             *
             * @package LifterLMS/Functions
            Severity: Minor
            Found in includes/functions/llms.functions.access.php - About 4 hrs to fix

              File abstract.llms.admin.table.php has 345 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Admin Table Abstract
               *
               * @package LifterLMS/Abstracts/Classes
              Severity: Minor
              Found in includes/abstracts/abstract.llms.admin.table.php - About 4 hrs to fix

                Function update_questions has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function update_questions( $questions, $parent ) {
                
                        $res = array();
                
                        foreach ( $questions as $q_data ) {
                Severity: Minor
                Found in includes/admin/class.llms.admin.builder.php - About 4 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_post_type_caps has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                    private static function get_post_type_caps( $role ) {
                
                        $caps = array();
                
                        // Students get nothing.
                Severity: Minor
                Found in includes/class.llms.roles.php - About 4 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 lifterlms_student_dashboard has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
                Open

                    function lifterlms_student_dashboard( $options = array() ) {
                
                        $options = wp_parse_args(
                            $options,
                            array(
                Severity: Minor
                Found in includes/functions/llms.functions.templates.dashboard.php - About 4 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 get_data has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_data( $key, $student ) {
                
                        switch ( $key ) {
                
                            case 'achievements':
                Severity: Major
                Found in includes/admin/reporting/tables/llms.table.students.php - About 4 hrs to fix

                  Method llms_insert_access_plan has 105 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function llms_insert_access_plan( $props = array() ) {
                  
                      $action = 'create';
                  
                      if ( ! empty( $props['id'] ) ) {
                  Severity: Major
                  Found in includes/functions/llms-functions-access-plans.php - About 4 hrs to fix

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

                                if ( is_post_type_archive( 'course' ) || $query->get( 'page_id' ) == llms_get_page_id( 'courses' ) || is_tax( array( 'course_cat', 'course_tag', 'course_difficulty', 'course_track' ) ) ) {
                    
                                    $query->set( 'posts_per_page', get_option( 'lifterlms_shop_courses_per_page', 10 ) );
                    
                                    $sorting = explode( ',', get_option( 'lifterlms_shop_ordering', 'menu_order,ASC' ) );
                    Severity: Major
                    Found in includes/class.llms.query.php and 1 other location - About 4 hrs to fix
                    includes/class.llms.query.php on lines 230..247

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

                    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