gocodebox/lifterlms

View on GitHub
includes/class.llms.post-types.php

Summary

Maintainability
F
3 wks
Test Coverage
A
97%

Method register_post_types has 615 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function register_post_types() {
        $permalinks = llms_get_permalink_structure();

        // Course.
        $catalog_id = llms_get_page_id( 'shop' );
Severity: Major
Found in includes/class.llms.post-types.php - About 3 days to fix

    File class.llms.post-types.php has 1102 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Register Post Types, Taxonomies, Statuses.
     *
     * @package LifterLMS/Classes
    Severity: Major
    Found in includes/class.llms.post-types.php - About 2 days to fix

      Method register_taxonomies has 210 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function register_taxonomies() {
      
              $permalinks = llms_get_permalink_structure();
      
              // Course cat.
      Severity: Major
      Found in includes/class.llms.post-types.php - About 1 day to fix

        Method get_order_statuses has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function get_order_statuses() {
        
                $statuses = array(
        
                    // Single payment only.
        Severity: Minor
        Found in includes/class.llms.post-types.php - About 1 hr to fix

          Method register_post_statuses has 41 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function register_post_statuses() {
          
                  $order_statuses = self::get_order_statuses();
          
                  $txn_statuses = apply_filters(
          Severity: Minor
          Found in includes/class.llms.post-types.php - About 1 hr to fix

            Method register_certificate_post_type has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function register_certificate_post_type( $post_type, $labels, $args, $rewrite_slug, $admin_cap ) {
            
                    $user_can = current_user_can( $admin_cap );
                    $supports = array( 'title', 'editor', 'thumbnail' );
            
            
            Severity: Minor
            Found in includes/class.llms.post-types.php - About 1 hr to fix

              Method get_post_type_caps has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function get_post_type_caps( $post_type ) {
              
                      if ( ! is_array( $post_type ) ) {
                          $singular = $post_type;
                          $plural   = $post_type . 's';
              Severity: Minor
              Found in includes/class.llms.post-types.php - About 1 hr to fix

                Method register_certificate_post_type has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private static function register_certificate_post_type( $post_type, $labels, $args, $rewrite_slug, $admin_cap ) {
                Severity: Minor
                Found in includes/class.llms.post-types.php - About 35 mins to fix

                  Function register_post_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function register_post_type( $name, $data ) {
                  
                          if ( ! post_type_exists( $name ) ) {
                  
                              $unprefixed_name = str_replace( 'llms_', '', $name );
                  Severity: Minor
                  Found in includes/class.llms.post-types.php - About 25 mins 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

                          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

                          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

                  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

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

                                  'labels'              => array(
                                      'name'                  => __( 'Achievement Templates', 'lifterlms' ),
                                      'singular_name'         => __( 'Achievement Template', 'lifterlms' ),
                                      'add_new'               => __( 'Add Achievement Template', 'lifterlms' ),
                                      'add_new_item'          => __( 'Add New Achievement Template', '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 839..858

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

                  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

                                  'labels'              => array(
                                      'name'                  => __( 'Awarded Achievements', 'lifterlms' ),
                                      'singular_name'         => __( 'Awarded Achievement', 'lifterlms' ),
                                      'add_new'               => __( 'Award Achievement', 'lifterlms' ),
                                      'add_new_item'          => __( 'Award New Achievement', '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 800..819

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

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

                                  'labels'              => array(
                                      'name'               => __( 'Reviews', 'lifterlms' ),
                                      'singular_name'      => __( 'Review', 'lifterlms' ),
                                      'menu_name'          => _x( 'Reviews', 'Admin menu name', 'lifterlms' ),
                                      'add_new'            => __( 'Add Review', 'lifterlms' ),
                  Severity: Major
                  Found in includes/class.llms.post-types.php and 2 other locations - About 6 hrs to fix
                  includes/class.llms.post-types.php on lines 456..471
                  includes/class.llms.post-types.php on lines 645..660

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

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

                                  'labels'              => array(
                                      'name'               => __( 'Courses', 'lifterlms' ),
                                      'singular_name'      => __( 'Course', 'lifterlms' ),
                                      'menu_name'          => _x( 'Courses', 'Admin menu name', 'lifterlms' ),
                                      'add_new'            => __( 'Add Course', 'lifterlms' ),
                  Severity: Major
                  Found in includes/class.llms.post-types.php and 2 other locations - About 6 hrs to fix
                  includes/class.llms.post-types.php on lines 645..660
                  includes/class.llms.post-types.php on lines 1060..1075

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

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

                                  'labels'              => array(
                                      'name'               => __( 'Memberships', 'lifterlms' ),
                                      'singular_name'      => __( 'Membership', 'lifterlms' ),
                                      'menu_name'          => _x( 'Memberships', 'Admin menu name', 'lifterlms' ),
                                      'add_new'            => __( 'Add Membership', 'lifterlms' ),
                  Severity: Major
                  Found in includes/class.llms.post-types.php and 2 other locations - About 6 hrs to fix
                  includes/class.llms.post-types.php on lines 456..471
                  includes/class.llms.post-types.php on lines 1060..1075

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

                  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

                              array(
                                  'name'               => __( 'Awarded Certificates', 'lifterlms' ),
                                  'singular_name'      => __( 'Awarded Certificate', 'lifterlms' ),
                                  'add_new'            => __( 'Award Certificate', 'lifterlms' ),
                                  'add_new_item'       => __( 'Award New Certificate', 'lifterlms' ),
                  Severity: Major
                  Found in includes/class.llms.post-types.php and 1 other location - About 5 hrs to fix
                  includes/class.llms.post-types.php on lines 888..902

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

                  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

                              array(
                                  'name'               => __( 'Certificate Templates', 'lifterlms' ),
                                  'singular_name'      => __( 'Certificate Template', 'lifterlms' ),
                                  'add_new'            => __( 'Add Certificate Template', 'lifterlms' ),
                                  'add_new_item'       => __( 'Add New Certificate Template', 'lifterlms' ),
                  Severity: Major
                  Found in includes/class.llms.post-types.php and 1 other location - About 5 hrs to fix
                  includes/class.llms.post-types.php on lines 920..934

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status