XoopsModules25x/rss

View on GitHub

Showing 101 of 101 total issues

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

    public function delete(\XoopsObject $object, $force = false): bool
    {
        //        $force = false;
        if (mb_strtolower(\get_class($object)) != mb_strtolower($this->objClass)) {
            return false;
Severity: Major
Found in class/MiscHandler.php and 1 other location - About 3 hrs to fix
class/PluginHandler.php on lines 168..184

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

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function grabEntries has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
    {
        $ret  = null;

        $i        = -1;
Severity: Minor
Found in class/Plugins/Surnames.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 getChannel has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function getChannel(array &$feed): void
    {
        $channel  = [];
        $elements = $this->miscHandler->getObjects2(new \Criteria('misc_category', 'channel'));
        if (\is_array($elements) && !empty($elements)) {
Severity: Minor
Found in class/FeedHandler.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 checkPlugin has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function checkPlugin(\XoopsObject $object)
    {
        $ret = null;
        $file = \RSSFIT_ROOT_PATH . 'class/Plugins/' . $object->getVar('rssf_filename');
        if (\is_file($file)) {
Severity: Minor
Found in class/PluginHandler.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 getRssFeedAsHtml has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getRssFeedAsHtml(string $feed_url, int $maxItemCount = 10, bool $show_date = true, bool $show_description = true, int $max_words = 0, int $cache_timeout = 7200, string $cache_prefix = XOOPS_VAR_PATH . '/caches/xoops_cache/rss2html-'): string
    {
        $result = '';
        // get feeds and parse items
        $rss       = new \DOMDocument();
Severity: Major
Found in class/Utility.php - About 2 hrs to fix

    Function checkVerModule has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function checkVerModule(Helper $helper, ?string $source = 'github', ?string $default = 'master'): ?array
        {
            $moduleDirName      = \basename(\dirname(__DIR__, 2));
            $moduleDirNameUpper = mb_strtoupper($moduleDirName);
            $update             = '';
    Severity: Minor
    Found in class/Common/VersionChecks.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 truncateHtml has 63 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function truncateHtml(
            string $text,
            ?int $length = 100,
            string $ending = '...',
            bool $exact = false,
    Severity: Major
    Found in class/Common/SysUtility.php - About 2 hrs to fix

      Function deleteDirectory has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function deleteDirectory(string $src): bool
          {
              // Only continue if user is a 'global' Admin
              if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
                  return false;
      Severity: Minor
      Found in class/Common/FilesManagement.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 insert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function insert(\XoopsObject $object, $force = false)
          {
              //        $force = false;
              if (mb_strtolower(\get_class($object)) != mb_strtolower($this->objClass)) {
                  return false;
      Severity: Minor
      Found in class/MiscHandler.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 insert has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          public function insert(\XoopsObject $object, $force = true)
          {
              if (mb_strtolower(\get_class($object)) != mb_strtolower($this->objClass)) {
                  return false;
              }
      Severity: Minor
      Found in class/PluginHandler.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 xoops_module_update_rssfit has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function xoops_module_update_rssfit(\XoopsModule $module, int $previousVersion): bool
      {
          $moduleDirName      = \basename(\dirname(__DIR__));
      
          /** @var Rssfit\Helper $helper */
      Severity: Major
      Found in include/onupdate.php - About 2 hrs to fix

        Function doSubstr has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function doSubstr(string $text): string
            {
                $ret      = $text;
                $len      = \function_exists('mb_strlen') ? mb_strlen($ret, $this->charset) : mb_strlen($ret);
                $maxChars = $this->helper->getConfig('max_char');
        Severity: Minor
        Found in class/FeedHandler.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

        File PluginHandler.php has 253 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        
        declare(strict_types=1);
        
        namespace XoopsModules\Rssfit;
        Severity: Minor
        Found in class/PluginHandler.php - About 2 hrs to fix

          Method getChannel has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getChannel(array &$feed): void
              {
                  $channel  = [];
                  $elements = $this->miscHandler->getObjects2(new \Criteria('misc_category', 'channel'));
                  if (\is_array($elements) && !empty($elements)) {
          Severity: Minor
          Found in class/FeedHandler.php - About 1 hr to fix

            Function getObjects2 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getObjects2($criteria = null, string $fields = '*', string $key = ''): ?array
                {
                    $ret   = null;
                    $limit = $start = 0;
                    switch ($fields) {
            Severity: Minor
            Found in class/PluginHandler.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 getItems has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getItems(array &$feed): void
                {
                    $entries = [];
                    $db      = \XoopsDatabaseFactory::getDatabaseConnection();
                    if (!empty($feed['plugin'])) {
            Severity: Minor
            Found in class/FeedHandler.php - About 1 hr to fix

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

                  public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
                  {
                      $ret  = null;
              
                      $i        = -1;
              Severity: Minor
              Found in class/Plugins/Surnames.php - About 1 hr to fix

                Method insert has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function insert(\XoopsObject $object, $force = true)
                    {
                        if (mb_strtolower(\get_class($object)) != mb_strtolower($this->objClass)) {
                            return false;
                        }
                Severity: Minor
                Found in class/PluginHandler.php - About 1 hr to fix

                  Method insert has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function insert(\XoopsObject $object, $force = false)
                      {
                          //        $force = false;
                          if (mb_strtolower(\get_class($object)) != mb_strtolower($this->objClass)) {
                              return false;
                  Severity: Minor
                  Found in class/MiscHandler.php - About 1 hr to fix

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

                        public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array
                        {
                            $myts = \MyTextSanitizer::getInstance();
                            $ret  = null;
                    
                    
                    Severity: Minor
                    Found in class/Plugins/legacy/Queries.php - About 1 hr to fix

                    Cognitive Complexity

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

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

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

                    Further reading

                    Severity
                    Category
                    Status
                    Source
                    Language