APO-Epsilon/apo-website

View on GitHub
all_hours.php

Summary

Maintainability
A
0 mins
Test Coverage

show_active accesses the super-global variable $_SESSION.
Open

function show_active() {
    include ('mysql_access.php');
    global $total_query;
    $id = $_SESSION['sessionID'];
    ?>
Severity: Minor
Found in all_hours.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Avoid using undefined variables such as '$db' which will lead to PHP notices.
Open

    $results = $db->query($sql) or die("Error Calculating Hours");
Severity: Minor
Found in all_hours.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid unused local variables such as '$db'.
Open

    $results = $db->query($sql) or die("Error Calculating Hours");
Severity: Minor
Found in all_hours.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

The function show_active() contains an exit expression.
Open

    $results = $db->query($sql) or die("Error Calculating Hours");
Severity: Minor
Found in all_hours.php by phpmd

ExitExpression

Since: 0.2

An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

Example

class Foo {
    public function bar($param)  {
        if ($param === 42) {
            exit(23);
        }
    }
}

Source https://phpmd.org/rules/design.html#exitexpression

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 27 and the first side effect is on line 2.
Open

<?php
Severity: Minor
Found in all_hours.php by phpcodesniffer

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    $id = $_SESSION['sessionID'];
Severity: Minor
Found in all_hours.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

TRUE, FALSE and NULL must be lowercase; expected "false" but found "False"
Open

$public_page = False;
Severity: Minor
Found in all_hours.php by phpcodesniffer

TRUE, FALSE and NULL must be lowercase; expected "false" but found "False"
Open

$exec_page = False;
Severity: Minor
Found in all_hours.php by phpcodesniffer

TRUE, FALSE and NULL must be lowercase; expected "true" but found "True"
Open

$active_page = True;
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        echo "<tr><td>$event</td><td>$hours</td><td>$semester</td><td>$date</td><td>$service_type</td></tr>";
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    <?php
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    <h1>All Hours List</h1>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    <tr><th>Event</th><th>Hours</th><th>Semester</th><th>Date</th><th>Service Type</th></tr>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    //list all events
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    <?php
Severity: Minor
Found in all_hours.php by phpcodesniffer

Line exceeds 120 characters; contains 122 characters
Open

    $sql = "SELECT event,hours,semester,date,servicetype FROM (SELECT * " . $total_query . ")mctable WHERE user_id='$id'";
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    $results = $db->query($sql) or die("Error Calculating Hours");
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $date = $result['date'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    $id = $_SESSION['sessionID'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    $total = 0;
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $service_type = $result['servicetype'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    ?>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $total = $total + $hours;
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    $results->free();
Severity: Minor
Found in all_hours.php by phpcodesniffer

End of line character is invalid; expected "\n" but found "\r\n"
Open

<?php
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $semester = $result['semester'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    include ('mysql_access.php');
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    <table>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    while ($result = mysqli_fetch_array($results)) {
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $event = $result['event'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    </table>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    global $total_query;
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    echo "Total Hours : " . $total;
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    $sql = "SELECT event,hours,semester,date,servicetype FROM (SELECT * " . $total_query . ")mctable WHERE user_id='$id'";
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $hours = $result['hours'];
Severity: Minor
Found in all_hours.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    ?>
Severity: Minor
Found in all_hours.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

require_once ('mysql_access.php');
Severity: Minor
Found in all_hours.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

require_once ('session.php');
Severity: Minor
Found in all_hours.php by phpcodesniffer

Space before opening parenthesis of function call prohibited
Open

    include ('mysql_access.php');
Severity: Minor
Found in all_hours.php by phpcodesniffer

Opening brace should be on a new line
Open

function show_active() {
Severity: Minor
Found in all_hours.php by phpcodesniffer

The variable $total_query is not named in camelCase.
Open

function show_active() {
    include ('mysql_access.php');
    global $total_query;
    $id = $_SESSION['sessionID'];
    ?>
Severity: Minor
Found in all_hours.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $total_query is not named in camelCase.
Open

function show_active() {
    include ('mysql_access.php');
    global $total_query;
    $id = $_SESSION['sessionID'];
    ?>
Severity: Minor
Found in all_hours.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $service_type is not named in camelCase.
Open

function show_active() {
    include ('mysql_access.php');
    global $total_query;
    $id = $_SESSION['sessionID'];
    ?>
Severity: Minor
Found in all_hours.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $service_type is not named in camelCase.
Open

function show_active() {
    include ('mysql_access.php');
    global $total_query;
    $id = $_SESSION['sessionID'];
    ?>
Severity: Minor
Found in all_hours.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status