AppStateESS/homestead

View on GitHub
class/HMS_Email.php

Summary

Maintainability
F
4 days
Test Coverage

File HMS_Email.php has 686 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Homestead;

use \Michelf\Markdown;
Severity: Major
Found in class/HMS_Email.php - About 1 day to fix

HMS_Email has 47 functions (exceeds 20 allowed). Consider refactoring.
Open

class HMS_Email{

    public static function get_tech_contacts()
    {
        $contacts = array();
Severity: Minor
Found in class/HMS_Email.php - About 6 hrs to fix

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

    public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL)
    {
        // Sanity checking
        if(!isset($to) || is_null($to)){
            return false;
Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

Method sendRoomChangeCancelledNotice has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function sendRoomChangeCancelledNotice(RoomChangeRequest $r, Student $canceller = null)
    {
        $subject = 'Room Change Cancelled';
        $template = 'email/roomChangeCancelledNotice.tpl';

Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

Function send_email has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL)
    {
        // Sanity checking
        if(!isset($to) || is_null($to)){
            return false;
Severity: Minor
Found in class/HMS_Email.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 sendRoomChangeDeniedNotice has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function sendRoomChangeDeniedNotice(RoomChangeRequest $r)
    {
        $subject = 'Room Change Denied';
        $template = 'email/roomChangeDeniedNotice.tpl';

Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

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

    public static function sendRoomChangeInProcessNotice(RoomChangeRequest $r)
    {
        $subject = 'Room Change Approved!';
        $template = 'email/roomChangeApprovalNotice.tpl';

Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

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

    public static function sendRoomChangeCurrRDNotice(RoomChangeRequest $request)
    {
        $subject = 'Room Change Approval Required';
        $template = 'email/roomChangeCurrRDNotice.tpl';

Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

Method sendRoomChangeParticipantNotice has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function sendRoomChangeParticipantNotice(RoomChangeParticipant $requestor, RoomChangeParticipant $requestee)
    {
        $subject = 'Room Change Requested';
        $template = 'email/roomChangeParticipantNotice.tpl';
        $term = Term::getCurrentTerm();
Severity: Minor
Found in class/HMS_Email.php - About 1 hr to fix

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

    public static function sendRoomChangeCancelledNotice(RoomChangeRequest $r, Student $canceller = null)
    {
        $subject = 'Room Change Cancelled';
        $template = 'email/roomChangeCancelledNotice.tpl';

Severity: Minor
Found in class/HMS_Email.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

Method send_lottery_roommate_reminder has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function send_lottery_roommate_reminder(Student $student, $name, $expires_on, $requestor_name, $hall_room, $year)
Severity: Minor
Found in class/HMS_Email.php - About 45 mins to fix

Method sendAssignmentNotice has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function sendAssignmentNotice(Student $student, $name, $term, $location, Array $roommates, $moveinTime){
Severity: Minor
Found in class/HMS_Email.php - About 45 mins to fix

Method send_email has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function send_email($to, $from, $subject, $content, $cc = NULL, $bcc = NULL)
Severity: Minor
Found in class/HMS_Email.php - About 45 mins to fix

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

    public static function sendRoomChangeDeniedNotice(RoomChangeRequest $r)
    {
        $subject = 'Room Change Denied';
        $template = 'email/roomChangeDeniedNotice.tpl';

Severity: Minor
Found in class/HMS_Email.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 logSwiftmailMessageLong has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static function logSwiftmailMessageLong(\Swift_Message $message)
    {
        $fd = fopen(PHPWS_SOURCE_DIR . 'logs/email.log', 'a');
        fprintf($fd, "=======================\n");

Severity: Minor
Found in class/HMS_Email.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

Method send_lottery_roommate_invite has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function send_lottery_roommate_invite(Student $student, Student $from, $expires_on, $hall_room, $year)
Severity: Minor
Found in class/HMS_Email.php - About 35 mins to fix

Method sendDamageNotification has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function sendDamageNotification(Student $student, $term, $billedAmount, $coordinatorName, $coordinatorEmail)
Severity: Minor
Found in class/HMS_Email.php - About 35 mins to fix

Method sendTemplateMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public static function sendTemplateMessage(Student $student, string $messageType, string $subject, string $tpl, Array $tags)
Severity: Minor
Found in class/HMS_Email.php - About 35 mins to fix

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

    public static function sendAssignmentNotice(Student $student, $name, $term, $location, Array $roommates, $moveinTime){
        $tpl = array();

        $tpl['NAME']            = $name;
        $tpl['TERM']            = Term::toString($term);
Severity: Minor
Found in class/HMS_Email.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 log_email has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function log_email($message)
    {
        // Log the message to a text file
        $fd = fopen(PHPWS_SOURCE_DIR . 'logs/email.log',"a");
        fprintf($fd, "=======================\n");
Severity: Minor
Found in class/HMS_Email.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

Avoid too many return statements within this method.
Open

        return true;
Severity: Major
Found in class/HMS_Email.php - About 30 mins to fix

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

    public static function sendRoomChangeInProcessNotice(RoomChangeRequest $r)
    {
        $subject = 'Room Change Approved!';
        $template = 'email/roomChangeApprovalNotice.tpl';

Severity: Minor
Found in class/HMS_Email.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