XoopsModules25x/xoopstube

View on GitHub
class/Tree.php

Summary

Maintainability
A
3 hrs
Test Coverage

Method makeMySelBox has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
    {
        if ('' === $sel_name) {
            $sel_name = $this->id;
        }
Severity: Minor
Found in class/Tree.php - About 1 hr to fix

    Function makeMySelBox has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
        {
            if ('' === $sel_name) {
                $sel_name = $this->id;
            }
    Severity: Minor
    Found in class/Tree.php - About 1 hr 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

    Method makeMySelBox has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
    Severity: Minor
    Found in class/Tree.php - About 45 mins to fix

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

              $this->db    = \XoopsDatabaseFactory::getDatabaseConnection();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 '\MyTextSanitizer' in method 'getNicePathFromId'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 '\MyTextSanitizer' in method 'getPathFromId'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 '\MyTextSanitizer' in method 'makeMySelBox'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 unused local variables such as '$myts'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 '$myts'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 '$myts'.
      Open

              $myts = \MyTextSanitizer::getInstance();
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 variables with short names like $id. Configured minimum length is 3.
      Open

          public $id; //name of unique id for records in table $table
      Severity: Minor
      Found in class/Tree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      Avoid variables with short names like $db. Configured minimum length is 3.
      Open

          public $db;
      Severity: Minor
      Found in class/Tree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      The parameter $sel_name is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

      Avoid variables with short names like $id. Configured minimum length is 3.
      Open

              while (list($id) = $this->db->fetchRow($result)) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      ShortVariable

      Since: 0.2

      Detects when a field, local, or parameter has a very short name.

      Example

      class Something {
          private $q = 15; // VIOLATION - Field
          public static function main( array $as ) { // VIOLATION - Formal
              $r = 20 + $this->q; // VIOLATION - Local
              for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                  $r += $this->q;
              }
          }
      }

      Source https://phpmd.org/rules/naming.html#shortvariable

      The parameter $r_prefix is not named in camelCase.
      Open

          public function getChildTreeArray($selectId = 0, $order = '', array $parray = [], $r_prefix = '')
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ' ';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

      The parameter $preset_id is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

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

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

      Line exceeds 120 characters; contains 134 characters
      Open

              $result   = $this->db->query('SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . '');
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      Line exceeds 120 characters; contains 142 characters
      Open

              $result   = $this->db->query('SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$selectId");
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      Line exceeds 120 characters; contains 126 characters
      Open

              $result   = $this->db->query('SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$selectId");
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      Line exceeds 120 characters; contains 128 characters
      Open

                      $catpath          = $option['prefix'] . '&nbsp;' . \htmlspecialchars($option[$title], \ENT_QUOTES | \ENT_HTML5);
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      Line exceeds 120 characters; contains 124 characters
      Open

              $sql      = 'SELECT ' . $this->pid . ', ' . $title . ' FROM ' . $this->table . ' WHERE ' . $this->id . "=$selectId";
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      Line exceeds 120 characters; contains 125 characters
      Open

              $path = "<li><a href='" . $funcURL . '&amp;' . $this->id . '=' . $selectId . "'>" . $name . '</a></li>' . $path . '';
      Severity: Minor
      Found in class/Tree.php by phpcodesniffer

      The variable $r_prefix is not named in camelCase.
      Open

          public function getChildTreeArray($selectId = 0, $order = '', array $parray = [], $r_prefix = '')
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT * FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . ' ';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllParentId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllParentId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $sel_name is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllChildId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $sel_name is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $preset_id is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllChildId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $sel_name is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllChildId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->id . ' FROM ' . $this->table . ' WHERE ' . $this->pid . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllParentId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $preset_id is not named in camelCase.
      Open

          public function makeMySelBox($title, $order = '', $preset_id = 0, $none = 0, $sel_name = '', $onchange = '')
          {
              if ('' === $sel_name) {
                  $sel_name = $this->id;
              }
      Severity: Minor
      Found in class/Tree.php by phpmd

      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 $r_id is not named in camelCase.
      Open

          public function getAllParentId($selectId, $order = '', array $idarray = [])
          {
              $selectId = (int)$selectId;
              $sql      = 'SELECT ' . $this->pid . ' FROM ' . $this->table . ' WHERE ' . $this->id . '=' . $selectId . '';
              if ('' !== $order) {
      Severity: Minor
      Found in class/Tree.php by phpmd

      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

      There are no issues that match your filters.

      Category
      Status