gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

                quiz: {
                    class: 'Quiz',
                    conditional: function( model ) {
                        // if quiz is enabled OR not enabled but we have some quiz data as an obj
                        return ( 'yes' === model.get( 'quiz_enabled' ) || ! _.isEmpty( model.get( 'quiz' ) ) );
Severity: Major
Found in assets/js/builder/Models/Lesson.js and 1 other location - About 1 hr to fix
assets/js/builder/Models/Lesson.js on lines 430..438

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

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

            this.relationships.children.assignment = {
                class: 'Assignment',
                conditional: function( model ) {
                    // If assignment is enabled OR not enabled but we have some assignment data as an obj.
                    return ( 'yes' === model.get( 'assignment_enabled' ) || ! _.isEmpty( model.get( 'assignment' ) ) );
Severity: Major
Found in assets/js/builder/Models/Lesson.js and 1 other location - About 1 hr to fix
assets/js/builder/Models/Lesson.js on lines 22..30

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

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

    check_strength: function() {

        var $pass_field = this.$pass.closest( '.llms-form-field' ),
            $conf_field = this.$conf && this.$conf.length ? this.$conf.closest( '.llms-form-field' ) : null,
            pass_length = this.$pass.val().length,
Severity: Minor
Found in assets/js/app/llms-password-strength.js - 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 BaseSearchControl has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export default function BaseSearchControl( {
    searchPath,
    onUpdate = () => {},
    selectedValue = [],
    additionalSearchArgs = {},
Severity: Minor
Found in packages/components/src/search-control/base-search-control.js - 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 calculate_grade_from_children has a Cognitive Complexity of 13 (exceeds 5 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

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

    private function validate_upload( $file ) {

        if ( ! empty( $file['error'] ) ) {

            switch ( $file['error'] ) {
Severity: Minor
Found in includes/admin/class.llms.admin.import.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 sql_where has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function sql_where() {

        global $wpdb;

        $sql = 'WHERE 1';
Severity: Minor
Found in includes/class.llms.query.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 update_section has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private static function update_section( $section_data, $course_id ) {

        $res = array_merge(
            $section_data,
            array(
Severity: Minor
Found in includes/admin/class.llms.admin.builder.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 get_export_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_export_data( $key, $student ) {

        switch ( $key ) {

            case 'id':
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.students.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 admin_header has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function admin_header() {

        // Assume we should not show our header.
        $show_header = false;

Severity: Minor
Found in includes/admin/class-llms-admin-header.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 set_merge_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_merge_data( $code ) {

        $quiz_id = $this->notification->get( 'post_id' );
        $attempt = $this->user->quizzes()->get_last_completed_attempt( $quiz_id );
        if ( ! $attempt ) {

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

    protected function should_track_client_events() {

        $ret = false;

        /**
Severity: Minor
Found in includes/class-llms-events.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 get_overall_grade has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_overall_grade( $use_cache = true ) {

        $grade = null;

        // Attempt to pull from the cache first.
Severity: Minor
Found in includes/models/model.llms.student.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 select2_query_posts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public static function select2_query_posts() {

        global $wpdb;

        // Grab the search term if it exists.
Severity: Minor
Found in includes/class.llms.ajax.handler.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 prepare_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    protected function prepare_value() {

        // Never autoload passwords and or fields with an explicit value (except radio and checkbox).
        if ( 'password' === $this->settings['type'] || ! empty( $this->settings['value'] && ! in_array( $this->settings['type'], array( 'checkbox', 'radio' ), true ) ) ) {
            return;
Severity: Minor
Found in includes/forms/class-llms-form-field.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 llms_get_user_postmeta has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    function llms_get_user_postmeta( $user_id, $post_id, $meta_key = null, $single = true, $return = 'meta_value' ) {

        $single = is_null( $meta_key ) ? false : $single;

        $res = array();
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

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

    $html = sprintf(
        '<strong>%1$s</strong><br><br>%2$s<br><br>%3$s',
        __( 'Welcome to LifterLMS 6.0.0!', 'lifterlms' ),
        __( "This new version brings you the power to build and customize certificates using the WordPress block editor! Start building beautiful certificates using all the blocks you're already familiar, the new Certificate Title block, and new certificate settings like page size (Letter or A4, for example), orientation, background color, and more. In addition to design features, this version also adds the ability to modify already-awarded certificates and achievements and to sync template updates with the click of a button.", 'lifterlms' ),
        sprintf(
Severity: Major
Found in includes/functions/updates/llms-functions-updates-600.php and 1 other location - About 1 hr to fix
includes/functions/updates/llms-functions-updates-500.php on lines 64..80

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

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

    $html = sprintf(
        '<strong>%1$s</strong><br><br>%2$s<br><br>%3$s',
        __( 'Welcome to LifterLMS 5.0!', 'lifterlms' ),
        __( 'This new version of LifterLMS brings you the power to build and customize your student information forms using a simple point and click interface constructed on top of the WordPress block editor. Customization like the removal of default fields, changing the text of field labels, or reordering fields within a form is all possible without any code or professional help.', 'lifterlms' ),
        sprintf(
Severity: Major
Found in includes/functions/updates/llms-functions-updates-500.php and 1 other location - About 1 hr to fix
includes/functions/updates/llms-functions-updates-600.php on lines 120..136

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

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

Method get_data has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function get_data( $key, $attempt ) {

        switch ( $key ) {

            case 'student':
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.quiz.attempts.php - About 1 hr to fix

    Method get_price_with_coupon has 39 lines of code (exceeds 25 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 1 hr to fix
      Severity
      Category
      Status
      Source
      Language