show_active accesses the super-global variable $_GET. Open
function show_active() {
if (isset($_GET['delete'])) {
$entry = $_GET['delete'];
delete_event($entry);
- Read upRead up
- Exclude checks
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
show_active accesses the super-global variable $_SESSION. Open
function show_active() {
if (isset($_GET['delete'])) {
$entry = $_GET['delete'];
delete_event($entry);
- Read upRead up
- Exclude checks
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
show_active accesses the super-global variable $_GET. Open
function show_active() {
if (isset($_GET['delete'])) {
$entry = $_GET['delete'];
delete_event($entry);
- Read upRead up
- Exclude checks
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
$delete = $db->query($sql) or exit("There was an error, contact Webmaster");
- Read upRead up
- Exclude checks
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 using undefined variables such as '$db' which will lead to PHP notices. Open
$response=$db->query("SELECT * FROM events_signup WHERE user_id = $user_id");
- Read upRead up
- Exclude checks
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 using undefined variables such as '$db' which will lead to PHP notices. Open
$check=$db->query("SELECT * FROM events_listing WHERE event_id=$eid");
- Read upRead up
- Exclude checks
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
$delete = $db->query($sql) or exit("There was an error, contact Webmaster");
- Read upRead up
- Exclude checks
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 delete_event() contains an exit expression. Open
$delete = $db->query($sql) or exit("There was an error, contact Webmaster");
- Read upRead up
- Exclude checks
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
Avoid unused local variables such as '$delete'. Open
$delete = $db->query($sql) or exit("There was an error, contact Webmaster");
- Read upRead up
- Exclude checks
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
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
- Exclude checks
Avoid variables with short names like $i. Configured minimum length is 3. Open
$i = 0;
- Read upRead up
- Exclude checks
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
Spaces must be used for alignment; tabs are not allowed Open
$i++;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while($done=mysqli_fetch_array($check))
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$type = $done['event_type'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$user_id = $_SESSION['sessionID'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo "<table>";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$i = 0;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
while($result=mysqli_fetch_array($response))
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
$public_page = False;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$event = $done['event_name'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
}
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo "<h1>My Events</h1>";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "true" but found "True" Open
$active_page = True;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
include('mysql_access.php');
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo "<tr><th>#</th><th>Name</th><th>Type</th><th>Delete?</th></tr>";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo "</table>";
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$entry = $result['entry_id'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
{
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
echo "<tr><td>$i</td><td>$event</td><td>$type</td><td><sup><a href='my_events.php?delete=$entry'>Delete?</a></sup></td></tr>";
- Exclude checks
Blank line found at end of control structure Open
- Exclude checks
TRUE, FALSE and NULL must be lowercase; expected "false" but found "False" Open
$exec_page = False;
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$response=$db->query("SELECT * FROM events_signup WHERE user_id = $user_id");
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$eid = $result['event_id'];
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
- Exclude checks
Spaces must be used for alignment; tabs are not allowed Open
$check=$db->query("SELECT * FROM events_listing WHERE event_id=$eid");
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
echo "<tr><td>$i</td><td>$event</td><td>$type</td><td><sup><a href='my_events.php?delete=$entry'>Delete?</a></sup></td></tr>";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$entry = $_GET['delete'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($_GET['delete'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
End of line character is invalid; expected "\n" but found "\r\n" Open
<?php
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
delete_event($entry);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
- Exclude checks
Opening brace should be on a new line Open
function delete_event($entry) {
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($result=mysqli_fetch_array($response))
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('session.php');
- Exclude checks
Space before opening parenthesis of function call prohibited Open
require_once ('mysql_access.php');
- Exclude checks
Expected 1 space after closing parenthesis; found 10 Open
while($done=mysqli_fetch_array($check))
- Exclude checks
Expected 1 space after closing parenthesis; found 6 Open
while($result=mysqli_fetch_array($response))
- Exclude checks
Space before opening parenthesis of function call prohibited Open
include ('mysql_access.php');
- Exclude checks
Whitespace found at end of line Open
}
- Exclude checks
Expected 1 space after WHILE keyword; 0 found Open
while($done=mysqli_fetch_array($check))
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$sql = "DELETE FROM `events_signup` WHERE `entry_id` = '$entry' LIMIT 1";
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
$delete = $db->query($sql) or exit("There was an error, contact Webmaster");
- Exclude checks
Opening brace should be on a new line Open
function show_active() {
- Exclude checks
Line indented incorrectly; expected at least 4 spaces, found 2 Open
include ('mysql_access.php');
- Exclude checks
The variable $user_id is not named in camelCase. Open
function show_active() {
if (isset($_GET['delete'])) {
$entry = $_GET['delete'];
delete_event($entry);
- Read upRead up
- Exclude checks
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 $user_id is not named in camelCase. Open
function show_active() {
if (isset($_GET['delete'])) {
$entry = $_GET['delete'];
delete_event($entry);
- Read upRead up
- Exclude checks
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();
}
}