gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

Function is_open has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function is_open( $user_id = null ) {

        $student = llms_get_student( $user_id );
        if ( ! $student ) {
            $quiz_open = false;
Severity: Minor
Found in includes/models/model.llms.quiz.php - About 55 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

Function quiz_start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function quiz_start( $request ) {

        $err = new WP_Error();

        $student = llms_get_student();
Severity: Minor
Found in includes/class.llms.ajax.handler.php - About 55 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

Function init has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function init( $args ) {

        $this->student    = new WP_User( $args['person_id'] );
        $this->email_post = get_post( $args['email_id'] );

Severity: Minor
Found in includes/emails/class.llms.email.engagement.php - About 55 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

Function validate_field_number has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validate_field_number( $posted_value, $field ) {

        $temp_value = str_replace( ',', '', $posted_value );
        if ( ! is_numeric( $temp_value ) ) {
            // Translators: %1$s field label or name; %2$s = user submitted value.
Severity: Minor
Found in includes/forms/class-llms-form-validator.php - About 55 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

Function maybe_run_actions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function maybe_run_actions() {

        if ( ! llms_verify_nonce( '_llms_quiz_attempt_nonce', 'llms_quiz_attempt_actions', 'POST' ) ) {
            return;
        }
Severity: Minor
Found in includes/controllers/class.llms.controller.admin.quiz.attempts.php - About 55 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

Function validate_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function validate_field( $posted_value, $field ) {

        // Validate field by type.
        $type_map = array(
            'email'  => array( $this, 'validate_field_email' ),
Severity: Minor
Found in includes/forms/class-llms-form-validator.php - About 55 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

Function find_block has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    private function find_block( $id, $blocks, $parent_index = null ) {

        foreach ( $blocks as $index => $block ) {

            if ( ! empty( $block['attrs']['id'] ) && $id === $block['attrs']['id'] ) {
Severity: Minor
Found in includes/forms/class-llms-forms-dynamic-fields.php - About 55 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

Function llms_get_restriction_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function llms_get_restriction_message( $restriction ) {

    $msg = __( 'You do not have permission to access this content', 'lifterlms' );

    switch ( $restriction['reason'] ) {
Severity: Minor
Found in includes/functions/llms.functions.access.php - About 55 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

Function get_notifications has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_notifications() {

        $notifications = array();
        $results       = $this->get_results();

Severity: Minor
Found in includes/notifications/class.llms.notifications.query.php - About 55 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

Function llms_update_450_migrate_events_open_sessions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function llms_update_450_migrate_events_open_sessions() {

    $limit = 200;
    $skip  = get_transient( 'llms_450_skipper_events_open_sessions' );
    if ( ! $skip ) {
Severity: Minor
Found in includes/functions/updates/llms-functions-updates-450.php - About 55 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

Function replace_default_sidebars has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public static function replace_default_sidebars( $widgets ) {

        if ( is_singular( 'course' ) || is_singular( 'lesson' ) ) {

            $sidebar_id = self::get_theme_default_sidebar();
Severity: Minor
Found in includes/class.llms.sidebars.php - About 55 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

Function llms_can_gateway_be_used_for_plan_or_order has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

function llms_can_gateway_be_used_for_plan_or_order( $gateway_id, $plan_or_order, $wp_err = false, $enabled_only = true ) {

    $can_use = true;

    $plan_or_order = is_numeric( $plan_or_order ) ? llms_get_post( $plan_or_order ) : $plan_or_order;
Severity: Minor
Found in includes/functions/llms.functions.order.php - About 55 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

Function lifterlms_get_archive_description has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    function lifterlms_get_archive_description() {

        $content = '';
        $page_id = false;

Severity: Minor
Found in includes/functions/llms.functions.templates.loop.php - About 55 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 3 locations. Consider refactoring.
Open

        if ( ! whichOpts.includes( which ) ) {
            logResult( `Unknown argument: "${ chalk.bold( which ) }".`, 'error' );
            process.exit( 1 );
        }
Severity: Major
Found in packages/dev/src/cmds/changelog/version.js and 2 other locations - About 55 mins to fix
packages/dev/src/cmds/changelog/write.js on lines 253..256
packages/dev/src/cmds/update-version.js on lines 179..182

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

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

        if ( ! semver.valid( version ) ) {
            logResult( `The supplied version string ${ chalk.bold( version ) } is invalid.`, 'error' );
            process.exit( 1 );
        }
Severity: Major
Found in packages/dev/src/cmds/update-version.js and 2 other locations - About 55 mins to fix
packages/dev/src/cmds/changelog/version.js on lines 17..20
packages/dev/src/cmds/changelog/write.js on lines 253..256

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

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

        } else if ( ! semver.valid( version ) ) {
            logResult( `The supplied version string ${ chalk.bold( version ) } is invalid.`, 'error' );
            process.exit( 1 );
        }
Severity: Major
Found in packages/dev/src/cmds/changelog/write.js and 2 other locations - About 55 mins to fix
packages/dev/src/cmds/changelog/version.js on lines 17..20
packages/dev/src/cmds/update-version.js on lines 179..182

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

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

    action: ( { significance, type, comment, entry, interactive, links, attributions, dir, title, useEditor } ) => {
        if ( ! entry && ! interactive ) {
            logResult( 'A changelog entry is required.', 'error' );
            process.exit( 1 );
        }
Severity: Minor
Found in packages/dev/src/cmds/changelog/add.js and 1 other location - About 55 mins to fix
src/js/admin-certificate-editor/document-settings.js on lines 32..63

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

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

function CertificateDocumentSettings( { type, title, sequentialId, background, height, margins, orientation, size, unit, width } ) {
    return (

        <PluginDocumentSettingPanel
            className="llms-certificate-doc-settings"
Severity: Minor
Found in src/js/admin-certificate-editor/document-settings.js and 1 other location - About 55 mins to fix
packages/dev/src/cmds/changelog/add.js on lines 113..176

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

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

        $rows = array(
            'STUDENT_NAME' => __( 'Student', 'lifterlms' ),
            'QUIZ_TITLE'   => __( 'Quiz', 'lifterlms' ),
            'LESSON_TITLE' => __( 'Lesson', 'lifterlms' ),
            'COURSE_TITLE' => __( 'Course', 'lifterlms' ),
includes/admin/reporting/class.llms.admin.reporting.php on lines 322..329
includes/llms.functions.core.php on lines 328..335
includes/llms.functions.core.php on lines 336..343

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

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

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

        if ( 'any' !== $this->filter ) {

            $serialized_id = serialize(
                array(
                    'id' => absint( $this->filter ),
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.courses.php and 1 other location - About 55 mins to fix
includes/admin/reporting/tables/llms.table.memberships.php on lines 214..231

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

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

Severity
Category
Status
Source
Language