load_invite_code accesses the super-global variable $GLOBALS. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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
Method load_invite_code
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
Function load_invite_code
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- Read upRead up
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 using undefined variables such as '$register_id' which will lead to PHP notices. Open
if (empty($invite_to) || !empty($register_id) || (int) ($invite_date) < time() - 3 * 86400) {
- 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
The function load_invite_code() contains an exit expression. Open
exit();
- 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 '$register_id'. Open
if (empty($invite_to) || !empty($register_id) || (int) ($invite_date) < time() - 3 * 86400) {
- 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
Avoid unused local variables such as '$result'. Open
$result = icms::$xoopsDB->query($sql);
- 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 load_invite_code() contains an exit expression. Open
exit();
- 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
The function load_invite_code() contains an exit expression. Open
exit();
- 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
Reference to static property xoopsDB
from undeclared class \icms
Open
'UPDATE ' . icms::$xoopsDB->prefix('invites') . ' SET view_date = %d WHERE invite_code = %s AND register_id = 0',
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
list($invite_to, $invite_date) = icms::$xoopsDB->fetchRow($result);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
icms::$xoopsDB->prefix('invites'), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
'UPDATE ' . icms::$xoopsDB->prefix('invites') . ' SET register_id = %d WHERE invite_code = %s AND register_id = 0',
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
$result = icms::$xoopsDB->query($sql);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
$result = icms::$xoopsDB->query($sql);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
icms::$xoopsDB->prefix('invites'), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
time(), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
$result = icms::$xoopsDB->query($sql);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
list($invite_to, $invite_date, $register_id, $extra_info) = icms::$xoopsDB->fetchRow($result);
- Exclude checks
Reference to undeclared constant \_US_INVITEEXPIRED
Open
redirect_header('invite.php', 3, _US_INVITEEXPIRED);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
$result = icms::$xoopsDB->queryF($sql);
- Exclude checks
Reference to undeclared constant \_US_INVITEINVALID
Open
redirect_header('invite.php', 3, _US_INVITEINVALID);
- Exclude checks
Reference to static property xoopsDB
from undeclared class \icms
Open
$new_id, icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
The parameter $new_id is not named in camelCase. Open
function update_invite_code($code, $new_id) {
// update register_id
$sql = sprintf(
'UPDATE ' . icms::$xoopsDB->prefix('invites') . ' SET register_id = %d WHERE invite_code = %s AND register_id = 0',
$new_id, icms::$xoopsDB->quoteString(addslashes($code))
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
Only one argument is allowed per line in a multi-line function call Open
$new_id, icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
icms::$xoopsDB->prefix('invites'), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
icms::$xoopsDB->prefix('invites'), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
time(), icms::$xoopsDB->quoteString(addslashes($code))
- Exclude checks
The variable $ex_value is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $ex_key is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_date is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_date is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_to is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $ex_key is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_to is not named in camelCase. Open
function check_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
return false;
}
- 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 $register_id is not named in camelCase. Open
function check_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
return false;
}
- 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 $ex_value is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $register_id is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_date is not named in camelCase. Open
function check_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
return false;
}
- 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 $invite_to is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $extra_info is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $register_id is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $extra_info is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_to is not named in camelCase. Open
function check_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
return false;
}
- 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 $extra_array is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $invite_date is not named in camelCase. Open
function check_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
return false;
}
- 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 $invite_to is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $extra_array is not named in camelCase. Open
function load_invite_code($code) {
// validate if code is of valid length.
if (empty($code) || strlen($code) != 8) {
header('Location: invite.php');
// redirect_header('invite.php', 0, _US_INVITENONE);
- 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 $new_id is not named in camelCase. Open
function update_invite_code($code, $new_id) {
// update register_id
$sql = sprintf(
'UPDATE ' . icms::$xoopsDB->prefix('invites') . ' SET register_id = %d WHERE invite_code = %s AND register_id = 0',
$new_id, icms::$xoopsDB->quoteString(addslashes($code))
- 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();
}
}