XoopsModules25x/xoopspartners

View on GitHub

Showing 346 of 346 total issues

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

<?php
//
// Support Francophone de Xoops (www.frxoops.org)
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
Severity: Major
Found in language/french/admin.php and 1 other location - About 2 days to fix
language/spanish/admin.php on lines 1..53

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

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

<?php // Xoops Spanish Support (http://www.esxoops.com)
// $Id: admin.php 8212M 2011-11-07 04:37:28Z (local) $
$adminMyDirName = basename(dirname(dirname(__DIR__)));

define('_AM_XOOPSPARTNERS_URL', 'URL');
Severity: Major
Found in language/spanish/admin.php and 1 other location - About 2 days to fix
language/french/admin.php on lines 1..84

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

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 xoops_module_update_xoopspartners has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

function xoops_module_update_xoopspartners(\XoopsModule $module, $previousVersion = null)
{
    $moduleDirName      = basename(dirname(__DIR__));
    $moduleDirNameUpper = mb_strtoupper($moduleDirName);

Severity: Minor
Found in include/onupdate.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

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

} else {
    // nothing in session so request new info
    $hdrs = [];
    $curl = curl_init($serviceUrl);
    curl_setopt_array(
Severity: Major
Found in include/issues.php and 1 other location - About 1 day to fix
include/issues.php on lines 108..135

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

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

    } elseif (preg_match('/^200 OK/', $status)) {
        // ok - request new info
        $hdrs = []; //reset the header array for new curl op
        $curl = curl_init($serviceUrl);
        curl_setopt_array(
Severity: Major
Found in include/issues.php and 1 other location - About 1 day to fix
include/issues.php on lines 160..187

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

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 truncateHtml has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

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

Cognitive Complexity

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

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

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

Further reading

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

$icons = [
    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
Severity: Major
Found in include/common.php and 1 other location - About 6 hrs to fix
config/icons.php on lines 8..18

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

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

    'icons' => [
        'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
        'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
        'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
        'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
Severity: Major
Found in config/icons.php and 1 other location - About 6 hrs to fix
include/common.php on lines 65..75

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

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

function b_xoopspartners_edit($options)
{
    if (0 == $options[0]) { //put spaces between partners
        $chk0no  = ' checked';
        $chk0yes = '';
Severity: Major
Found in blocks/partners.php - About 4 hrs to fix

    File main.php has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

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

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

          public static function checkVerModule($helper, $source = 'github', $default = 'master')
          {
              $moduleDirName      = \basename(\dirname(\dirname(__DIR__)));
              $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 xoops_module_update_xoopspartners has 67 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function xoops_module_update_xoopspartners(\XoopsModule $module, $previousVersion = null)
      {
          $moduleDirName      = basename(dirname(__DIR__));
          $moduleDirNameUpper = mb_strtoupper($moduleDirName);
      
      
      Severity: Major
      Found in include/onupdate.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/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($src)
              {
                  // 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

          Method b_xoopspartners_show has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function b_xoopspartners_show($options)
          {
              $myts = \MyTextSanitizer::getInstance();
          
              $moduleDirName = basename(dirname(__DIR__));
          Severity: Minor
          Found in blocks/partners.php - About 1 hr to fix

            Method checkVerModule has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function checkVerModule($helper, $source = 'github', $default = 'master')
                {
                    $moduleDirName      = \basename(\dirname(\dirname(__DIR__)));
                    $moduleDirNameUpper = mb_strtoupper($moduleDirName);
                    $update             = '';
            Severity: Minor
            Found in class/Common/VersionChecks.php - About 1 hr to fix

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

              function b_xoopspartners_show($options)
              {
                  $myts = \MyTextSanitizer::getInstance();
              
                  $moduleDirName = basename(dirname(__DIR__));
              Severity: Minor
              Found in blocks/partners.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 rrmdir has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function rrmdir($src)
                  {
                      // 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 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 xoops_module_install_xoopspartners has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function xoops_module_install_xoopspartners(\XoopsModule $module)
              {
                  require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
              
                  $moduleDirName = basename(dirname(__DIR__));
              Severity: Minor
              Found in include/oninstall.php - About 1 hr to fix

                Avoid using undefined variables such as '$app' which will lead to PHP notices.
                Open

                    \Xmf\Yaml::save($app, $yamlFile);
                Severity: Minor
                Found in admin/index.php by phpmd

                UndefinedVariable

                Since: 2.8.0

                Detects when a variable is used that has not been defined before.

                Example

                class Foo
                {
                    private function bar()
                    {
                        // $message is undefined
                        echo $message;
                    }
                }

                Source https://phpmd.org/rules/cleancode.html#undefinedvariable

                Severity
                Category
                Status
                Source
                Language