ImpressCMS/impresscms

View on GitHub
htdocs/install/class/settingmanager.php

Summary

Maintainability
B
7 hrs
Test Coverage

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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

__construct accesses the super-global variable $_SERVER.
Open

    function __construct($post=false) {

        $this->sanitizer =& icms_core_Textsanitizer::getInstance();
        if ($post) {
            $this->readPost();

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

readPost accesses the super-global variable $_POST.
Open

    function readPost() {
        if (isset($_POST['database']))
        $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
        if (isset($_POST['dbhost']))
        $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

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 confirmForm has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function confirmForm() {
        $yesno = empty($this->db_pconnect) ? _INSTALL_L24 : _INSTALL_L23;
        $ret =
            "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='90%'><tr><td class='bg2'>
                <table width='100%' border='0' cellpadding='4' cellspacing='1'>
Severity: Major
Found in htdocs/install/class/settingmanager.php - About 2 hrs to fix

    Method editform has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        function editform() {
            $ret =
                "<table width='100%' class='outer' cellspacing='5'>
                    <tr>
                        <th colspan='2'></th>
    Severity: Minor
    Found in htdocs/install/class/settingmanager.php - About 1 hr to fix

      Function readPost has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          function readPost() {
              if (isset($_POST['database']))
              $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
              if (isset($_POST['dbhost']))
              $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);
      Severity: Minor
      Found in htdocs/install/class/settingmanager.php - About 55 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

      Function readConstant has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          function readConstant() {
              if (defined('XOOPS_DB_TYPE'))
              $this->database = XOOPS_DB_TYPE;
              if (defined('XOOPS_DB_HOST'))
              $this->dbhost = XOOPS_DB_HOST;
      Severity: Minor
      Found in htdocs/install/class/settingmanager.php - About 55 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

      Function checkData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          function checkData() {
              $ret = '';
              $error = array();
      
              if (empty($this->dbhost)) {
      Severity: Minor
      Found in htdocs/install/class/settingmanager.php - About 45 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

      Function __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          function __construct($post=false) {
      
              $this->sanitizer =& icms_core_Textsanitizer::getInstance();
              if ($post) {
                  $this->readPost();
      Severity: Minor
      Found in htdocs/install/class/settingmanager.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

      The method readConstant() has an NPath complexity of 768. The configured NPath complexity threshold is 200.
      Open

          function readConstant() {
              if (defined('XOOPS_DB_TYPE'))
              $this->database = XOOPS_DB_TYPE;
              if (defined('XOOPS_DB_HOST'))
              $this->dbhost = XOOPS_DB_HOST;

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The method readPost() has an NPath complexity of 768. The configured NPath complexity threshold is 200.
      Open

          function readPost() {
              if (isset($_POST['database']))
              $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
              if (isset($_POST['dbhost']))
              $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

      NPathComplexity

      Since: 0.1

      The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

      Example

      class Foo {
          function bar() {
              // lots of complicated code
          }
      }

      Source https://phpmd.org/rules/codesize.html#npathcomplexity

      The method readPost() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
      Open

          function readPost() {
              if (isset($_POST['database']))
              $this->database = $this->sanitizer->stripSlashesGPC($_POST['database']);
              if (isset($_POST['dbhost']))
              $this->dbhost = $this->sanitizer->stripSlashesGPC($_POST['dbhost']);

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      The method readConstant() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
      Open

          function readConstant() {
              if (defined('XOOPS_DB_TYPE'))
              $this->database = XOOPS_DB_TYPE;
              if (defined('XOOPS_DB_HOST'))
              $this->dbhost = XOOPS_DB_HOST;

      CyclomaticComplexity

      Since: 0.1

      Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

      Example

      // Cyclomatic Complexity = 11
      class Foo {
      1   public function example() {
      2       if ($a == $b) {
      3           if ($a1 == $b1) {
                      fiddle();
      4           } elseif ($a2 == $b2) {
                      fiddle();
                  } else {
                      fiddle();
                  }
      5       } elseif ($c == $d) {
      6           while ($c == $d) {
                      fiddle();
                  }
      7        } elseif ($e == $f) {
      8           for ($n = 0; $n < $h; $n++) {
                      fiddle();
                  }
              } else {
                  switch ($z) {
      9               case 1:
                          fiddle();
                          break;
      10              case 2:
                          fiddle();
                          break;
      11              case 3:
                          fiddle();
                          break;
                      default:
                          fiddle();
                          break;
                  }
              }
          }
      }

      Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

      The method __construct has a boolean flag argument $post, which is a certain sign of a Single Responsibility Principle violation.
      Open

          function __construct($post=false) {

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Avoid using static access to class 'icms_core_Textsanitizer' in method '__construct'.
      Open

              $this->sanitizer =& icms_core_Textsanitizer::getInstance();

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'icms_core_Filesystem' in method 'getDBList'.
      Open

              $list = icms_core_Filesystem::getDirList($dirname);

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class 'icms_core_Password' in method 'generatePrefix'.
      Open

              return icms_core_Password::createSalt(5);;

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      The method __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $this->database = 'mysql';
                  $this->dbhost = 'localhost';
      
                  $this->db_pconnect = 0;

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

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

      TODO found
      Open

              // TODO: Add any verification of compatibility between the database drivers and the system.

      Reference to undeclared constant \_INSTALL_L55
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L55);

      Reference to undeclared constant \_INSTALL_L64
      Open

              $ret .= $this->editform_sub(_INSTALL_L29, _INSTALL_L64, 'dbname', $this->sanitizer->htmlSpecialChars($this->dbname));

      Reference to undeclared constant \_INSTALL_L29
      Open

                              <td class='bg3'><b>"._INSTALL_L29."</b></td>

      Reference to undeclared constant \_INSTALL_L57
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L55);

      Reference to undeclared constant \_INSTALL_L52
      Open

              $ret .= $this->editform_sub(_INSTALL_L52, _INSTALL_L68, 'dbpass', $this->sanitizer->htmlSpecialChars($this->dbpass));

      Reference to undeclared constant \_INSTALL_L55
      Open

              $ret .= $this->editform_sub(_INSTALL_L55, _INSTALL_L59, 'root_path', $this->sanitizer->htmlSpecialChars($this->root_path));

      Reference to undeclared constant \_INSTALL_L69
      Open

                              <span style='font-size:85%;'>"._INSTALL_L69."</span>

      Reference to undeclared constant \_INSTALL_L58
      Open

              $ret .= $this->editform_sub(_INSTALL_L56, _INSTALL_L58, 'xoops_url', $this->sanitizer->htmlSpecialChars($this->xoops_url));

      Reference to undeclared constant \_INSTALL_L55
      Open

                              <td class='bg3'><b>"._INSTALL_L55."</b></td>

      Reference to undeclared constant \_INSTALL_L66
      Open

                              <span style='font-size:85%;'>"._INSTALL_L66."</span>

      Reference to undeclared constant \_INSTALL_L59
      Open

              $ret .= $this->editform_sub(_INSTALL_L55, _INSTALL_L59, 'root_path', $this->sanitizer->htmlSpecialChars($this->root_path));

      Reference to undeclared constant \_INSTALL_L23
      Open

              $yesno = empty($this->db_pconnect) ? _INSTALL_L24 : _INSTALL_L23;

      Reference to undeclared constant \_INSTALL_L57
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L56);

      Call to method getDirList from undeclared class \icms_core_Filesystem
      Open

              $list = icms_core_Filesystem::getDirList($dirname);
      Severity: Critical
      Found in htdocs/install/class/settingmanager.php by phan

      Reference to undeclared constant \_INSTALL_L67
      Open

              $ret .= $this->editform_sub(_INSTALL_L27, _INSTALL_L67, 'dbhost', $this->sanitizer->htmlSpecialChars($this->dbhost));

      Reference to undeclared constant \_INSTALL_L28
      Open

              $ret .= $this->editform_sub(_INSTALL_L28, _INSTALL_L65, 'dbuname', $this->sanitizer->htmlSpecialChars($this->dbuname));

      Reference to undeclared constant \_INSTALL_L28
      Open

                              <td class='bg3'><b>"._INSTALL_L28."</b></td>

      Reference to undeclared constant \_INSTALL_L52
      Open

                              <td class='bg3'><b>"._INSTALL_L52."</b></td>

      Reference to undeclared constant \_INSTALL_L29
      Open

              $ret .= $this->editform_sub(_INSTALL_L29, _INSTALL_L64, 'dbname', $this->sanitizer->htmlSpecialChars($this->dbname));

      Reference to undeclared constant \_INSTALL_L30
      Open

                              <td class='bg3'><b>"._INSTALL_L30."</b></td>

      Reference to undeclared constant \_INSTALL_L68
      Open

              $ret .= $this->editform_sub(_INSTALL_L52, _INSTALL_L68, 'dbpass', $this->sanitizer->htmlSpecialChars($this->dbpass));

      Reference to undeclared constant \_INSTALL_L24
      Open

                              <input type='radio' name='db_pconnect' value='0'".($this->db_pconnect != 1 ? " checked='checked'" : "" )." />"._INSTALL_L24."

      Reference to undeclared constant \_INSTALL_L24
      Open

              $yesno = empty($this->db_pconnect) ? _INSTALL_L24 : _INSTALL_L23;

      Reference to undeclared constant \_INSTALL_L29
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L29);

      Reference to undeclared constant \_INSTALL_L56
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L56);

      Reference to undeclared constant \_INSTALL_L56
      Open

              $ret .= $this->editform_sub(_INSTALL_L56, _INSTALL_L58, 'xoops_url', $this->sanitizer->htmlSpecialChars($this->xoops_url));

      Reference to undeclared constant \_INSTALL_L51
      Open

                              <b>"._INSTALL_L51."</b><br />

      Reference to undeclared constant \_INSTALL_L65
      Open

              $ret .= $this->editform_sub(_INSTALL_L28, _INSTALL_L65, 'dbuname', $this->sanitizer->htmlSpecialChars($this->dbuname));

      Reference to undeclared constant \_INSTALL_L30
      Open

              $ret .= $this->editform_sub(_INSTALL_L30, _INSTALL_L63, 'prefix', $this->sanitizer->htmlSpecialChars($this->prefix));

      Reference to undeclared constant \_INSTALL_L27
      Open

                              <td class='bg3'><b>"._INSTALL_L27."</b></td>

      Reference to undeclared constant \_INSTALL_L57
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L27);

      Call to method getInstance from undeclared class \icms_core_Textsanitizer
      Open

              $this->sanitizer =& icms_core_Textsanitizer::getInstance();
      Severity: Critical
      Found in htdocs/install/class/settingmanager.php by phan

      Reference to undeclared constant \_INSTALL_L27
      Open

              $ret .= $this->editform_sub(_INSTALL_L27, _INSTALL_L67, 'dbhost', $this->sanitizer->htmlSpecialChars($this->dbhost));

      Reference to undeclared constant \_INSTALL_L63
      Open

              $ret .= $this->editform_sub(_INSTALL_L30, _INSTALL_L63, 'prefix', $this->sanitizer->htmlSpecialChars($this->prefix));

      Reference to undeclared constant \_INSTALL_L51
      Open

                              <td class='bg3'><b>"._INSTALL_L51."</b></td>

      Reference to undeclared constant \_INSTALL_L54
      Open

                              <td class='bg3'><b>"._INSTALL_L54."</b></td>

      Call to method createSalt from undeclared class \icms_core_Password
      Open

              return icms_core_Password::createSalt(5);;
      Severity: Critical
      Found in htdocs/install/class/settingmanager.php by phan

      Reference to undeclared constant \_INSTALL_L27
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L27);

      Reference to undeclared constant \_INSTALL_L57
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L30);

      Reference to undeclared constant \_INSTALL_L23
      Open

                              <input type='radio' name='db_pconnect' value='1'".($this->db_pconnect == 1 ? " checked='checked'" : "" )." />"._INSTALL_L23."

      Reference to undeclared constant \_INSTALL_L56
      Open

                              <td class='bg3'><b>"._INSTALL_L56."</b></td>

      Reference to undeclared constant \_INSTALL_L57
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L29);

      Reference to undeclared constant \_INSTALL_L30
      Open

                  $error[] = sprintf(_INSTALL_L57, _INSTALL_L30);

      Reference to undeclared constant \_INSTALL_L54
      Open

                              <b>"._INSTALL_L54."</b><br />

      Each class must be in a namespace of at least one level (a top-level vendor name)
      Open

      class setting_manager {

      The property $db_pconnect is not named in camelCase.
      Open

      class setting_manager {
      
          var $database;
          var $dbhost;
          var $dbuname;

      CamelCasePropertyName

      Since: 0.2

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

      Example

      class ClassName {
          protected $property_name;
      }

      Source

      The property $xoops_url is not named in camelCase.
      Open

      class setting_manager {
      
          var $database;
          var $dbhost;
          var $dbuname;

      CamelCasePropertyName

      Since: 0.2

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

      Example

      class ClassName {
          protected $property_name;
      }

      Source

      The property $root_path is not named in camelCase.
      Open

      class setting_manager {
      
          var $database;
          var $dbhost;
          var $dbuname;

      CamelCasePropertyName

      Since: 0.2

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

      Example

      class ClassName {
          protected $property_name;
      }

      Source

      The class setting_manager is not named in CamelCase.
      Open

      class setting_manager {
      
          var $database;
          var $dbhost;
          var $dbuname;

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

      Visibility must be declared on method "readConstant"
      Open

          function readConstant() {

      The var keyword must not be used to declare a property
      Open

          var $dbuname;

      Visibility must be declared on property "$dbuname"
      Open

          var $dbuname;

      The var keyword must not be used to declare a property
      Open

          var $root_path;

      The var keyword must not be used to declare a property
      Open

          var $xoops_url;

      Each PHP statement must be on a line by itself
      Open

              return icms_core_Password::createSalt(5);;

      Visibility must be declared on method "checkData"
      Open

          function checkData() {

      Visibility must be declared on method "getDBList"
      Open

          function getDBList()

      Visibility must be declared on property "$database"
      Open

          var $database;

      Visibility must be declared on property "$prefix"
      Open

          var $prefix;

      Visibility must be declared on method "__construct"
      Open

          function __construct($post=false) {

      Incorrect spacing between argument "$post" and equals sign; expected 1 but found 0
      Open

          function __construct($post=false) {

      Visibility must be declared on method "readPost"
      Open

          function readPost() {

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

                  "<table width='100%' class='outer' cellspacing='5'>

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

          {

      The var keyword must not be used to declare a property
      Open

          var $dbhost;

      Space found after opening bracket of FOREACH loop
      Open

                  foreach ( $error as $err) {

      Visibility must be declared on property "$xoops_url"
      Open

          var $xoops_url;

      Visibility must be declared on property "$sanitizer"
      Open

          var $sanitizer;

      Visibility must be declared on property "$dbhost"
      Open

          var $dbhost;

      The var keyword must not be used to declare a property
      Open

          var $db_pconnect;

      Incorrect spacing between default value and equals sign for argument "$post"; expected 1 but found 0
      Open

          function __construct($post=false) {

      Visibility must be declared on property "$dbpass"
      Open

          var $dbpass;

      Method name "setting_manager::editform_sub" is not in camel caps format
      Open

          function editform_sub($title, $desc, $name, $value) {

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

                  "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='90%'><tr><td class='bg2'>

      The var keyword must not be used to declare a property
      Open

          var $dbname;

      Visibility must be declared on property "$db_pconnect"
      Open

          var $db_pconnect;

      Visibility must be declared on property "$root_path"
      Open

          var $root_path;

      Visibility must be declared on method "editform_sub"
      Open

          function editform_sub($title, $desc, $name, $value) {

      The var keyword must not be used to declare a property
      Open

          var $dbpass;

      The var keyword must not be used to declare a property
      Open

          var $prefix;

      Visibility must be declared on method "editform"
      Open

          function editform() {

      Visibility must be declared on method "generatePrefix"
      Open

          function generatePrefix() {

      The var keyword must not be used to declare a property
      Open

          var $database;

      Visibility must be declared on property "$dbname"
      Open

          var $dbname;

      The var keyword must not be used to declare a property
      Open

          var $sanitizer;

      Visibility must be declared on method "confirmForm"
      Open

          function confirmForm() {

      Inline control structures are not allowed
      Open

              if (isset($_POST['dbhost']))

      Inline control structures are not allowed
      Open

              if (isset($_POST['dbuname']))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_PREFIX'))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_URL'))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_PASS'))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_PCONNECT'))

      Inline control structures are not allowed
      Open

                  if ($val == $this->database) $ret .= " selected='selected'";

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_ROOT_PATH'))

      Inline control structures are not allowed
      Open

              if (isset($_POST['xoops_url']))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_NAME'))

      Inline control structures are not allowed
      Open

              if (isset($_POST['root_path']))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_TYPE'))

      Inline control structures are not allowed
      Open

              if (isset($_POST['db_pconnect']))

      Inline control structures are not allowed
      Open

              if (isset($_POST['dbpass']))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_USER'))

      Inline control structures are not allowed
      Open

              if (isset($_POST['prefix']))

      Inline control structures are not allowed
      Open

              if (defined('XOOPS_DB_HOST'))

      Inline control structures are not allowed
      Open

              if (isset($_POST['database']))

      Inline control structures are not allowed
      Open

              if (isset($_POST['dbname']))

      No space found after comma in function call
      Open

                  $this->root_path = str_replace("\\","/",getcwd()); // "

      Class name "setting_manager" is not in camel caps format
      Open

      class setting_manager {

      No space found after comma in function call
      Open

                      $filepath = substr($filepath,1);

      No space found after comma in function call
      Open

                  $this->root_path = str_replace("\\","/",getcwd()); // "

      Expected 0 spaces after opening bracket; 1 found
      Open

                  foreach ( $error as $err) {

      The method editform_sub is not named in camelCase.
      Open

          function editform_sub($title, $desc, $name, $value) {
              $inputType = 'text';
              return  "<tr valign='top' align='left'>
                          <td class='head'>
                              <b>".$title."</b><br />

      CamelCaseMethodName

      Since: 0.2

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

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      Unexpected spaces found.
      Open

                          <td class='even'>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbuname)."</td>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->prefix)."</td>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='dbuname' value='".$this->sanitizer->htmlSpecialChars($this->dbuname)."' />

      Unexpected spaces found.
      Open

                              <b>"._INSTALL_L51."</b><br />

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->database)."</td>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <select  size='1' name='database' id='database'>";

      Unexpected spaces found.
      Open

                      ";

      Unexpected spaces found.
      Open

                              <b>".$title."</b><br />

      Unexpected spaces found.
      Open

                      </tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbhost)."</td>

      Unexpected spaces found.
      Open

                      </tr>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbpass)."</td>

      Unexpected spaces found.
      Open

                  "<table border='0' cellpadding='0' cellspacing='0' valign='top' width='90%'><tr><td class='bg2'>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L55."</b></td>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L29."</b></td>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                              <span style='font-size:85%;'>"._INSTALL_L66."</span>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                              <input type='radio' name='db_pconnect' value='1'".($this->db_pconnect == 1 ? " checked='checked'" : "" )." />"._INSTALL_L23."

      Unexpected spaces found.
      Open

                      ";

      Unexpected spaces found.
      Open

                          <td class='head'>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L30."</b></td>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='dbhost' value='".$this->sanitizer->htmlSpecialChars($this->dbhost)."' />

      Unexpected spaces found.
      Open

                      ";

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->dbname)."</td>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='root_path' value='".$this->sanitizer->htmlSpecialChars($this->root_path)."' />

      Unexpected spaces found.
      Open

                  <input type='hidden' name='xoops_url' value='".$this->sanitizer->htmlSpecialChars($this->xoops_url)."' />

      Unexpected spaces found.
      Open

                              <input type='radio' name='db_pconnect' value='0'".($this->db_pconnect != 1 ? " checked='checked'" : "" )." />"._INSTALL_L24."

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L51."</b></td>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L27."</b></td>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='dbpass' value='".$this->sanitizer->htmlSpecialChars($this->dbpass)."' />

      Unexpected spaces found.
      Open

                  "<table width='100%' class='outer' cellspacing='5'>

      Unexpected spaces found.
      Open

                              <span style='font-size:85%;'>".$desc."</span>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L28."</b></td>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L54."</b></td>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->xoops_url)."</td>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='db_pconnect' value='". (int) ($this->db_pconnect)."' />

      Unexpected spaces found.
      Open

                      <tr valign='top' align='left'>

      Unexpected spaces found.
      Open

                          <td class='head'>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L52."</b></td>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                      </table></td></tr>

      Unexpected spaces found.
      Open

                      <tr>

      Unexpected spaces found.
      Open

                      </tr>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                      <table width='100%' border='0' cellpadding='4' cellspacing='1'>

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$this->sanitizer->htmlSpecialChars($this->root_path)."</td>

      Unexpected spaces found.
      Open

                          <td class='head'>

      Unexpected spaces found.
      Open

                              <b>"._INSTALL_L54."</b><br />

      Unexpected spaces found.
      Open

                          <td class='even'>

      Unexpected spaces found.
      Open

                              <td class='bg1'>".$yesno."</td>

      Unexpected spaces found.
      Open

                              <td class='bg3'><b>"._INSTALL_L56."</b></td>

      Unexpected spaces found.
      Open

                          <th colspan='2'></th>

      Unexpected spaces found.
      Open

                              <input type='$inputType' name='".$name."' id='".$name."' size='30' maxlength='100' value='".htmlspecialchars($value)."' />

      Unexpected spaces found.
      Open

                          </tr>

      Unexpected spaces found.
      Open

                          <tr>

      Unexpected spaces found.
      Open

                          </td>

      Unexpected spaces found.
      Open

                          <td class='even'>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='database' value='".$this->sanitizer->htmlSpecialChars($this->database)."' />

      Unexpected spaces found.
      Open

                  <input type='hidden' name='dbname' value='".$this->sanitizer->htmlSpecialChars($this->dbname)."' />

      Unexpected spaces found.
      Open

                              <span style='font-size:85%;'>"._INSTALL_L69."</span>

      Unexpected spaces found.
      Open

                      </tr>

      Unexpected spaces found.
      Open

                  </table>

      Unexpected spaces found.
      Open

                  <input type='hidden' name='prefix' value='".$this->sanitizer->htmlSpecialChars($this->prefix)."' />

      Unexpected spaces found.
      Open

                  ";

      There are no issues that match your filters.

      Category
      Status