mambax7/songlist

View on GitHub

Showing 3,642 of 3,642 total issues

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

            case 'abid':
                if ('albums' !== $op) {
                    $ele = new SelectAlbumForm('', 'filter_' . $field . '', $components['value'], 1, false);
                    $ele->setExtra(
                        'onchange="window.open(\''
Severity: Major
Found in class/Utility.php and 5 other locations - About 3 hrs to fix
class/Utility.php on lines 319..338
class/Utility.php on lines 339..358
class/Utility.php on lines 359..378
class/Utility.php on lines 417..436
class/Utility.php on lines 437..456

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

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 6 locations. Consider refactoring.
Open

            case 'vcid':
                if ('voice' !== $op) {
                    $ele = new SelectVoiceForm('', 'filter_' . $field . '', $components['value'], 1, false);
                    $ele->setExtra(
                        'onchange="window.open(\''
Severity: Major
Found in class/Utility.php and 5 other locations - About 3 hrs to fix
class/Utility.php on lines 319..338
class/Utility.php on lines 359..378
class/Utility.php on lines 397..416
class/Utility.php on lines 417..436
class/Utility.php on lines 437..456

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

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

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

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

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

Refactorings

Further Reading

File permissions.php has 319 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php declare(strict_types=1);
/*
 * 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 authors.
Severity: Minor
Found in admin/permissions.php - About 3 hrs to fix

    Function xoops_module_update_songlist has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    function xoops_module_update_songlist(\XoopsModule $module, $previousVersion = null): bool
    {
        $moduleDirName      = \basename(\dirname(__DIR__));
        $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
    
    
    Severity: Minor
    Found in include/onupdate.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 toArray has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function toArray($extra = false): array
        {
            $ret  = parent::toArray();
            $form = $this->getForm(true);
            foreach ($form as $key => $element) {
    Severity: Minor
    Found in class/Artists.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

    File SongsHandler.php has 307 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php declare(strict_types=1);
    
    namespace XoopsModules\Songlist;
    
    require_once \dirname(__DIR__) . '/include/songlist.object.php';
    Severity: Minor
    Found in class/SongsHandler.php - About 3 hrs to fix

      The class AlbumsHandler has an overall complexity of 56 which is very high. The configured complexity threshold is 50.
      Open

      class AlbumsHandler extends XoopsPersistableObjectHandler
      {
          /**
           * AlbumsHandler constructor.
           * @param \XoopsDatabase $db
      Severity: Minor
      Found in class/AlbumsHandler.php by phpmd

      The class ArtistsHandler has an overall complexity of 55 which is very high. The configured complexity threshold is 50.
      Open

      class ArtistsHandler extends \XoopsPersistableObjectHandler
      {
          /**
           * ArtistsHandler constructor.
           * @param \XoopsDatabase $db
      Severity: Minor
      Found in class/ArtistsHandler.php by phpmd

      The class Blocksadmin has an overall complexity of 81 which is very high. The configured complexity threshold is 50.
      Open

      class Blocksadmin
      {
          /**
           * @var \XoopsMySQLDatabase|null
           */
      Severity: Minor
      Found in class/Common/Blocksadmin.php by phpmd

      The class FormController has an overall complexity of 376 which is very high. The configured complexity threshold is 50.
      Open

      class FormController
      {
          /**
           * Get {@link XoopsThemeForm} for adding/editing fields
           *
      Severity: Minor
      Found in class/Form/FormController.php by phpmd

      The class Field has an overall complexity of 141 which is very high. The configured complexity threshold is 50.
      Open

      class Field extends \XoopsObject
      {
          public $field_id;
          public $cids;
          public $field_type;
      Severity: Minor
      Found in class/Field.php by phpmd

      The class FieldHandler has an overall complexity of 58 which is very high. The configured complexity threshold is 50.
      Open

      class FieldHandler extends \XoopsPersistableObjectHandler
      {
          /**
           * FieldHandler constructor.
           * @param \XoopsDatabase $db
      Severity: Minor
      Found in class/FieldHandler.php by phpmd

      The class ServicesJSON has an overall complexity of 129 which is very high. The configured complexity threshold is 50.
      Open

      class ServicesJSON
      {
          /**
           * constructs a new JSON instance
           *
      Severity: Minor
      Found in class/JSON.php by phpmd

      The class SongsHandler has an overall complexity of 97 which is very high. The configured complexity threshold is 50.
      Open

      class SongsHandler extends \XoopsPersistableObjectHandler
      {
          /**
           * SongsHandler constructor.
           * @param \XoopsDatabase $db
      Severity: Minor
      Found in class/SongsHandler.php by phpmd

      The class Uploader has an overall complexity of 65 which is very high. The configured complexity threshold is 50.
      Open

      class Uploader
      {
          public $mediaName;
          public $mediaType;
          public $mediaSize;
      Severity: Minor
      Found in class/Uploader.php by phpmd

      The class Utility has an overall complexity of 149 which is very high. The configured complexity threshold is 50.
      Open

      class Utility extends Common\SysUtility
      {
          //--------------- Custom module methods -----------------------------
          /**
           * Function responsible for checking if a directory exists, we can also write in and create an index.html file
      Severity: Minor
      Found in class/Utility.php by phpmd

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

                  case 'actiona':
                      if (Request::hasVar('xmlfile', 'SESSION')) {
                          redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $_SESSION['xmlfile'] . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED);
                      }
                      $adminObject = Admin::getInstance();
      Severity: Major
      Found in admin/import.php and 1 other location - About 3 hrs to fix
      admin/export.php on lines 35..45

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

      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

                  case 'actiona':
                      if (Request::hasVar('xmlfile', 'SESSION')) {
                          redirect_header($_SERVER['SCRIPT_NAME'] . '?file=' . $_SESSION['xmlfile'] . '&op=import&fct=actionb', 10, _AM_SONGLIST_XMLFILE_UPLOADED);
                      }
                      $adminObject = Admin::getInstance();
      Severity: Major
      Found in admin/export.php and 1 other location - About 3 hrs to fix
      admin/import.php on lines 29..39

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

      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

      Consider simplifying this complex logical expression.
      Open

                              if (($c == $strlen_chrs) || ((',' === $chrs[$c]) && (SERVICES_JSON_SLICE == $top['what']))) {
                                  // found a comma that is not inside a string, array, etc.,
                                  // OR we've reached the end of the character list
                                  $slice = mb_substr($chrs, $top['where'], $c - $top['where']);
                                  array_push($stk, ['what' => SERVICES_JSON_SLICE, 'where' => $c + 1, 'delim' => false]);
      Severity: Critical
      Found in class/JSON.php - About 3 hrs to fix

        File field.php has 289 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php declare(strict_types=1);
        
        use Xmf\Module\Admin;
        use Xmf\Request;
        use XoopsModules\Songlist\Helper;
        Severity: Minor
        Found in admin/field.php - About 2 hrs to fix
          Severity
          Category
          Status
          Source
          Language