gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

Function llms_bulk_delete_user_postmeta has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    function llms_bulk_delete_user_postmeta( $user_id, $post_id, $data = array() ) {

        $res = array_fill_keys( array_keys( $data ), null );
        $err = false;

Severity: Minor
Found in includes/functions/llms.functions.user.postmeta.php - About 1 hr 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 toggle_switch has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        toggle_switch: function( event ) {

            event.stopPropagation();
            var $el      = $( event.target ),
                attr     = $el.attr( 'name' ),
Severity: Minor
Found in assets/js/builder/Views/_Editable.js - About 1 hr to fix

    Function options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                            options: function() {
    
                                var options = [
                                    {
                                        key: '',
    Severity: Minor
    Found in assets/js/builder/Schemas/Lesson.js - About 1 hr to fix

      Function get_available_prereq_options has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              get_available_prereq_options: function() {
      
                  var parent_section_index    = this.get_parent().collection.indexOf( this.get_parent() ),
                      lesson_index_in_section = this.collection.indexOf( this ),
                      options                 = [];
      Severity: Minor
      Found in assets/js/builder/Models/Lesson.js - About 1 hr to fix

        Function createUser has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function createUser( opts = {} ) {
            await visitAdminPage( 'user-new.php' );
        
            const login = `mock_${ Math.random().toString( 36 ).slice( 2 ) }`;
            opts = Object.assign(
        Severity: Minor
        Found in packages/llms-e2e-test-utils/src/create-user.js - About 1 hr to fix

          Method get_post_type_filter_html has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function get_post_type_filter_html( $name, $post_type = 'course', $selected = array() ) {
          
                  $id = sprintf( 'filter-by-llms-post-%s', $post_type );
          
                  $obj = get_post_type_object( $post_type );
          Severity: Minor
          Found in includes/admin/post-types/class.llms.post.tables.php - About 1 hr to fix

            Method get_css has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_css( $rule = '', $echo = true ) {
            
                    if ( empty( $rule ) ) {
                        return '';
                    }
            Severity: Minor
            Found in includes/class.llms.emails.php - About 1 hr to fix

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

                  public function get_fields() {
              
                      $next_id = llms_get_certificate_sequential_id( $this->post->ID );
              
                      $fields = array(

                Method save has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

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

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

                      public function output() {
                  
                          global $post;
                  
                          if ( ! in_array( $post->post_type, array( 'course', 'llms_membership' ) ) ) {

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

                        public function get_fields() {
                    
                            $fields = array();
                    
                            if ( 'llms_achievement' === $this->post->post_type ) {

                      Method calculate_grade_from_children has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          private function calculate_grade_from_children( $children, $student ) {
                      
                              $grade  = null;
                              $grades = array();
                      
                      
                      Severity: Minor
                      Found in includes/class-llms-grades.php - About 1 hr to fix

                        Method output_table_filters_html has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function output_table_filters_html() {
                                $select_id     = sprintf( '%1$s-%2$s-filter', $this->id, 'course-membership' );
                                $instructor_id = null;
                                // Limit Course/Membership results based on instructor access.
                                if ( ! current_user_can( 'view_others_lifterlms_reports' ) && current_user_can( 'view_lifterlms_reports' ) ) {
                        Severity: Minor
                        Found in includes/admin/reporting/tables/llms.table.students.php - About 1 hr to fix

                          Method set_query has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function set_query() {
                          
                                  global $wpdb;
                          
                                  $dates = $this->get_posted_dates();

                            Method get_custom_schemas has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                private static function get_custom_schemas() {
                            
                                    $quiz_fields = array();
                            
                                    /**
                            Severity: Minor
                            Found in includes/admin/class.llms.admin.builder.php - About 1 hr to fix

                              Method block_templates_from_db has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function block_templates_from_db( $slugs = array() ) {
                              
                                      $query_args = array(
                                          'post_status'    => array( 'auto-draft', 'draft', 'publish' ),
                                          'post_type'      => 'wp_template',
                              Severity: Minor
                              Found in includes/class-llms-block-templates.php - About 1 hr to fix

                                Method calculate_next_payment_date has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    private function calculate_next_payment_date( $format = 'Y-m-d H:i:s' ) {
                                
                                        // If the limited plan has already ended return early.
                                        $remaining = $this->get_remaining_payments();
                                        if ( 0 === $remaining ) {
                                Severity: Minor
                                Found in includes/models/model.llms.order.php - About 1 hr to fix

                                  Method get_checkout_url has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public function get_checkout_url( $check_availability = true ) {
                                  
                                          $ret       = '#llms-plan-locked';
                                          $available = $this->is_available_to_user( get_current_user_id() );
                                  
                                  
                                  Severity: Minor
                                  Found in includes/models/model.llms.access.plan.php - About 1 hr to fix

                                    Method get_merge_data has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        protected function get_merge_data() {
                                    
                                            $template_id   = $this->get( 'parent' );
                                            $user_id       = $this->get_user_id();
                                            $related_id    = $this->get( 'related' );
                                    Severity: Minor
                                    Found in includes/models/model.llms.user.certificate.php - About 1 hr to fix

                                      Method insert_incompletion_postmeta has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                      Open

                                          private function insert_incompletion_postmeta( $object_id, $trigger = 'unspecified' ) {
                                      
                                              global $wpdb;
                                      
                                              // Add '_is_complete' to the user postmeta table for object.
                                      Severity: Minor
                                      Found in includes/models/model.llms.student.php - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language