gocodebox/lifterlms

View on GitHub

Showing 1,389 of 1,394 total issues

Function get_current_location has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function get_current_location() {

        if ( is_llms_checkout() ) {

            return 'checkout';
Severity: Minor
Found in includes/forms/class-llms-forms-admin-bar.php - About 35 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_password_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function find_password_fields( $location ) {

        $forms = LLMS_Forms::instance();
        $all   = $forms->get_form_fields( $location );

Severity: Minor
Found in includes/class.llms.person.handler.php - About 35 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_login_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function validate_login_fields( $data ) {

        $err = new WP_Error();

        $fields = self::get_login_fields();
Severity: Minor
Found in includes/class.llms.person.handler.php - About 35 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 add_required_block_fields has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function add_required_block_fields( $fields_to_require, $blocks, $location ) {

        $blocks_to_add = array();
        foreach ( $fields_to_require as $field_id => $block_to_add ) {

Severity: Minor
Found in includes/forms/class-llms-forms-dynamic-fields.php - About 35 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_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_html() {

        /**
         * Short-circuit field HTML generation.
         *
Severity: Minor
Found in includes/forms/class-llms-form-field.php - About 35 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 update has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function update() {

        if ( ! llms_verify_nonce( '_llms_update_person_nonce', 'llms_update_person' ) ) {
            return;
        }
Severity: Minor
Found in includes/forms/controllers/class.llms.controller.account.php - About 35 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 update_caps has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private static function update_caps( $role, $type = 'add', $exclude_groups = array() ) {

        $role_caps = self::get_all_caps( $role->name );
        $role_caps = empty( $exclude_groups ) ? $role_caps : array_diff_key( $role_caps, array_flip( $exclude_groups ) );

Severity: Minor
Found in includes/class.llms.roles.php - About 35 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 has_username_block has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function has_username_block( $blocks ) {

        foreach ( $blocks as $block ) {

            if ( 'llms/form-field-user-login' === $block['blockName'] ) {
Severity: Minor
Found in includes/forms/class-llms-forms-data.php - About 35 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 set_merge_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_merge_data( $code ) {

        switch ( $code ) {

            case '{{COURSE_PROGRESS}}':

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 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function sql_where() {

        global $wpdb;

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

    protected function set_merge_data( $code ) {

        $achievement = new LLMS_User_Achievement( $this->post );

        switch ( $code ) {

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 7 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_merge_data( $code ) {

        switch ( $code ) {

            case '{{COURSE_PROGRESS}}':

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function lifterlms_template_achievements_loop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    function lifterlms_template_achievements_loop( $student = null, $limit = false, $columns = null ) {

        // Get the current student if none supplied.
        if ( ! $student ) {
            $student = llms_get_student();
Severity: Minor
Found in includes/functions/llms.functions.templates.achievements.php - About 35 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_is_post_restricted_by_sitewide_membership has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function llms_is_post_restricted_by_sitewide_membership( $post_id, $user_id = null ) {

    $membership_id = absint( get_option( 'lifterlms_membership_required', '' ) );

    // site is restricted to a membership.
Severity: Minor
Found in includes/functions/llms.functions.access.php - About 35 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_3160_update_quiz_to_lesson_rels has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function llms_update_3160_update_quiz_to_lesson_rels() {

    if ( 'complete' !== get_transient( 'llms_update_3160_update_attempt_question_data' ) ) {
        return true;
    }
Severity: Minor
Found in includes/functions/updates/llms-functions-updates-3160.php - About 35 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_300_migrate_course_postmeta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function llms_update_300_migrate_course_postmeta() {

    global $wpdb;

    // Rekey meta fields.
Severity: Minor
Found in includes/functions/updates/llms-functions-updates-300.php - About 35 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_template_certificates_loop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    function lifterlms_template_certificates_loop( $student = null, $limit = false ) {

        // Get the current student if none supplied.
        if ( ! $student ) {
            $student = llms_get_student();
Severity: Minor
Found in includes/functions/llms.functions.templates.certificates.php - About 35 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 rest_filter_products_with_active_subscriptions_error_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function rest_filter_products_with_active_subscriptions_error_message( $response, $handler, $request ) {

        if ( is_wp_error( $response ) ) {
            foreach ( $response->errors as $code => &$data ) {
                // Error code can be produced by our rest-api or by wp core.
Severity: Minor
Found in includes/class.llms.post.relationships.php - About 35 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_course_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private function get_course_id() {

        global $post;
        $post_id = isset( $post->ID ) ? $post->ID : null;

Severity: Minor
Found in includes/shortcodes/class.llms.shortcode.course.outline.php - About 35 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

        relationships: {
            parent: {
                model: 'course',
                type: 'model',
            },
Severity: Minor
Found in assets/js/builder/Models/Section.js and 1 other location - About 35 mins to fix
assets/js/builder/Models/Quiz.js on lines 29..41

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

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