ImpressCMS/impresscms

View on GitHub

Showing 47,251 of 47,256 total issues

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

        $section['events'] = array();

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

Function Selector has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

Prototype.Selector = (function() {

    function select() {
        throw new Error('Method "Prototype.Selector.select" must be defined.');
    }
Severity: Minor
Found in htdocs/install/prototype.js - About 1 hr to fix

    Function TCGenerateMac has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function TCGenerateMac() {
        var s = '';
        var c = 0,n = 1;
        var r,g,b;
        for (j = 0; j < 15; j ++) {
    Severity: Minor
    Found in htdocs/include/color-picker.js - About 1 hr to fix

      Method xoFormFieldCollation has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function xoFormFieldCollation($name, $value, $label, $link, $charset, $help = '') {
          if (version_compare(getDBVersion($link), "4.1.0", "lt")) {
              return "";
          }
          if (empty ($charset) || !$collations = getDbCollations($link, $charset)) {
      Severity: Minor
      Found in htdocs/install/page_dbsettings.php - About 1 hr to fix

        Method checkSql has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function checkSql($sql) {
                list($sql_wo_strings, $strings) = $this->separateStringsInSQL($sql);
        
                // stage1: addslashes() processed or not
                foreach ($this->doubtful_requests as $request) {

          Method deny_by_htaccess has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function deny_by_htaccess($ip = null) {
                  if (empty($ip)) $ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
                  if (empty($ip)) return false;
                  if (!function_exists('file_get_contents')) return false;
          
          

            Method draw_repost_form has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    function draw_repost_form($area = '') {
                        // Notify which file is broken
                        if (headers_sent()) {
                            restore_error_handler();
                            set_error_handler(array (

              Method imCheckRequirements has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function imCheckRequirements()
              {
                  $requirement['server_api']['description']=PHP_SAPI;
                  $requirement['server_api']['result']=php_sapi_name();
                  $requirement['server_api']['status']=true;
              Severity: Minor
              Found in htdocs/install/page_modcheck.php - About 1 hr to fix

                Method imanager_delfileok has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function imanager_delfileok($image_id, $redir = NULL) {
                    global $target, $type;
                    if (!icms::$security->check()) {
                        redirect_header('browser.php?op=list&target=' . $target . '&type=' . $type, 3, implode('<br />', icms::$security->getErrors()));
                    }
                Severity: Minor
                Found in htdocs/modules/system/admin/images/browser.php - About 1 hr to fix

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

                  Form.Element.EventObserver = Class.create(Abstract.EventObserver, {
                      getValue: function() {
                          return Form.Element.getValue(this.element);
                      }
                  });
                  Severity: Major
                  Found in htdocs/install/prototype.js and 1 other location - About 1 hr to fix
                  htdocs/install/prototype.js on lines 6620..6624

                  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 58.

                  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

                  Form.Element.Observer = Class.create(Abstract.TimedObserver, {
                      getValue: function() {
                          return Form.Element.getValue(this.element);
                      }
                  });
                  Severity: Major
                  Found in htdocs/install/prototype.js and 1 other location - About 1 hr to fix
                  htdocs/install/prototype.js on lines 6673..6677

                  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 58.

                  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

                  $modversion['config'][] = array(
                      'name' => 'union_action',
                      'title' => $constpref . '_UNION_ACTION',
                      'description' => $constpref . '_UNION_ACTIONDSC',
                      'formtype' => 'select',
                  htdocs/install/modules/protector/trust_path/modules/protector/icms_version.php on lines 138..150

                  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

                          foreach ( $commands as $cmd) {
                              if (!@empty( $this->f_tables[$cmd] )) {
                                  foreach ( $this->f_tables[$cmd] as $key => $val) {
                                      $content .= '<li class="failure">';
                                      $content .= ($cmd!='insert') ? sprintf( $this->failureStrings[$cmd], $key ) : sprintf( $this->failureStrings[$cmd], $val, $key );
                  Severity: Major
                  Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
                  htdocs/install/class/dbmanager.php on lines 147..155

                  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

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

                      if ($uid == icms::$user->getVar('uid')) {
                          $xoopsOption['template_main'] = 'system_userinfo.html';
                          include ICMS_ROOT_PATH . '/header.php';
                          $icmsTpl->assign('user_ownpage', true);
                          icms_makeSmarty(array(
                  Severity: Major
                  Found in htdocs/userinfo.php and 1 other location - About 1 hr to fix
                  htdocs/userinfo.php on lines 72..104

                  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

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

                  if (is_object(icms::$user)) {
                      if ($uid == icms::$user->getVar('uid')) {
                          $xoopsOption['template_main'] = 'system_userinfo.html';
                          include ICMS_ROOT_PATH . '/header.php';
                          $icmsTpl->assign('user_ownpage', true);
                  Severity: Major
                  Found in htdocs/userinfo.php and 1 other location - About 1 hr to fix
                  htdocs/userinfo.php on lines 73..95

                  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

                  $modversion['config'][] = array(
                      'name' => 'isocom_action',
                      'title' => $constpref . '_ISOCOM_ACTION',
                      'description' => $constpref . '_ISOCOM_ACTIONDSC',
                      'formtype' => 'select',
                  htdocs/install/modules/protector/trust_path/modules/protector/icms_version.php on lines 151..163

                  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

                          foreach ( $commands as $cmd) {
                              if (!@empty( $this->s_tables[$cmd] )) {
                                  foreach ( $this->s_tables[$cmd] as $key => $val) {
                                      $content .= '<li class="success">';
                                      $content .= ($cmd!='insert') ? sprintf( $this->successStrings[$cmd], $key ) : sprintf( $this->successStrings[$cmd], $val, $key );
                  Severity: Major
                  Found in htdocs/install/class/dbmanager.php and 1 other location - About 1 hr to fix
                  htdocs/install/class/dbmanager.php on lines 156..164

                  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

                  Method icmsPopupHeader has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function icmsPopupHeader() {
                      //TODO: make the image manager header use a template instead of hardcoded HTML
                      global $icmsConfig;
                      if (!headers_sent()) {
                          header('Content-Type:text/html; charset=' . _CHARSET);
                  Severity: Minor
                  Found in htdocs/modules/system/admin/images/browser.php - About 1 hr to fix

                    Function icms_escapeValue has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function icms_escapeValue($value, $quotes = true)
                    {
                        if(is_string($value))
                        {
                            $value = icms::$xoopsDB->escape($value);
                    Severity: Minor
                    Found in htdocs/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 icms_getfloat has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function icms_getfloat($str, $set=FALSE)
                    {
                        if(preg_match("/([0-9\.,-]+)/", $str, $match))
                        {
                            // Found number in $str, so set $str that number
                    Severity: Minor
                    Found in htdocs/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

                    Severity
                    Category
                    Status
                    Source
                    Language