mambax7/smartfaq

View on GitHub

Showing 649 of 649 total issues

Function getFaqsFromSearch has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFaqsFromSearch($queryarray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
    {
        global $xoopsUser;

        $ret              = [];
Severity: Minor
Found in class/FaqHandler.php - About 4 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

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

if (olIe4) {
    var agent = navigator.userAgent;
    if (/MSIE/.test(agent)) {
        var versNum = parseFloat(agent.match(/MSIE (\d\.\d+)\.*/)[1]);
        if (versNum >= 5) {
Severity: Major
Found in assets/js/overlib/mini/overlib_mini.js and 1 other location - About 4 hrs to fix
assets/js/overlib/overlib.js on lines 214..225

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

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 (olIe4) {
    var agent = navigator.userAgent;
    if (/MSIE/.test(agent)) {
        var versNum = parseFloat(agent.match(/MSIE (\d\.\d+)\.*/)[1]);
        if (versNum >= 5) {
Severity: Major
Found in assets/js/overlib/overlib.js and 1 other location - About 4 hrs to fix
assets/js/overlib/mini/overlib_mini.js on lines 175..186

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

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

    function sf_createThumbnail($source, $thumb_width)
    {
        /** @var Smartfaq\Helper $helper */
        $helper = Smartfaq\Helper::getInstance();

Severity: Major
Found in include/functions.image.php - About 4 hrs to fix

    Function getContextualFaqs has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getContextualFaqs($limit = 0)
        {
            $ret = false;
    
            $otherCriteria = new \CriteriaCompo();
    Severity: Minor
    Found in class/FaqHandler.php - About 3 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 render has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function render(?array $block = null)
        {
            \xoops_load('XoopsFormLoader');
            \xoops_loadLanguage('common', $this->moduleDirNameUpper);
    
    
    Severity: Major
    Found in class/Common/Blocksadmin.php - About 3 hrs to fix

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

      function opt_FRAME(frm) {
          o3_frame = compatibleFrame(frm) ? frm : ol_frame;
          if (olNs4) {
              over = o3_frame.document.layers['overDiv'];
          } else if (document.all) {
      Severity: Major
      Found in assets/js/overlib/mini/overlib_crossframe_mini.js and 1 other location - About 3 hrs to fix
      assets/js/overlib/overlib_crossframe.js on lines 45..57

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

      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

      function opt_FRAME(frm) {
          o3_frame = compatibleFrame(frm) ? frm : ol_frame;
      
          if (olNs4) {
              over = o3_frame.document.layers['overDiv'];
      Severity: Major
      Found in assets/js/overlib/overlib_crossframe.js and 1 other location - About 3 hrs to fix
      assets/js/overlib/mini/overlib_crossframe_mini.js on lines 23..33

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

      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

      function disp(statustext) {
          runHook("disp", FBEFORE);
      
          if (o3_allowmove == 0) {
              runHook("placeLayer", FREPLACE);
      Severity: Major
      Found in assets/js/overlib/overlib.js and 1 other location - About 3 hrs to fix
      assets/js/overlib/mini/overlib_mini.js on lines 399..408

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

      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

      function disp(statustext) {
          runHook("disp", FBEFORE);
          if (o3_allowmove == 0) {
              runHook("placeLayer", FREPLACE);
              (olNs6 && olShowId < 0) ? olShowId = setTimeout("runHook('showObject', FREPLACE, over)", 1) : runHook("showObject", FREPLACE, over);
      Severity: Major
      Found in assets/js/overlib/mini/overlib_mini.js and 1 other location - About 3 hrs to fix
      assets/js/overlib/overlib.js on lines 534..546

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

      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 main.php has 323 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php declare(strict_types=1);
      
      /**
       * Module: SmartFAQ
       * Author: The SmartFactory <www.smartfactory.ca>
      Severity: Minor
      Found in admin/main.php - About 3 hrs to fix

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

        function parseScrollExtras(pf, i, ar) {
            var k = i, v;
            if (k < ar.length) {
                if (ar[k] == FOLLOWSCROLL) {
                    eval(pf + 'followscroll=(' + pf + 'followscroll==0)? 1 : 0');
        Severity: Major
        Found in assets/js/overlib/overlib_followscroll.js and 1 other location - About 3 hrs to fix
        assets/js/overlib/mini/overlib_followscroll_mini.js on lines 20..33

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

        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

        function parseScrollExtras(pf, i, ar) {
            var k = i, v;
            if (k < ar.length) {
                if (ar[k] == FOLLOWSCROLL) {
                    eval(pf + 'followscroll=(' + pf + 'followscroll==0)?1:0');
        Severity: Major
        Found in assets/js/overlib/mini/overlib_followscroll_mini.js and 1 other location - About 3 hrs to fix
        assets/js/overlib/overlib_followscroll.js on lines 53..66

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

        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 Constants::SF_STATUS_NEW_ANSWER:
                        $statustxt = _AM_SF_NEWANSWER;
                        $approve   = "<a href='answer.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/approve.gif' title='" . _AM_SF_FAQ_EDIT . "' alt='" . _AM_SF_FAQ_EDIT . "'></a>&nbsp;";
                        $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/delete.gif' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
                        $modify    = '';
        Severity: Major
        Found in admin/main.php and 1 other location - About 3 hrs to fix
        admin/main.php on lines 348..353

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

        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 Constants::SF_STATUS_SUBMITTED:
                        $statustxt = _AM_SF_SUBMITTED;
                        $approve   = "<a href='faq.php?op=mod&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/approve.gif' title='" . _AM_SF_SUBMISSION_MODERATE . "' alt='" . _AM_SF_SUBMISSION_MODERATE . "'></a>&nbsp;";
                        $delete    = "<a href='faq.php?op=del&amp;faqid=" . $faqsObj[$i]->faqid() . "'><img src='" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/delete.gif' title='" . _AM_SF_DELETEART . "' alt='" . _AM_SF_DELETEART . "'></a>";
                        $modify    = '';
        Severity: Major
        Found in admin/main.php and 1 other location - About 3 hrs to fix
        admin/main.php on lines 360..365

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

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

            public function getFaqsFromSearch($queryarray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0)
            {
                global $xoopsUser;
        
                $ret              = [];
        Severity: Major
        Found in class/FaqHandler.php - About 3 hrs to fix

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

          function setCSSStyleVariables() {
              o3_padunit = ol_padunit;
              o3_heightunit = ol_heightunit;
              o3_widthunit = ol_widthunit;
              o3_textsizeunit = ol_textsizeunit;
          Severity: Major
          Found in assets/js/overlib/mini/overlib_cssstyle_mini.js and 1 other location - About 3 hrs to fix
          assets/js/overlib/overlib_cssstyle.js on lines 74..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 109.

          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

          function setCSSStyleVariables() {
              o3_padunit = ol_padunit;
              o3_heightunit = ol_heightunit;
              o3_widthunit = ol_widthunit;
              o3_textsizeunit = ol_textsizeunit;
          Severity: Major
          Found in assets/js/overlib/overlib_cssstyle.js and 1 other location - About 3 hrs to fix
          assets/js/overlib/mini/overlib_cssstyle_mini.js on lines 42..58

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

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

          function editfaq(string $faqid = ''): void
          {
              global $answerHandler, $xoopsUser, $xoopsConfig, $xoopsDB, $modify, $xoopsModule, $XOOPS_URL, $myts, $pathIcon16;
              /** @var Smartfaq\Helper $helper */
              $helper = Helper::getInstance();
          Severity: Major
          Found in admin/answer.php - About 3 hrs to fix

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

            function compatibleFrame(frameid) {
                if (olNs4 && typeof frameid.document.overDiv == 'undefined') {
                    return false;
                } else if (document.all && typeof frameid.document.all["overDiv"] == 'undefined') {
                    return false;
            Severity: Major
            Found in assets/js/overlib/overlib_crossframe.js and 1 other location - About 3 hrs to fix
            assets/js/overlib/mini/overlib_crossframe_mini.js on lines 34..43

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

            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

            Severity
            Category
            Status
            Source
            Language