XoopsModules25x/wfdownloads

View on GitHub
class/Utility.php

Summary

Maintainability
F
2 wks
Test Coverage

File Utility.php has 1363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace XoopsModules\Wfdownloads;

/*
Severity: Major
Found in class/Utility.php - About 3 days to fix

    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/Utility.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

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

    class Utility extends Common\SysUtility
    {
        //--------------- Custom module methods -----------------------------
        /**
         * @param     $categoryObj
    Severity: Major
    Found in class/Utility.php - About 1 day to fix

      Function displayIcons has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function displayIcons($time, $status = \_WFDOWNLOADS_STATUS_WAITING, $counter = 0)
          {
              $helper = Helper::getInstance();
      
              $new     = '';
      Severity: Minor
      Found in class/Utility.php - About 5 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 getDownloadTime has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
          {
              $aflag  = [];
              $amtime = [];
              $artime = [];
      Severity: Minor
      Found in class/Utility.php - About 5 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 editCategory has 109 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
          {
              $helper = Helper::getInstance();
      
              // if there is a parameter, and the id exists, retrieve data: we're editing a category
      Severity: Major
      Found in class/Utility.php - About 4 hrs to fix

        Function createThumb has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
            {
                $helper = Helper::getInstance();
        
                // Paths
        Severity: Minor
        Found in class/Utility.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

        Function editCategory has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function editCategory($showmenu = false, $categoryId = 0, $nbSubCats = 4, $categoryObj = null)
            {
                $helper = Helper::getInstance();
        
                // if there is a parameter, and the id exists, retrieve data: we're editing a category
        Severity: Minor
        Found in class/Utility.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

        Function largeDownload has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

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

            public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
            {
                $helper = Helper::getInstance();
        
                // Paths
        Severity: Major
        Found in class/Utility.php - About 2 hrs to fix

          Function uploading has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function uploading(
                  $filename,
                  $uploadDirectory = 'uploads',
                  $allowedMimetypes = [],
                  $redirectURL = 'index.php',
          Severity: Minor
          Found in class/Utility.php - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Function copyDir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function copyDir($source, $destination)
              {
                  if (!$dirHandler = \opendir($source)) {
                      return false;
                  }
          Severity: Minor
          Found in class/Utility.php - About 2 hrs to fix

          Cognitive Complexity

          Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

          A method's cognitive complexity is based on a few simple rules:

          • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
          • Code is considered more complex for each "break in the linear flow of the code"
          • Code is considered more complex when "flow breaking structures are nested"

          Further reading

          Method searchSwishe has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function searchSwishe($swisheQueryWords)
              {
                  /**
                   * @param $str
                   * @param $num_chars
          Severity: Major
          Found in class/Utility.php - About 2 hrs to fix

            Method truncateHtml has 63 lines of code (exceeds 25 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: Major
            Found in class/Utility.php - About 2 hrs to fix

              Method largeDownload has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function searchSwishe has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function searchSwishe($swisheQueryWords)
                    {
                        /**
                         * @param $str
                         * @param $num_chars
                Severity: Minor
                Found in class/Utility.php - About 2 hrs to fix

                Cognitive Complexity

                Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                A method's cognitive complexity is based on a few simple rules:

                • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                • Code is considered more complex for each "break in the linear flow of the code"
                • Code is considered more complex when "flow breaking structures are nested"

                Further reading

                Method uploading has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function uploading(
                        $filename,
                        $uploadDirectory = 'uploads',
                        $allowedMimetypes = [],
                        $redirectURL = 'index.php',
                Severity: Minor
                Found in class/Utility.php - About 1 hr to fix

                  Method getDownloadTime has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
                      {
                          $aflag  = [];
                          $amtime = [];
                          $artime = [];
                  Severity: Minor
                  Found in class/Utility.php - About 1 hr to fix

                    Function delDir has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function delDir($dir, $if_not_empty = true)
                        {
                            if (!\file_exists($dir)) {
                                return true;
                            }
                    Severity: Minor
                    Found in class/Utility.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 convertHtml2text has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public static function convertHtml2text($document)
                        {
                            $search = [
                                "'<script[^>]*?>.*?</script>'si", // Strip out javascript
                                "'<img.*?>'si", // Strip out img tags
                    Severity: Minor
                    Found in class/Utility.php - About 1 hr to fix

                      Method convertorderbyin has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function convertorderbyin($orderby)
                          {
                              switch (\trim($orderby)) {
                                  case 'titleA':
                                      $orderby = 'title ASC';
                      Severity: Minor
                      Found in class/Utility.php - About 1 hr to fix

                        Method displayIcons has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public static function displayIcons($time, $status = \_WFDOWNLOADS_STATUS_WAITING, $counter = 0)
                            {
                                $helper = Helper::getInstance();
                        
                                $new     = '';
                        Severity: Minor
                        Found in class/Utility.php - About 1 hr to fix

                          Function convertorderbyin has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function convertorderbyin($orderby)
                              {
                                  switch (\trim($orderby)) {
                                      case 'titleA':
                                          $orderby = 'title ASC';
                          Severity: Minor
                          Found in class/Utility.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 convertOrderByTrans has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public static function convertOrderByTrans($orderby)
                              {
                                  $orderbyTrans = '';
                                  if ('title ASC' === $orderby) {
                                      $orderbyTrans = \_MD_WFDOWNLOADS_TITLEATOZ;
                          Severity: Minor
                          Found in class/Utility.php - About 1 hr to fix

                            Method isNewImage has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public static function isNewImage($published)
                                {
                                    if ($published <= 0) {
                                        $indicator['image']   = 'assets/images/icon/download.gif';
                                        $indicator['alttext'] = \_MD_WFDOWNLOADS_NO_FILES;
                            Severity: Minor
                            Found in class/Utility.php - About 1 hr to fix

                              Method lettersChoice has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public static function lettersChoice()
                                  {
                                      $helper = Helper::getInstance();
                              
                                      $criteria = $helper->getHandler('Download')->getActiveCriteria();
                              Severity: Minor
                              Found in class/Utility.php - About 1 hr to fix

                                Method convertorderbyout has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public static function convertorderbyout($orderby)
                                    {
                                        if ('title ASC' === $orderby) {
                                            $orderby = 'titleA';
                                        }
                                Severity: Minor
                                Found in class/Utility.php - About 1 hr to fix

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

                                      public static function toolbar()
                                      {
                                          $helper = Helper::getInstance();
                                  
                                          $isSubmissionAllowed = false;
                                  Severity: Minor
                                  Found in class/Utility.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 convertOrderByTrans has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public static function convertOrderByTrans($orderby)
                                      {
                                          $orderbyTrans = '';
                                          if ('title ASC' === $orderby) {
                                              $orderbyTrans = \_MD_WFDOWNLOADS_TITLEATOZ;
                                  Severity: Minor
                                  Found in class/Utility.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 convertorderbyout has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                      public static function convertorderbyout($orderby)
                                      {
                                          if ('title ASC' === $orderby) {
                                              $orderby = 'titleA';
                                          }
                                  Severity: Minor
                                  Found in class/Utility.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 displayCategory has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      public static function displayCategory(Wfdownloads\Category $categoryObj, $level = 0)
                                      {
                                          $helper = Helper::getInstance();
                                  
                                          $description = $categoryObj->description();
                                  Severity: Minor
                                  Found in class/Utility.php - About 1 hr to fix

                                    Method toolbar has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        public static function toolbar()
                                        {
                                            $helper = Helper::getInstance();
                                    
                                            $isSubmissionAllowed = false;
                                    Severity: Minor
                                    Found in class/Utility.php - About 1 hr to fix

                                      Method createThumb has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          public static function createThumb($imgName, $imgPath, $imgSavePath, $width = 100, $height = 100, $quality = 100, $update = false, $aspect = 1)
                                      Severity: Major
                                      Found in class/Utility.php - About 1 hr to fix

                                        Method uploading has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                        Open

                                                $filename,
                                                $uploadDirectory = 'uploads',
                                                $allowedMimetypes = [],
                                                $redirectURL = 'index.php',
                                                $num = 0,
                                        Severity: Major
                                        Found in class/Utility.php - About 1 hr to fix

                                          Method getDownloadTime has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                          Open

                                              public static function getDownloadTime($size = 0, $gmodem = 1, $gisdn = 1, $gdsl = 1, $gslan = 0, $gflan = 0)
                                          Severity: Minor
                                          Found in class/Utility.php - About 45 mins to fix

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

                                                public static function 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 class/Utility.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

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

                                                public static function displayImage($image = '', $href = '', $imgSource = '', $altText = '')
                                                {
                                                    $helper = Helper::getInstance();
                                            
                                                    $showImage = '';
                                            Severity: Minor
                                            Found in class/Utility.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 truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
                                            Severity: Minor
                                            Found in class/Utility.php - About 35 mins to fix

                                              Function getFiles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function getFiles($path = '.')
                                                  {
                                                      $files = [];
                                                      $dir   = \opendir($path);
                                                      while (false !== ($file = \readdir($dir))) {
                                              Severity: Minor
                                              Found in class/Utility.php - About 35 mins to fix

                                              Cognitive Complexity

                                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                              A method's cognitive complexity is based on a few simple rules:

                                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                              • Code is considered more complex for each "break in the linear flow of the code"
                                              • Code is considered more complex when "flow breaking structures are nested"

                                              Further reading

                                              Function getDir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function getDir($path = '.', $level = 0)
                                                  {
                                                      $ret    = [];
                                                      $ignore = ['cgi-bin', '.', '..'];
                                                      // Directories to ignore when listing output. Many hosts will deny PHP access to the cgi-bin.
                                              Severity: Minor
                                              Found in class/Utility.php - About 35 mins to fix

                                              Cognitive Complexity

                                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                              A method's cognitive complexity is based on a few simple rules:

                                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                              • Code is considered more complex for each "break in the linear flow of the code"
                                              • Code is considered more complex when "flow breaking structures are nested"

                                              Further reading

                                              Function displayCategory has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function displayCategory(Wfdownloads\Category $categoryObj, $level = 0)
                                                  {
                                                      $helper = Helper::getInstance();
                                              
                                                      $description = $categoryObj->description();
                                              Severity: Minor
                                              Found in class/Utility.php - About 35 mins to fix

                                              Cognitive Complexity

                                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                              A method's cognitive complexity is based on a few simple rules:

                                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                              • Code is considered more complex for each "break in the linear flow of the code"
                                              • Code is considered more complex when "flow breaking structures are nested"

                                              Further reading

                                              Function makeDir has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function makeDir($dir, $perm = 0777, $create_index = true)
                                                  {
                                                      if (!\mkdir($dir, $perm) && !\is_dir($dir)) {
                                                          throw new \RuntimeException('The directory ' . $dir . ' could not be created.');
                                                      }
                                              Severity: Minor
                                              Found in class/Utility.php - About 35 mins to fix

                                              Cognitive Complexity

                                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                              A method's cognitive complexity is based on a few simple rules:

                                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                              • Code is considered more complex for each "break in the linear flow of the code"
                                              • Code is considered more complex when "flow breaking structures are nested"

                                              Further reading

                                              Function isNewImage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                              Open

                                                  public static function isNewImage($published)
                                                  {
                                                      if ($published <= 0) {
                                                          $indicator['image']   = 'assets/images/icon/download.gif';
                                                          $indicator['alttext'] = \_MD_WFDOWNLOADS_NO_FILES;
                                              Severity: Minor
                                              Found in class/Utility.php - About 35 mins to fix

                                              Cognitive Complexity

                                              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                                              A method's cognitive complexity is based on a few simple rules:

                                              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                                              • Code is considered more complex for each "break in the linear flow of the code"
                                              • Code is considered more complex when "flow breaking structures are nested"

                                              Further reading

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

                                                  public static function sortCategories($pid = 0, $level = 0)
                                                  {
                                                      $helper = Helper::getInstance();
                                              
                                                      $sorted   = [];
                                              Severity: Minor
                                              Found in class/Utility.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

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

                                                  public static function sizeToBytes1024($size)
                                                  {
                                                      $l   = mb_substr($size, -1);
                                                      $ret = mb_substr($size, 0, -1);
                                                      switch (mb_strtoupper($l)) {
                                              Severity: Minor
                                              Found in class/Utility.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

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

                                                  public static function lettersChoice()
                                                  {
                                                      $helper = Helper::getInstance();
                                              
                                                      $criteria = $helper->getHandler('Download')->getActiveCriteria();
                                              Severity: Minor
                                              Found in class/Utility.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

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

                                                  public static function generateSeoUrl($op, $id, $title = '')
                                                  {
                                                      if (\defined('SEO_ENABLED')) {
                                                          if (SEO_ENABLED === 'rewrite') {
                                                              // generate SEO url using htaccess
                                              Severity: Minor
                                              Found in class/Utility.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

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

                                                      if ($considerHtml) {
                                                          // if the plain text is shorter than the maximum length, return the whole text
                                                          if (mb_strlen(\preg_replace('/<.*?' . '>/', '', $text)) <= $length) {
                                                              return $text;
                                                          }
                                              Severity: Major
                                              Found in class/Utility.php and 1 other location - About 2 days to fix
                                              class/Common/SysUtility.php on lines 63..130

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

                                              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

                                                  public static function cloneRecord($tableName, $id_field, $id)
                                                  {
                                                      $new_id = false;
                                                      $table  = $GLOBALS['xoopsDB']->prefix($tableName);
                                                      // copy content of the record you wish to clone
                                              Severity: Major
                                              Found in class/Utility.php and 1 other location - About 5 hrs to fix
                                              class/Common/SysUtility.php on lines 212..228

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

                                              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