XoopsModules25x/xoopsinfo

View on GitHub
modules/xoopsinfo/include/functions.php

Summary

Maintainability
C
1 day
Test Coverage

XoopsInfo_GetLastVersion accesses the super-global variable $GLOBALS.
Open

function XoopsInfo_GetLastVersion()
{
    global $modversion;

    $version = @file_get_contents($modversion['status_fileinfo']);

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

XoopsInfo_UpdatedModule accesses the super-global variable $GLOBALS.
Open

function XoopsInfo_UpdatedModule()
{
    global $modversion;

    if ($modversion['version'] != $GLOBALS['xoopsModule']->getVar('version') / 100) {

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

XoopsInfo_UpdatedModule accesses the super-global variable $GLOBALS.
Open

function XoopsInfo_UpdatedModule()
{
    global $modversion;

    if ($modversion['version'] != $GLOBALS['xoopsModule']->getVar('version') / 100) {

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

function adminmenu($currentoption = 0, $breadcrumb = '')
{
    global $xoopsModule, $xoopsConfig, $modversion;

    /* Nice buttons styles */
Severity: Major
Found in modules/xoopsinfo/include/functions.php - About 2 hrs to fix

    Function adminmenu has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function adminmenu($currentoption = 0, $breadcrumb = '')
    {
        global $xoopsModule, $xoopsConfig, $modversion;
    
        /* Nice buttons styles */
    Severity: Minor
    Found in modules/xoopsinfo/include/functions.php - About 2 hrs 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 XoopsInfo_moduleoption has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
    {
        global $xoopsModuleConfig, $xoopsModule;
    
        static $tbloptions = [];
    Severity: Minor
    Found in modules/xoopsinfo/include/functions.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

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

    function XoopsInfo_GetLastVersion()
    {
        global $modversion;
    
        $version = @file_get_contents($modversion['status_fileinfo']);
    Severity: Minor
    Found in modules/xoopsinfo/include/functions.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 filemtime_override has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    function filemtime_override($dirname, $template, $theme = '', $block = false)
    {
        global $xoopsConfig;
    
        $themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
    Severity: Minor
    Found in modules/xoopsinfo/include/functions.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

    Consider simplifying this complex logical expression.
    Open

        if (defined('_PHPSYSINFO') && defined('_PHPSECINFO')) {
            $break = 4;
        } elseif ((defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) || (!defined('_PHPSYSINFO') && defined('_PHPSECINFO'))) {
            $break = 3;
        } elseif (!defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) {
    Severity: Major
    Found in modules/xoopsinfo/include/functions.php - About 40 mins to fix

      Function check_override has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function check_override($dirname, $template, $theme = '', $block = false)
      {
          global $xoopsConfig;
      
          $themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;
      Severity: Minor
      Found in modules/xoopsinfo/include/functions.php - About 25 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 function adminmenu() has an NPath complexity of 324. The configured NPath complexity threshold is 200.
      Open

      function adminmenu($currentoption = 0, $breadcrumb = '')
      {
          global $xoopsModule, $xoopsConfig, $modversion;
      
          /* Nice buttons styles */

      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 function adminmenu() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10.
      Open

      function adminmenu($currentoption = 0, $breadcrumb = '')
      {
          global $xoopsModule, $xoopsConfig, $modversion;
      
          /* Nice buttons styles */

      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 function XoopsInfo_moduleoption() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
      Open

      function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
      {
          global $xoopsModuleConfig, $xoopsModule;
      
          static $tbloptions = [];

      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

      Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices.
      Open

          $tblColors = array_fill(0, count($adminmenu), '');

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices.
      Open

          for ($i = 0, $iMax = count($adminmenu); $i < $iMax; $i++) {

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices.
      Open

              echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$headermenu' which will lead to PHP notices.
      Open

          for ($i = 0, $iMax = count($headermenu); $i < $iMax; $i++) {

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$headermenu' which will lead to PHP notices.
      Open

              if ($i < count($headermenu) - 1) {

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$headermenu' which will lead to PHP notices.
      Open

              echo '<a class="nobutton" href="' . $headermenu[$i]['link'] . '">' . $headermenu[$i]['title'] . '</a> ';

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$headermenu' which will lead to PHP notices.
      Open

              echo '<a class="nobutton" href="' . $headermenu[$i]['link'] . '">' . $headermenu[$i]['title'] . '</a> ';

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Avoid using undefined variables such as '$adminmenu' which will lead to PHP notices.
      Open

              echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

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

      Missing class import via use statement (line '157', column '24').
      Open

          $criteria->add(new Criteria('mid', 1), 'OR');

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '165', column '27').
      Open

          $modules_select = new XoopsFormSelect(_AM_XI_MIME_MODULES, 'mid', $mid);

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Remove error control operator '@' on line 293.
      Open

      function XoopsInfo_GetLastVersion()
      {
          global $modversion;
      
          $version = @file_get_contents($modversion['status_fileinfo']);

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

      Remove error control operator '@' on line 285.
      Open

      function filemtime_override($dirname, $template, $theme = '', $block = false)
      {
          global $xoopsConfig;
      
          $themeset = '' == $theme ? $xoopsConfig['theme_set'] : $theme;

      ErrorControlOperator

      Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

      Example

      function foo($filePath) {
          $file = @fopen($filPath); // hides exceptions
          $key = @$array[$notExistingKey]; // assigns null to $key
      }

      Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

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

      function check_override($dirname, $template, $theme = '', $block = 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

      Missing class import via use statement (line '153', column '39').
      Open

          $criteria = new CriteriaCompo(new Criteria('hasmain', 1));

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '153', column '21').
      Open

          $criteria = new CriteriaCompo(new Criteria('hasmain', 1));

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

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

      function filemtime_override($dirname, $template, $theme = '', $block = 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

      Missing class import via use statement (line '155', column '24').
      Open

          $criteria->add(new Criteria('isactive', 1));

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

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

          } else {
              include_once XOOPS_ROOT_PATH . '/modules/xoopsinfo/language/english/modinfo.php';
          }

      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

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

              } else {
                  $filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
              }

      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

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

                  } else {
                      echo $modversion['developer_website_url'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];
                  }

      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

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

          } else {
              if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
                  $filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template;
              } else {
                  $filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;

      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

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

          } else {
              if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
                  return true;
              }
          }

      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

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

              } else {
                  $filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/blocks/' . $template;
              }

      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

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

          } else {
              $module_handler = xoops_getHandler('module');
      
              $module = $module_handler->getByDirname($repmodule);
      
      

      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

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

              } else {
                  echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';
      
                  echo _AM_XI_NO_UPGRADE;
      
      

      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

      Avoid unused parameters such as '$breadcrumb'.
      Open

      function adminmenu($currentoption = 0, $breadcrumb = '')

      UnusedFormalParameter

      Since: 0.2

      Avoid passing parameters to methods or constructors and then not using those parameters.

      Example

      class Foo
      {
          private function bar($howdy)
          {
              // $howdy is not used
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

      Avoid unused local variables such as '$modversion'.
      Open

          global $xoopsModule, $xoopsConfig, $modversion;

      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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          if ($block) {
              if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/blocks/' . $template)) {
                  $filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/blocks/' . $template;
              } else {
                  $filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/blocks/' . $template;
      Severity: Major
      Found in modules/xoopsinfo/include/functions.php and 1 other location - About 1 hr to fix
      modules/xoopsinfo/include/functions.php on lines 276..282

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 103.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          } else {
              if (file_exists(XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template)) {
                  $filename = XOOPS_ROOT_PATH . '/themes/' . $themeset . '/modules/' . $dirname . '/' . $template;
              } else {
                  $filename = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/templates/' . $template;
      Severity: Major
      Found in modules/xoopsinfo/include/functions.php and 1 other location - About 1 hr to fix
      modules/xoopsinfo/include/functions.php on lines 270..282

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 103.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 25 and the first side effect is on line 18.
      Open

      <?php

      Line exceeds 120 characters; contains 123 characters
      Open

          echo '<td style="width: 100%; font-size: 10px; text-align: left; color: #2F5376; padding: 0 6px; line-height: 18px;">';

      Line exceeds 120 characters; contains 151 characters
      Open

                      echo $modversion['developer_website_url'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];

      Line exceeds 120 characters; contains 140 characters
      Open

                  echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';

      Line exceeds 120 characters; contains 186 characters
      Open

                  #buttonbar a { float:left; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 5px; text-decoration:none; }

      Line exceeds 120 characters; contains 123 characters
      Open

          echo '<h3 style="margin:0 0 10px 0; text-align:center;">' . $xoopsModule->name() . '  ' . _AM_XI_MODULEADMIN . '</h3>';

      Line exceeds 120 characters; contains 130 characters
      Open

              $modules_select->addOption('templates.php?fct=templates&mid=' . $key . '&status=' . $status . '&theme=' . $theme, $value);

      Line exceeds 120 characters; contains 245 characters
      Open

                  #buttonbar { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/xoopsinfo/images/bg.png') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; }

      Line exceeds 120 characters; contains 267 characters
      Open

                  #buttonbar2 { float:left; width:100%; background: #e7e7e7 url('" . XOOPS_URL . "/modules/xoopsinfo/images/bg.png') repeat-x left bottom; font-size:93%; line-height:normal; border-left: 1px solid black; border-right: 1px solid black; margin-bottom: 10px; }

      Line exceeds 120 characters; contains 217 characters
      Open

                  #buttonbar2 a { float:left; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/left_both.png') no-repeat left top; margin:0; padding:0 0 0 5px; border-bottom:1px solid #000; text-decoration:none; }

      Line exceeds 120 characters; contains 213 characters
      Open

                  #buttonbar a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }

      Line exceeds 120 characters; contains 123 characters
      Open

          } elseif ((defined('_PHPSYSINFO') && !defined('_PHPSECINFO')) || (!defined('_PHPSYSINFO') && defined('_PHPSECINFO'))) {

      Line exceeds 120 characters; contains 214 characters
      Open

                  #buttonbar2 a span { float:left; display:block; background:url('" . XOOPS_URL . "/modules/xoopsinfo/images/right_both.png') no-repeat right top; padding:5px 15px 4px 6px; font-weight:bold; color:#765; }

      Line exceeds 120 characters; contains 140 characters
      Open

                  echo '<div class="bg1" style="margin:20px 100px; padding:5px; border:2px solid #FF0000; text-align:center; font-weight:bold;">';

      Line exceeds 120 characters; contains 146 characters
      Open

                      echo $modversion['download_website'] . '" target="_blank"><br><br><font color="#0000CC">' . $modversion['developer_website_name'];

      Line exceeds 120 characters; contains 140 characters
      Open

              $redirect = XOOPS_URL . '/modules/system/admin.php?fct=modulesadmin&op=update&module=' . $GLOBALS['xoopsModule']->getVar('dirname');

      Line exceeds 120 characters; contains 207 characters
      Open

                  #buttontop { float:left; width:100%; background: #e7e7e7; font-size:93%; line-height:normal; border-top: 1px solid black; border-left: 1px solid black; border-right: 1px solid black; margin: 0; }

      Line exceeds 120 characters; contains 125 characters
      Open

                  #buttonbar ul { margin:0; margin-top: 15px; padding:10px 0 0; list-style:none; white-space: nowrap; float:left; }

      Line exceeds 120 characters; contains 158 characters
      Open

              echo '<li id="' . $tblColors[$i] . '"><a href="' . XOOPSINFO_URL . $adminmenu[$i]['link'] . '"><span>' . $adminmenu[$i]['title'] . '</span></a></li>';

      Line exceeds 120 characters; contains 192 characters
      Open

          echo '<div align="right"><br><a target="_blank" href="http://www.dugris.info/"><img src="' . XOOPS_URL . '/modules/xoopsinfo/images/xoopsinfo.gif" border="0" align="absmiddle"></a></div>';

      Line exceeds 120 characters; contains 150 characters
      Open

          if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) {

      The variable $config_handler is not named in camelCase.
      Open

      function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
      {
          global $xoopsModuleConfig, $xoopsModule;
      
          static $tbloptions = [];

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
      {
          global $xoopsModuleConfig, $xoopsModule;
      
          static $tbloptions = [];

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

      function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
      {
          global $xoopsModuleConfig, $xoopsModule;
      
          static $tbloptions = [];

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function Template_GetModulesList()
      {
          global $mid, $theme, $status;
      
          $module_handler = xoops_getHandler('module');

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

      function XoopsInfo_moduleoption($option, $repmodule = 'xoopsinfo')
      {
          global $xoopsModuleConfig, $xoopsModule;
      
          static $tbloptions = [];

      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