XoopsModules25x/lexikon

View on GitHub

Showing 316 of 316 total issues

Function truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
    {
        if ($considerHtml) {
            // if the plain text is shorter than the maximum length, return the whole text
            if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
Severity: Minor
Found in class/Common/SysUtility.php - About 1 day 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

File blocksadmin.php has 502 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

/**
Severity: Major
Found in admin/blocksadmin.php - About 1 day to fix

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

        if ($result2) {
            while (false !== ($row1 = $xoopsDB->fetchArray($sql2))) {
                $categoryID  = (int)$row1['categoryID'];
                $name        = $myts->addSlashes($row1['name']);
                $description = $myts->addSlashes(import2db($row1['description']));
    Severity: Major
    Found in admin/importxwords.php and 1 other location - About 7 hrs to fix
    admin/importwordbook.php on lines 205..235

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

    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

        if ($result3) {
            while (false !== ($row1 = $xoopsDB->fetchArray($sql3))) {
                $categoryID  = (int)$row1['categoryID'];
                $name        = $myts->addSlashes($row1['name']);
                $description = $myts->addSlashes(import2db($row1['description']));
    Severity: Major
    Found in admin/importwordbook.php and 1 other location - About 7 hrs to fix
    admin/importxwords.php on lines 201..230

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

    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

    File entry.php has 476 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Module: Lexikon - glossary module
     * Author: hsalazar
     * Modifs: Yerres
    Severity: Minor
    Found in admin/entry.php - About 7 hrs to fix

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

          if ('' != $block['template'] && !defined('XOOPS_ORETEKI')) {
              /** @var \XoopsTplfileHandler $tplfileHandler */
              $tplfileHandler = xoops_getHandler('tplfile');
              $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
              if (count($btemplate) > 0) {
      Severity: Major
      Found in admin/myblockform.php and 1 other location - About 7 hrs to fix
      admin/blockform.php on lines 78..90

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

      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

          if ('' !== $block['template']) {
              /** @var \XoopsTplfileHandler $tplfileHandler */
              $tplfileHandler = xoops_getHandler('tplfile');
              $btemplate      = $tplfileHandler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $block['bid']);
              if (count($btemplate) > 0) {
      Severity: Major
      Found in admin/blockform.php and 1 other location - About 7 hrs to fix
      admin/myblockform.php on lines 79..91

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

      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

      File blocksadmin.inc.php has 455 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /*
       * You may not change or alter any portion of this comment or credits
       * of supporting developers from this source code or any supporting source code
       * which is considered copyrighted (c) material of the original comment or credit authors.
      Severity: Minor
      Found in include/blocksadmin.inc.php - About 6 hrs to fix

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

            if (!$entryID) { // there's no entryID? Then it's a new entry
                $butt_create = new \XoopsFormButton('', '', _AM_LEXIKON_CREATE, 'submit');
                $butt_create->setExtra('onclick="this.form.elements.op.value=\'addentry\'"');
                $buttonTray->addElement($butt_create);
        
        
        Severity: Major
        Found in admin/entry.php and 1 other location - About 6 hrs to fix
        admin/category.php on lines 228..247

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

        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

            if (!$categoryID) {
                $butt_create = new \XoopsFormButton('', '', _AM_LEXIKON_CREATE, 'submit');
                $butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"');
                $buttonTray->addElement($butt_create);
        
        
        Severity: Major
        Found in admin/category.php and 1 other location - About 6 hrs to fix
        admin/entry.php on lines 355..374

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

        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

        Function entrySave has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

        function entrySave($entryID = '')
        {
            global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsDB;
            $helper  = Helper::getInstance();
            $utility = new Utility();
        Severity: Minor
        Found in admin/entry.php - About 6 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 DefinitionImport has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

        function DefinitionImport($delete)
        {
            global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $entryID, $myts;
            $sqlQuery = $xoopsDB->query('SELECT count(entryID) AS count FROM ' . $xoopsDB->prefix('wbentries'));
            [$count] = $xoopsDB->fetchRow($sqlQuery);
        Severity: Minor
        Found in admin/importwordbook.php - About 6 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 DefinitionImport has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        function DefinitionImport($delete)
        {
            global $xoopsConfig, $xoopsDB, $xoopsModule, $myts;
            $sqlQuery = $xoopsDB->query('SELECT count(id) AS count FROM ' . $xoopsDB->prefix('dictionary'));
            [$count] = $xoopsDB->fetchRow($sqlQuery);
        Severity: Minor
        Found in admin/importdictionary.php - About 6 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 DefinitionImport has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
        Open

        function DefinitionImport($delete)
        {
            global $xoopsConfig, $xoopsDB, $xoopsModule;
            $myts     = \MyTextSanitizer::getInstance();
            $sqlQuery = $xoopsDB->query('SELECT count(entryID) AS count FROM ' . $xoopsDB->prefix('xwords_ent'));
        Severity: Minor
        Found in admin/importxwords.php - About 6 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

        Method DefinitionImport has 160 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function DefinitionImport($delete)
        {
            global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $entryID, $myts;
            $sqlQuery = $xoopsDB->query('SELECT count(entryID) AS count FROM ' . $xoopsDB->prefix('wbentries'));
            [$count] = $xoopsDB->fetchRow($sqlQuery);
        Severity: Major
        Found in admin/importwordbook.php - About 6 hrs to fix

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

              case 'delete':
                  $entriesObject = $entriesHandler->get(Request::getString('entryID', ''));
                  if (1 == Request::getInt('ok', 0)) {
                      if (!$GLOBALS['xoopsSecurity']->check()) {
                          redirect_header('entries.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
          Severity: Major
          Found in admin/entries.php and 1 other location - About 6 hrs to fix
          admin/categories.php on lines 329..343

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

          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

              case 'delete':
                  $categoriesObject = $categoriesHandler->get(Request::getString('categoryID', ''));
                  if (1 == Request::getInt('ok', 0)) {
                      if (!$GLOBALS['xoopsSecurity']->check()) {
                          redirect_header('categories.php', 3, implode(', ', $GLOBALS['xoopsSecurity']->getErrors()));
          Severity: Major
          Found in admin/categories.php and 1 other location - About 6 hrs to fix
          admin/entries.php on lines 274..288

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

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

          function entryEdit($entryID = '')
          {
              global $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $init;
              $helper = Helper::getInstance();
          
          
          Severity: Major
          Found in admin/entry.php - About 6 hrs to fix

            Function listBlocks has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
            Open

                function listBlocks()
                {
                    global $xoopsModule, $pathIcon16;
                    //        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
                    xoops_load('xoopslist');
            Severity: Minor
            Found in admin/blocksadmin.php - About 6 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

            Utility has 43 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Utility extends Common\SysUtility
            {
                //--------------- Custom module methods -----------------------------
                /**
                 * static::getLinkedUnameFromId()
            Severity: Minor
            Found in class/Utility.php - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language