gocodebox/lifterlms

View on GitHub

Showing 1,386 of 1,391 total issues

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

const Edit = ( props ) => {
    const { attributes } = props;
    const blockProps = useBlockProps();
    const courseOptions = usePostOptions();

Severity: Major
Found in src/blocks/course-reviews/index.jsx and 3 other locations - About 1 day to fix
src/blocks/course-continue/index.jsx on lines 21..64
src/blocks/course-meta-info/index.jsx on lines 21..62
src/blocks/course-prerequisites/index.jsx on lines 18..59

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

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

const Edit = ( props ) => {
    const { attributes } = props;
    const blockProps = useBlockProps();
    const courseOptions = usePostOptions();

Severity: Major
Found in src/blocks/course-meta-info/index.jsx and 3 other locations - About 1 day to fix
src/blocks/course-continue/index.jsx on lines 21..64
src/blocks/course-prerequisites/index.jsx on lines 18..59
src/blocks/course-reviews/index.jsx on lines 18..59

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

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

        self::register_post_type(
            'llms_coupon',
            array(
                'labels'              => array(
                    'name'               => __( 'Coupons', 'lifterlms' ),
Severity: Major
Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
includes/class.llms.post-types.php on lines 1022..1054

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

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

        self::register_post_type(
            'llms_voucher',
            array(
                'labels'              => array(
                    'name'               => __( 'Vouchers', 'lifterlms' ),
Severity: Major
Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
includes/class.llms.post-types.php on lines 987..1019

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

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

<?php
/**
 * LLMS_Processor_Achievement_Sync class
 *
 * @package LifterLMS/Processors/Classes
includes/processors/class-llms-processor-certificate-sync.php on lines 1..99

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

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

<?php
/**
 * LLMS_Processor_Certificate_Sync class
 *
 * @package LifterLMS/Processors/Classes
includes/processors/class-llms-processor-achievement-sync.php on lines 1..99

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

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

<?php
/**
 * LifterLMS Admin Course Builder
 *
 * @package LifterLMS/Admin/Classes
Severity: Major
Found in includes/admin/class.llms.admin.builder.php - About 1 day to fix

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

        public function get_settings() {
            $account_settings = array(
                array(
                    'class' => 'top',
                    'id'    => 'course_account_options',
    Severity: Major
    Found in includes/admin/settings/class.llms.settings.accounts.php - About 1 day to fix

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

          $( '.achievement_image_button' ).click( function( e ) {
      
              // Create Media Manager On Click to allow multiple on one Page
              var achievement_uploader;
      
      
      Severity: Major
      Found in assets/js/llms-metabox-achievement.js and 1 other location - About 1 day to fix
      assets/js/llms-metabox-certificate.js on lines 3..42

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

      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

          $( '.certificate_image_button' ).click(function(e) {
      
              // Create Media Manager On Click to allow multiple on one Page
              var certificate_uploader;
      
      
      Severity: Major
      Found in assets/js/llms-metabox-certificate.js and 1 other location - About 1 day to fix
      assets/js/llms-metabox-achievement.js on lines 4..43

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

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

      <?php
      /**
       * Admin Settings and fields
       *
       * @package LifterLMS/Admin/Classes
      Severity: Major
      Found in includes/admin/class.llms.admin.settings.php - About 1 day to fix

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

                self::register_post_type(
                    'llms_access_plan',
                    array(
                        'labels'              => array(
                            'name'               => __( 'Access Plans', 'lifterlms' ),
        Severity: Major
        Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
        includes/class.llms.post-types.php on lines 494..525

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

        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

                self::register_post_type(
                    'section',
                    array(
                        'labels'              => array(
                            'name'               => __( 'Sections', 'lifterlms' ),
        Severity: Major
        Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
        includes/class.llms.post-types.php on lines 1092..1130

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

        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 abstract.llms.post.model.php has 646 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * LLMS_Post_Model abstract class file
         *
         * @package LifterLMS/Abstracts/Classes
        Severity: Major
        Found in includes/abstracts/abstract.llms.post.model.php - About 1 day to fix

          Function Analytics has 287 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              var Analytics = function( opts ) {
          
                  if ( ! $( '#llms-analytics-json' ).length ) {
                      return;
                  }
          Severity: Major
          Found in assets/js/llms-analytics.js - About 1 day to fix

            Function output_field has a Cognitive Complexity of 67 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function output_field( $field ) {
            
                    // Set missing values with defaults.
                    $field = self::set_field_defaults( $field );
            
            
            Severity: Minor
            Found in includes/admin/class.llms.admin.settings.php - About 1 day 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_checkout has 262 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                var llms_checkout = function() {
            
                    /**
                     * Array of validation functions to call on form submission
                     *
            Severity: Major
            Found in assets/js/llms-form-checkout.js - About 1 day to fix

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

                      self::register_taxonomy(
                          'course_cat',
                          array( 'course' ),
                          array(
                              'label'             => __( 'Course Categories', 'lifterlms' ),
              Severity: Major
              Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
              includes/class.llms.post-types.php on lines 1379..1409

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

              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

                      self::register_taxonomy(
                          'course_track',
                          array( 'course' ),
                          array(
                              'label'             => __( 'Course Track', 'lifterlms' ),
              Severity: Major
              Found in includes/class.llms.post-types.php and 1 other location - About 1 day to fix
              includes/class.llms.post-types.php on lines 1282..1312

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

              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 llms_update_3160_attempt_migration has a Cognitive Complexity of 65 (exceeds 5 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: Minor
              Found in includes/functions/updates/llms-functions-updates-3160.php - About 1 day 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