getDbCollations accesses the super-global variable $GLOBALS. Open
function getDbCollations()
{
$collations = array();
$charsets = getDbCharsets();
- 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
getDbCharsets accesses the super-global variable $GLOBALS. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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
getDbCharsets accesses the super-global variable $GLOBALS. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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
getDbCollations accesses the super-global variable $GLOBALS. Open
function getDbCollations()
{
$collations = array();
$charsets = getDbCharsets();
- 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
Function getDbCharsets
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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 unused local variables such as '$collations'. Open
$collations = array();
- 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 '$collation_default'. Open
$collation_default = "";
- 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 '$options'. Open
$options = "";
- 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
Reference to undeclared constant \_SUBMIT
Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Avoid assigning values to variables in if clauses and the like (line '51', column '9'). Open
function getDbCollations()
{
$collations = array();
$charsets = getDbCharsets();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '31', column '9'). Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$collations = array();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$charsets[$row["Charset"]]["desc"] = $row["Description"];
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$charsets = getDbCharsets();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
foreach ($charset['collation'] as $collation) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
return $charsets;
- Exclude checks
Expected 1 space after comma in function call; 4 found Open
<?php echo xoFormFieldCollation( 'DB_COLLATION', $vars['DB_COLLATION'], DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>
- Exclude checks
Expected 1 space after comma in function call; 2 found Open
<?php echo xoFormFieldCollation( 'DB_COLLATION', $vars['DB_COLLATION'], DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$field .= "<option value='{$collation}'" . ( ($value == $collation) ? " selected='selected'" : "" ) . ">{$collation}</option>";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
unset($charsets["utf8"]);
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$ut8_available = false;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW CHARSET")) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if (!$ut8_available) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$collations = getDbCollations();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$vars['DB_COLLATION'] = '';
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$field .= "<optgroup label='{$key} - ({$charset['desc']})'>";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
return $charsets;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$field .= "</optgroup>";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if ($row["Charset"] == "utf8") {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$charsets["utf8"] = array();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$ut8_available = true;
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW COLLATION")) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Expected 0 spaces between opening bracket and argument "$name"; 1 found Open
function xoFormFieldCollation( $name, $value, $label, $help = '' )
- Exclude checks
Expected 0 spaces between argument "$help" and closing bracket; 1 found Open
function xoFormFieldCollation( $name, $value, $label, $help = '' )
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$charsets[$row["Charset"]]["collation"][] = $row["Collation"];
- Exclude checks
Opening brace should be on the same line as the declaration Open
{
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
foreach ($collations as $key => $charset) {
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
}
- Exclude checks
Opening brace should be on the same line as the declaration Open
{
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$charsets = array();
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$options = "";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
$collation_default = "";
- Exclude checks
Tabs must be used to indent lines; spaces are not allowed Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Space found after opening bracket of FOREACH loop Open
foreach ( $params as $name) {
- Exclude checks
Opening brace should be on the same line as the declaration Open
{
- Exclude checks
Inline control structures are not allowed Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$label = htmlspecialchars( $label );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$label = htmlspecialchars( $label );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$value = htmlspecialchars( $value, ENT_QUOTES );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- Exclude checks
Space after opening parenthesis of function call prohibited Open
$name = htmlspecialchars( $name, ENT_QUOTES );
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
if (!isset( $vars['DB_COLLATION'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (!defined( 'ICMS_ROOT_PATH' )) {
- Exclude checks
Expected 0 spaces after opening bracket; 1 found Open
foreach ( $params as $name) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
if (!isset( $vars['DB_COLLATION'] )) {
- Exclude checks
Space after opening parenthesis of function call prohibited Open
<?php echo xoFormFieldCollation( 'DB_COLLATION', $vars['DB_COLLATION'], DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>
- Exclude checks
Expected 0 spaces before closing bracket; 1 found Open
<?php echo xoFormFieldCollation( 'DB_COLLATION', $vars['DB_COLLATION'], DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>
- Exclude checks
The variable $ut8_available is not named in camelCase. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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 $ut8_available is not named in camelCase. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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 $collation_default is not named in camelCase. Open
function xoFormFieldCollation( $name, $value, $label, $help = '' )
{
$collations = getDbCollations();
$label = htmlspecialchars( $label );
- 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 $ut8_available is not named in camelCase. Open
function getDbCharsets()
{
$charsets = array();
$charsets["utf8"] = array();
- 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
Unexpected spaces found. Open
$charsets[$row["Charset"]]["collation"][] = $row["Collation"];
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
if (!$ut8_available) {
- Exclude checks
Unexpected spaces found. Open
unset($charsets["utf8"]);
- Exclude checks
Unexpected spaces found. Open
$field .= "<option value='{$collation}'" . ( ($value == $collation) ? " selected='selected'" : "" ) . ">{$collation}</option>";
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
return $charsets;
- Exclude checks
Unexpected spaces found. Open
$charsets = getDbCharsets();
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$collations = array();
- Exclude checks
Unexpected spaces found. Open
return $charsets;
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$charsets["utf8"] = array();
- Exclude checks
Unexpected spaces found. Open
while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {
- Exclude checks
Unexpected spaces found. Open
$collations = getDbCollations();
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
<button type="submit"><?php echo _SUBMIT; ?></button>
- Exclude checks
Unexpected spaces found. Open
die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
$collation_default = "";
- Exclude checks
Unexpected spaces found. Open
foreach ($collations as $key => $charset) {
- Exclude checks
Unexpected spaces found. Open
if ($row["Charset"] == "utf8") {
- Exclude checks
Unexpected spaces found. Open
$ut8_available = true;
- Exclude checks
Unexpected spaces found. Open
if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW COLLATION")) {
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
$field .= "</optgroup>";
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
$field .= "<optgroup label='{$key} - ({$charset['desc']})'>";
- Exclude checks
Unexpected spaces found. Open
$charsets = array();
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW CHARSET")) {
- Exclude checks
Unexpected spaces found. Open
while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
foreach ($charset['collation'] as $collation) {
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected spaces found. Open
$charsets[$row["Charset"]]["desc"] = $row["Description"];
- Exclude checks
Unexpected spaces found. Open
}
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
$options = "";
- Exclude checks
Unexpected spaces found. Open
$ut8_available = false;
- Exclude checks
Unexpected trailing spaces found. Open
- Exclude checks
Unexpected spaces found. Open
- Exclude checks
Unexpected spaces found. Open
$vars['DB_COLLATION'] = '';
- Exclude checks