AppStateESS/homestead

View on GitHub
util/createfakestudents.php

Summary

Maintainability
F
1 wk
Test Coverage

File createfakestudents.php has 1048 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/php
<?php
/**
 * @license http://opensource.org/licenses/lgpl-3.0.html
 * @author Matthew McNaney <mcnaney at gmail dot com>
Severity: Major
Found in util/createfakestudents.php - About 2 days to fix

Method first_name has 169 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function first_name()
{
    static $first_names = array(
        'Abigail',
        'Abigail',
Severity: Major
Found in util/createfakestudents.php - About 6 hrs to fix

Method last_name has 155 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function last_name()
{
    static $last_names = array(
        'Acula',
        'Achenbach',
Severity: Major
Found in util/createfakestudents.php - About 6 hrs to fix

Method nickname has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function nickname($first_name)
{
    $shortened = array(
        'Abigail' => 'Abby',
        'Alexander' => 'Alex',
Severity: Major
Found in util/createfakestudents.php - About 3 hrs to fix

Function process has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

function process($arguments)
{
    $dump_data = false;
    $term = get_term_default();

Severity: Minor
Found in util/createfakestudents.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

Method process has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function process($arguments)
{
    $dump_data = false;
    $term = get_term_default();

Severity: Major
Found in util/createfakestudents.php - About 2 hrs to fix

Method road has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function road()
{
    $roads = array(
        'Elm',
        'Cactus',
Severity: Minor
Found in util/createfakestudents.php - About 2 hrs to fix

Method create_autocomplete_query has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function create_autocomplete_query($row)
{
    extract($row);

    $lfirst = strtolower($first_name);
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

Method reset_tables has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function reset_tables()
{
    $pdo = get_connection();
    echo 'Dropping ' . TABLE_NAME . " table.\n";
    $pdo->exec('drop table if exists ' . TABLE_NAME);
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

Method get_row has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function get_row($application_term)
{
    $first_name = first_name();
    $middle_name = middle_name($first_name);
    $last_name = last_name();
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

Method dsn_array has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function dsn_array()
{
    static $dsn_array = null;

    if (!empty($dsn_array)) {
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

Method student_type has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function student_type($student_level)
{
    if ($student_level == 'G') {
        return 'G';
    }
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

Method create_new_table has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function create_new_table($pdo)
{
    $table_name = TABLE_NAME;
    $query = <<<EOF
CREATE TABLE $table_name (
Severity: Minor
Found in util/createfakestudents.php - About 1 hr to fix

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

function student_type($student_level)
{
    if ($student_level == 'G') {
        return 'G';
    }
Severity: Minor
Found in util/createfakestudents.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

Avoid too many return statements within this method.
Open

        return 'Z';
Severity: Major
Found in util/createfakestudents.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return 'N';
Severity: Major
Found in util/createfakestudents.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return 'G';
Severity: Major
Found in util/createfakestudents.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return 'R';
Severity: Major
Found in util/createfakestudents.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return 'W';
Severity: Major
Found in util/createfakestudents.php - About 30 mins to fix

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

function middle_name($first_name)
{
    if (mt_rand(1, 100) == 1) {
        return 'Danger';
    } else {
Severity: Minor
Found in util/createfakestudents.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

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

function dsn_array()
{
    static $dsn_array = null;

    if (!empty($dsn_array)) {
Severity: Minor
Found in util/createfakestudents.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