AppStateESS/homestead

View on GitHub
class/Report/AssignmentDemographics/AssignmentDemographics.php

Summary

Maintainability
C
1 day
Test Coverage

Function getSummary has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    private function getSummary(Array $assignments)
    {
        // Create the summary array for this set of assignments and initialize it
        $summary = array();
        $this->initializeArray($summary);
Severity: Minor
Found in class/Report/AssignmentDemographics/AssignmentDemographics.php - About 3 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 calcGrandTotals has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function calcGrandTotals()
    {
        foreach($this->hallSummaries as $hall){
            foreach($this->studentTypes as $t){
                // handle the 'other' type and skip the other types
Severity: Minor
Found in class/Report/AssignmentDemographics/AssignmentDemographics.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 getSummary has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function getSummary(Array $assignments)
    {
        // Create the summary array for this set of assignments and initialize it
        $summary = array();
        $this->initializeArray($summary);
Severity: Minor
Found in class/Report/AssignmentDemographics/AssignmentDemographics.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

            if(!isset($type) || $type === NULL ||
            ($type != TYPE_FRESHMEN && $type != TYPE_TRANSFER && $type != TYPE_CONTINUING && $type != TYPE_READMIT && $type != TYPE_RETURNING)) {
                //$this->problems[] = $assign['asu_username'] . ': Type is unrecognized ('. $type .')';
                $summary['OTHER']++;
                continue;
Severity: Major
Found in class/Report/AssignmentDemographics/AssignmentDemographics.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

            if(!isset($class) || $class === NULL ||
            ($class != CLASS_FRESHMEN && $class != CLASS_SOPHOMORE &&
            $class != CLASS_JUNIOR && $class != CLASS_SENIOR)) {
                //$this->problems[] = $assign['asu_username'] . ': Class is unrecognized ('. $class .')';
                $summary['OTHER']++;
Severity: Major
Found in class/Report/AssignmentDemographics/AssignmentDemographics.php - About 40 mins to fix

Function initializeArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function initializeArray(Array &$arr)
    {
        // Initialize the multi-dimensional array
        foreach($this->studentTypes as $t){
            foreach($this->classes as $c){
Severity: Minor
Found in class/Report/AssignmentDemographics/AssignmentDemographics.php - About 25 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