gocodebox/lifterlms

View on GitHub
includes/models/model.llms.question.php

Summary

Maintainability
D
1 day
Test Coverage
D
64%

File model.llms.question.php has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * LifterLMS Quiz Question Model
 *
 * @package LifterLMS/Models/Classes
Severity: Minor
Found in includes/models/model.llms.question.php - About 4 hrs to fix

    LLMS_Question has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class LLMS_Question extends LLMS_Post_Model {
    
        /**
         * Database post type name
         *
    Severity: Minor
    Found in includes/models/model.llms.question.php - About 3 hrs to fix

      Function get_correct_choice has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public function get_correct_choice() {
      
              $correct = false;
      
              if ( $this->supports( 'choices' ) && $this->supports( 'grading', 'auto' ) ) {
      Severity: Minor
      Found in includes/models/model.llms.question.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

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

          protected function get_creation_args( $args = null ) {
      
              // Allow nothing to be passed in.
              if ( empty( $args ) ) {
                  $args = array();
      Severity: Minor
      Found in includes/models/model.llms.question.php - About 1 hr to fix

        Function grade has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function grade( $answer ) {
        
                $question_type = $this->get( 'question_type' );
        
                /**
        Severity: Minor
        Found in includes/models/model.llms.question.php - About 45 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_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_image( $size = 'full', $unused = null ) {
        
                $url = '';
        
                if ( $this->has_image() ) {
        Severity: Minor
        Found in includes/models/model.llms.question.php - About 45 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 supports has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public function supports( $feature, $option = null ) {
        
                $ret = false;
        
                $type = $this->get_question_type();
        Severity: Minor
        Found in includes/models/model.llms.question.php - About 45 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_creation_args has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function get_creation_args( $args = null ) {
        
                // Allow nothing to be passed in.
                if ( empty( $args ) ) {
                    $args = array();
        Severity: Minor
        Found in includes/models/model.llms.question.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

        There are no issues that match your filters.

        Category
        Status