mambax7/xnewsletter

View on GitHub
include/functions.php

Summary

Maintainability
F
1 wk
Test Coverage

Function xnewsletter_setPost has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

function xnewsletter_setPost($contentObj, $sets)
{
    if (!is_object($contentObj)) {
        return false;
    }
Severity: Minor
Found in include/functions.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 functions.php has 540 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * ****************************************************************************
 *  - A Project by Developers TEAM For Xoops - ( https://xoops.org )
 * ****************************************************************************
Severity: Major
Found in include/functions.php - About 1 day to fix

    Method xnewsletter_emailSize has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function xnewsletter_emailSize($letter_id = 0)
    {
    //    require_once XNEWSLETTER_ROOT_PATH . '/class/class.xnewslettermailer.php';
        global $XoopsTpl;
        $helper = Xnewsletter\Helper::getInstance();
    Severity: Major
    Found in include/functions.php - About 5 hrs to fix

      Function xnewsletter_emailSize has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

      function xnewsletter_emailSize($letter_id = 0)
      {
      //    require_once XNEWSLETTER_ROOT_PATH . '/class/class.xnewslettermailer.php';
          global $XoopsTpl;
          $helper = Xnewsletter\Helper::getInstance();
      Severity: Minor
      Found in include/functions.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

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

      function xnewsletter_getUserPermissionsByLetter($letter_id = 0)
      {
          global $xoopsUser;
          /** @var \XoopsGroupPermHandler $grouppermHandler */
          $grouppermHandler = xoops_getHandler('groupperm');
      Severity: Minor
      Found in include/functions.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 xnewsletter_setPost has 86 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function xnewsletter_setPost($contentObj, $sets)
      {
          if (!is_object($contentObj)) {
              return false;
          }
      Severity: Major
      Found in include/functions.php - About 3 hrs to fix

        Function xnewsletter_largeDownload has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

        function xnewsletter_largeDownload($filePath, $fileMimetype)
        {
            /* You may need these ini settings too */
            set_time_limit(0);
            ini_set('memory_limit', '512M');
        Severity: Minor
        Found in include/functions.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 xnewsletter_largeDownload has 61 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function xnewsletter_largeDownload($filePath, $fileMimetype)
        {
            /* You may need these ini settings too */
            set_time_limit(0);
            ini_set('memory_limit', '512M');
        Severity: Major
        Found in include/functions.php - About 2 hrs to fix

          Method xnewsletter_getUserPermissionsByLetter has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function xnewsletter_getUserPermissionsByLetter($letter_id = 0)
          {
              global $xoopsUser;
              /** @var \XoopsGroupPermHandler $grouppermHandler */
              $grouppermHandler = xoops_getHandler('groupperm');
          Severity: Major
          Found in include/functions.php - About 2 hrs to fix

            Function xnewsletter_CleanVars has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function xnewsletter_CleanVars($global, $key, $default = '', $type = 'int', $notset = false)
            {
                require_once XOOPS_ROOT_PATH . '/include/functions.php';
                switch ($type) {
                    case 'string':
            Severity: Minor
            Found in 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

            Method xnewsletter_CleanVars has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function xnewsletter_CleanVars($global, $key, $default = '', $type = 'int', $notset = false)
            {
                require_once XOOPS_ROOT_PATH . '/include/functions.php';
                switch ($type) {
                    case 'string':
            Severity: Minor
            Found in include/functions.php - About 1 hr to fix

              Function xnewsletter_download has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              function xnewsletter_download($filePath, $isBinary = true, $retBytes = true)
              {
                  // how many bytes per chunk
                  //$chunkSize = 1 * (1024 * 1024);
                  $chunkSize    = 8 * (1024 * 1024); //8MB (highest possible fread length)
              Severity: Minor
              Found in 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

              Method xnewsletter_CleanVars has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              function xnewsletter_CleanVars($global, $key, $default = '', $type = 'int', $notset = false)
              Severity: Minor
              Found in include/functions.php - About 35 mins to fix

                Avoid too many return statements within this method.
                Open

                    return $mail->getSize();
                Severity: Major
                Found in include/functions.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return false;
                  Severity: Major
                  Found in include/functions.php - About 30 mins to fix

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

                    function xnewsletter_userAllowedCreateCat($cat_id = 0)
                    {
                        global $xoopsUser;
                        $grouppermHandler = xoops_getHandler('groupperm');
                        $memberHandler    = xoops_getHandler('member');
                    Severity: Minor
                    Found in 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

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

                            if (_XNEWSLETTER_ACCOUNTS_TYPE_VAL_SMTP == $contentObj->getVar('accounts_type')) {
                                if ($contentObj->isNew()) {
                                    if (_AM_XNEWSLETTER_ACCOUNTS_TYPE_SMTP_SERVER_IN == @$set['accounts_server_in']) {
                                        $sets['accounts_server_in'] = null;
                                    }
                    Severity: Major
                    Found in include/functions.php and 1 other location - About 1 day to fix
                    include/functions.php on lines 250..271

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

                    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

                            } else {
                                if ($contentObj->isNew()) {
                                    if (_AM_XNEWSLETTER_ACCOUNTS_TYPE_POP3_SERVER_IN == @$set['accounts_server_in']) {
                                        $sets['accounts_server_in'] = null;
                                    }
                    Severity: Major
                    Found in include/functions.php and 1 other location - About 1 day to fix
                    include/functions.php on lines 208..271

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

                    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

                    There are no issues that match your filters.

                    Category
                    Status