gocodebox/lifterlms

View on GitHub

Showing 1,420 of 1,425 total issues

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

                    array(
                        'class'            => 'input-full',
                        'controller'       => '#' . $this->prefix . 'enrollment_period',
                        'controller_value' => 'yes',
                        'default'          => sprintf( __( 'Enrollment in this course opens on [lifterlms_course_info id="%d" key="enrollment_start_date"].', 'lifterlms' ), $this->post->ID ),
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 233..243
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 272..282
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 283..293

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

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

                    array(
                        'class'            => 'input-full',
                        'controller'       => '#' . $this->prefix . 'enrollment_period',
                        'controller_value' => 'yes',
                        'default'          => sprintf( __( 'Enrollment in this course closed on [lifterlms_course_info id="%d" key="enrollment_end_date"].', 'lifterlms' ), $this->post->ID ),
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 222..232
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 272..282
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 283..293

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

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

                    array(
                        'class'            => 'input-full',
                        'controller'       => '#' . $this->prefix . 'time_period',
                        'controller_value' => 'yes',
                        'default'          => sprintf( __( 'This course opens on [lifterlms_course_info id="%d" key="start_date"].', 'lifterlms' ), $this->post->ID ),
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 222..232
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 233..243
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 283..293

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

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

                    array(
                        'class'            => 'input-full',
                        'controller'       => '#' . $this->prefix . 'time_period',
                        'controller_value' => 'yes',
                        'default'          => sprintf( __( 'This course closed on [lifterlms_course_info id="%d" key="end_date"].', 'lifterlms' ), $this->post->ID ),
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 222..232
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 233..243
includes/admin/post-types/meta-boxes/class.llms.meta.box.course.options.php on lines 272..282

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

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

function llms_get_date_diff( $time1, $time2, $precision = 2 ) {
    // If not numeric then convert timestamps.
    if ( ! is_numeric( $time1 ) ) {
        $time1 = strtotime( $time1 );
    }
Severity: Minor
Found in includes/llms.functions.core.php - About 2 hrs 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 serve_file has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function serve_file() {

        $media_id = llms_filter_input( INPUT_GET, self::URL_PARAMETER_ID, FILTER_SANITIZE_NUMBER_INT );

        // Handle a rewritten URL.
Severity: Minor
Found in includes/class-llms-media-protector.php - About 2 hrs 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_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_data( $key, $certificate ) {

        // Handle old object being passed in.
        if ( ! is_a( $certificate, 'LLMS_User_Certificate' ) && property_exists( $certificate, 'certificate_id' ) ) {
            $certificate = llms_get_certificate( $certificate->certificate_id );
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.certificates.php - About 2 hrs 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_data has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_data( $key, $data ) {

        $quiz = llms_get_post( $data );

        switch ( $key ) {
Severity: Minor
Found in includes/admin/reporting/tables/llms.table.quizzes.php - About 2 hrs 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_count has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_count( $key ) {

        $count     = 0;
        $questions = $this->get_questions();

Severity: Minor
Found in includes/models/model.llms.quiz.attempt.php - About 2 hrs 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_order_data_query has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_order_data_query( $args = array() ) {

        extract(
            wp_parse_args(
                $args,
Severity: Minor
Found in includes/abstracts/abstract.llms.analytics.widget.php - About 2 hrs 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 has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function ___get( $key, $raw = false ) {

        // Force numeric id and prevent filtering on the id.
        if ( 'id' === $key ) {

Severity: Minor
Found in includes/abstracts/abstract.llms.post.model.php - About 2 hrs 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 restriction_checks_courses has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function restriction_checks_courses( $results ) {

        $post_id = null;

        if ( bbp_is_forum( $results['content_id'] ) ) {
Severity: Minor
Found in includes/integrations/class.llms.integration.bbpress.php - About 2 hrs 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_modify_edit_account_field_settings has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function maybe_modify_edit_account_field_settings( &$posted_data, $location, &$fields ) {

        if ( 'account' !== $location ) {
            return;
        }
Severity: Minor
Found in includes/forms/class-llms-form-handler.php - About 2 hrs 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 convert_to_hours_minutes_string has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function convert_to_hours_minutes_string( $time ) {
        $decimal_part = $time - floor( $time );
        settype( $time, 'integer' );
        if ( $time < 1 ) {
            return;
Severity: Minor
Found in includes/class.llms.date.php - About 2 hrs 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_course_terms has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function add_course_terms( $course_id, $raw_terms ) {

        $taxes = array(
            'course_cat'        => 'categories',
            'course_difficulty' => 'difficulty',
Severity: Minor
Found in includes/class-llms-generator-courses.php - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_merge_data( $code ) {

        $order = $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 get_output has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function get_output() {

        // Backwards compatibility, get membership if set and fallback to the id.
        $ids = $this->get_attribute( 'membership' ) ? $this->get_attribute( 'membership' ) : $this->get_attribute( 'id' );

Severity: Minor
Found in includes/shortcodes/class.llms.shortcode.hide.content.php - About 2 hrs 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_prerequisite has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

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

    $post_type = get_post_type( $post_id );

    switch ( $post_type ) {
Severity: Minor
Found in includes/functions/llms.functions.access.php - About 2 hrs 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 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_merge_data( $code ) {

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

    protected function set_merge_data( $code ) {

        $order = $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

Severity
Category
Status
Source
Language