ImpressCMS/impresscms

View on GitHub
upgrade/upd-icms-1.0-to-1.1/settings_db.php

Summary

Maintainability
A
35 mins
Test Coverage

getDbCollations accesses the super-global variable $GLOBALS.
Open

function getDbCollations()
{
    $collations = array();
    $charsets = getDbCharsets();
    

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();

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();

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();
    

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();
Severity: Minor
Found in upgrade/upd-icms-1.0-to-1.1/settings_db.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 unused local variables such as '$collations'.
Open

    $collations = array();

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 = "";

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 = "";

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>

Avoid assigning values to variables in if clauses and the like (line '51', column '9').
Open

function getDbCollations()
{
    $collations = array();
    $charsets = getDbCharsets();
    

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();

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

            }

Tabs must be used to indent lines; spaces are not allowed
Open

    $collations = array();

Tabs must be used to indent lines; spaces are not allowed
Open

    }

Tabs must be used to indent lines; spaces are not allowed
Open

            $charsets[$row["Charset"]]["desc"] = $row["Description"];

Expected 0 spaces before closing bracket; 1 found
Open

<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>

Tabs must be used to indent lines; spaces are not allowed
Open

    }

Tabs must be used to indent lines; spaces are not allowed
Open

    $charsets = getDbCharsets();

Tabs must be used to indent lines; spaces are not allowed
Open

        foreach ($charset['collation'] as $collation) {

Tabs must be used to indent lines; spaces are not allowed
Open

        while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {

Tabs must be used to indent lines; spaces are not allowed
Open

    }

Tabs must be used to indent lines; spaces are not allowed
Open

        }

Tabs must be used to indent lines; spaces are not allowed
Open

    return $charsets;

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 ); ?>

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 ); ?>

Tabs must be used to indent lines; spaces are not allowed
Open

        while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {

Tabs must be used to indent lines; spaces are not allowed
Open

            $field .= "<option value='{$collation}'" . ( ($value == $collation) ? " selected='selected'" : "" ) . ">{$collation}</option>";

Tabs must be used to indent lines; spaces are not allowed
Open

        unset($charsets["utf8"]);

Tabs must be used to indent lines; spaces are not allowed
Open

    $ut8_available = false;

Tabs must be used to indent lines; spaces are not allowed
Open

    if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW CHARSET")) {

Tabs must be used to indent lines; spaces are not allowed
Open

    if (!$ut8_available) {

Tabs must be used to indent lines; spaces are not allowed
Open

    $collations = getDbCollations();

Tabs must be used to indent lines; spaces are not allowed
Open

    $vars['DB_COLLATION'] = '';

Tabs must be used to indent lines; spaces are not allowed
Open

        $field .= "<optgroup label='{$key} - ({$charset['desc']})'>";

Tabs must be used to indent lines; spaces are not allowed
Open

    }

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    return $charsets;

Tabs must be used to indent lines; spaces are not allowed
Open

        $field .= "</optgroup>";

Tabs must be used to indent lines; spaces are not allowed
Open

            if ($row["Charset"] == "utf8") {

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    $charsets["utf8"] = array();

Tabs must be used to indent lines; spaces are not allowed
Open

                $ut8_available = true;

Tabs must be used to indent lines; spaces are not allowed
Open

    if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW COLLATION")) {

Tabs must be used to indent lines; spaces are not allowed
Open

        }

Expected 0 spaces between opening bracket and argument "$name"; 1 found
Open

function xoFormFieldCollation( $name, $value, $label, $help = '' )

Expected 0 spaces between argument "$help" and closing bracket; 1 found
Open

function xoFormFieldCollation( $name, $value, $label, $help = '' )

Tabs must be used to indent lines; spaces are not allowed
Open

    

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');

Tabs must be used to indent lines; spaces are not allowed
Open

            $charsets[$row["Charset"]]["collation"][] = $row["Collation"];

Opening brace should be on the same line as the declaration
Open

{

Tabs must be used to indent lines; spaces are not allowed
Open

    foreach ($collations as $key => $charset) {

Tabs must be used to indent lines; spaces are not allowed
Open

        }

Opening brace should be on the same line as the declaration
Open

{

Tabs must be used to indent lines; spaces are not allowed
Open

    $charsets = array();

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    $options = "";

Tabs must be used to indent lines; spaces are not allowed
Open

    

Tabs must be used to indent lines; spaces are not allowed
Open

    $collation_default = "";

Tabs must be used to indent lines; spaces are not allowed
Open

    <button type="submit"><?php echo _SUBMIT; ?></button>

Space found after opening bracket of FOREACH loop
Open

    foreach ( $params as $name) {

Opening brace should be on the same line as the declaration
Open

{

Inline control structures are not allowed
Open

<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>

Expected 0 spaces before closing bracket; 1 found
Open

    $value = htmlspecialchars( $value, ENT_QUOTES );

Space after opening parenthesis of function call prohibited
Open

    $label = htmlspecialchars( $label );

Space after opening parenthesis of function call prohibited
Open

<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>

Expected 0 spaces before closing bracket; 1 found
Open

<?php if (!empty( $error ) ) echo '<div class="x2-note error">' . $error . "</div>\n"; ?>

Expected 0 spaces before closing bracket; 1 found
Open

    $label = htmlspecialchars( $label );

Space after opening parenthesis of function call prohibited
Open

    $value = htmlspecialchars( $value, ENT_QUOTES );

Expected 0 spaces before closing bracket; 1 found
Open

if (!defined( 'ICMS_ROOT_PATH' )) {

Expected 0 spaces before closing bracket; 1 found
Open

    $name = htmlspecialchars( $name, ENT_QUOTES );

Space after opening parenthesis of function call prohibited
Open

    $name = htmlspecialchars( $name, ENT_QUOTES );

Expected 0 spaces before closing bracket; 1 found
Open

if (!isset( $vars['DB_COLLATION'] )) {

Space after opening parenthesis of function call prohibited
Open

    die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');

Space after opening parenthesis of function call prohibited
Open

if (!defined( 'ICMS_ROOT_PATH' )) {

Expected 0 spaces after opening bracket; 1 found
Open

    foreach ( $params as $name) {

Space after opening parenthesis of function call prohibited
Open

if (!isset( $vars['DB_COLLATION'] )) {

Space after opening parenthesis of function call prohibited
Open

    <?php echo xoFormFieldCollation( 'DB_COLLATION',    $vars['DB_COLLATION'],    DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>

Expected 0 spaces before closing bracket; 1 found
Open

    <?php echo xoFormFieldCollation( 'DB_COLLATION',    $vars['DB_COLLATION'],    DB_COLLATION_LABEL, DB_COLLATION_HELP ); ?>

The variable $ut8_available is not named in camelCase.
Open

function getDbCharsets()
{
    $charsets = array();
    
    $charsets["utf8"] = array();

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();

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 );

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();

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"];

Unexpected spaces found.
Open

    

Unexpected spaces found.
Open

    

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    if (!$ut8_available) {

Unexpected spaces found.
Open

        unset($charsets["utf8"]);

Unexpected spaces found.
Open

            $field .= "<option value='{$collation}'" . ( ($value == $collation) ? " selected='selected'" : "" ) . ">{$collation}</option>";

Unexpected spaces found.
Open

    

Unexpected spaces found.
Open

    return $charsets;

Unexpected spaces found.
Open

    $charsets = getDbCharsets();

Unexpected spaces found.
Open

    }

Unexpected spaces found.
Open

    $collations = array();

Unexpected spaces found.
Open

    return $charsets;

Unexpected spaces found.
Open

    }

Unexpected spaces found.
Open

            }

Unexpected spaces found.
Open

    $charsets["utf8"] = array();

Unexpected spaces found.
Open

        while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {

Unexpected spaces found.
Open

    $collations = getDbCollations();

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    <button type="submit"><?php echo _SUBMIT; ?></button>

Unexpected spaces found.
Open

    die( 'Bad installation: please add this folder to the ImpressCMS install you want to upgrade');

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    

Unexpected trailing spaces found.
Open

    

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    $collation_default = "";

Unexpected spaces found.
Open

    foreach ($collations as $key => $charset) {

Unexpected spaces found.
Open

            if ($row["Charset"] == "utf8") {

Unexpected spaces found.
Open

                $ut8_available = true;

Unexpected spaces found.
Open

    if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW COLLATION")) {

Unexpected spaces found.
Open

        }

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

        $field .= "</optgroup>";

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    

Unexpected spaces found.
Open

    

Unexpected spaces found.
Open

        $field .= "<optgroup label='{$key} - ({$charset['desc']})'>";

Unexpected spaces found.
Open

    $charsets = array();

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    if ($result = $GLOBALS["xoopsDB"]->queryF("SHOW CHARSET")) {

Unexpected spaces found.
Open

        while ($row = $GLOBALS["xoopsDB"]->fetchArray($result)) {

Unexpected spaces found.
Open

        }

Unexpected spaces found.
Open

    }

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

        foreach ($charset['collation'] as $collation) {

Unexpected spaces found.
Open

        }

Unexpected spaces found.
Open

            $charsets[$row["Charset"]]["desc"] = $row["Description"];

Unexpected spaces found.
Open

    }

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    $options = "";

Unexpected spaces found.
Open

    $ut8_available = false;

Unexpected trailing spaces found.
Open

    

Unexpected spaces found.
Open

    

Unexpected spaces found.
Open

    $vars['DB_COLLATION'] = '';

There are no issues that match your filters.

Category
Status