gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

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

const Edit = ( props ) => {
    const { attributes, setAttributes } = props;
    const blockProps = useBlockProps();

    const [ users, setUsers ] = useState( [] );
Severity: Major
Found in src/blocks/my-achievements/index.jsx - About 3 hrs to fix

    Method llms_update_3160_ensure_no_dupe_question_rels has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

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

      Function action has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          action: async ( { archive, dir, commitMessage, branch, logfile, prerelease, prereleaseBranch, draft, merge, yes, verbose } ) => {
              // Ensure the CLI is installed before proceeding.
              try {
                  execSync( 'which gh', true );
              } catch ( Error ) {
      Severity: Minor
      Found in packages/dev/src/cmds/release/create.js - 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 get_price_with_coupon has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_price_with_coupon( $key, $coupon_id, $price_args = array(), $format = 'html' ) {
      
              // Allow id or instance to be passed for $coupon_id.
              if ( $coupon_id instanceof LLMS_Coupon ) {
                  $coupon = $coupon_id;
      Severity: Minor
      Found in includes/models/model.llms.access.plan.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 lifterlms_template_student_dashboard_my_notifications has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          function lifterlms_template_student_dashboard_my_notifications() {
      
              $url = llms_get_endpoint_url( 'notifications', '', llms_get_page_url( 'myaccount' ) );
      
              $sections = array(
      Severity: Minor
      Found in includes/functions/llms.functions.templates.dashboard.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

          public static function get_period_filters() {
      
              return array(
                  'today'      => esc_attr__( 'Today', 'lifterlms' ),
                  'yesterday'  => esc_attr__( 'Yesterday', 'lifterlms' ),
      Severity: Major
      Found in includes/admin/reporting/class.llms.admin.reporting.php and 1 other location - About 3 hrs to fix
      includes/abstracts/llms.abstract.notification.view.quiz.completion.php on lines 89..101

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

      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

          protected function set_merge_codes() {
              return array(
                  '{{COURSE_PROGRESS}}' => __( 'Course Progress Bar', 'lifterlms' ),
                  '{{COURSE_TITLE}}'    => __( 'Course Title', 'lifterlms' ),
                  '{{GRADE}}'           => __( 'Grade', 'lifterlms' ),
      includes/admin/reporting/class.llms.admin.reporting.php on lines 259..272

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

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

      <?php
      /**
       * Generate LMS Content from export files or raw arrays of data.
       *
       * @package LifterLMS/Abstracts/Classes
      Severity: Minor
      Found in includes/abstracts/llms-abstract-generator-posts.php - About 3 hrs to fix

        Function MetaboxStudents has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            var MetaboxStudents = function() {
        
                /**
                 * Initialize
                 *
        Severity: Major
        Found in assets/js/llms-metabox-students.js - About 3 hrs to fix

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

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

            LLMS_Abstract_Query has 26 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class LLMS_Abstract_Query {
            
                /**
                 * Identify the extending query.
                 *
            Severity: Minor
            Found in includes/abstracts/llms-abstract-query.php - About 3 hrs to fix

              LLMS_Form_Field has 26 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class LLMS_Form_Field {
              
                  /**
                   * Form Field Settings
                   *
              Severity: Minor
              Found in includes/forms/class-llms-form-field.php - About 3 hrs to fix

                Function setup_field has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        setup_field: function( orig_field, field_index ) {
                
                            var defaults = {
                                classes: [],
                                id: _.uniqueId( orig_field.attribute + '_' ),
                Severity: Major
                Found in assets/js/builder/Views/SettingsFields.js - About 2 hrs to fix

                  Method init has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function init( $user_data, $plan, $gateway, $coupon = false ) {
                  
                          $this->set_user_data( $user_data );
                  
                          // Access plan data.
                  Severity: Major
                  Found in includes/models/model.llms.order.php - About 2 hrs to fix

                    Method get_enrollments has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function get_enrollments( $post_type = 'course', $args = array() ) {
                    
                            global $wpdb;
                    
                            $args = wp_parse_args(
                    Severity: Major
                    Found in includes/models/model.llms.student.php - About 2 hrs to fix

                      Method llms_expire_membership has 74 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function llms_expire_membership() {
                          global $wpdb;
                      
                          // find all memberships wth an expiration date
                          $args = array(
                      Severity: Major
                      Found in includes/functions/llms-functions-deprecated.php - About 2 hrs to fix

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

                        <?php
                        /**
                         * Retrieve data sets used by various other classes and functions
                         *
                         * @package LifterLMS/Classes
                        Severity: Minor
                        Found in includes/class.llms.data.php - About 2 hrs to fix

                          Method llms_create_page has 73 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function llms_create_page( $slug, $title = '', $content = '', $option = '' ) {
                          
                              $option_val = get_option( $option );
                          
                              // See if there's a valid page already stored for the option we're trying to create.
                          Severity: Major
                          Found in includes/admin/llms.functions.admin.php - About 2 hrs to fix

                            Function manage_columns has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function manage_columns( $column, $post_id ) {
                                    global $post;
                            
                                    $order = new LLMS_Order( $post_id );
                            
                            

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

                                public function autoload( $class ) {
                            
                                    $class = strtolower( $class );
                                    if ( 0 !== strpos( $class, 'llms_' ) && 'lifterlms' !== $class && 'meta_box_field_interface' !== $class ) {
                                        return;
                            Severity: Minor
                            Found in includes/class-llms-loader.php - About 2 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

                            Severity
                            Category
                            Status
                            Source
                            Language