mambax7/smartpartner

View on GitHub

Showing 2,297 of 2,297 total issues

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

    public function fetchMedia($media_name, $index = null)
    {
        global $_FILES;

        if (!isset($_FILES[$media_name])) {
Severity: Minor
Found in class/Uploader.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 getRedirectMsg has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    public function getRedirectMsg($original_status, $new_status)
    {
        $redirect_msgs = [];

        switch ($original_status) {
Severity: Minor
Found in class/Partner.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 deleteDirectory has a Cognitive Complexity of 22 (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 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

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

    public function updateAll($fieldname, $fieldvalue, \CriteriaElement $criteria = null, $force = false)
    {
        $set_clause = is_numeric($fieldvalue) ? $fieldname . ' = ' . $fieldvalue : $fieldname . ' = ' . $this->db->quoteString($fieldvalue);
        $sql        = 'UPDATE ' . $this->db->prefix('smartpartner_partner') . ' SET ' . $set_clause;
        if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
Severity: Major
Found in class/PartnerHandler.php and 1 other location - About 3 hrs to fix
class/FileHandler.php on lines 337..350

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

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

    public function updateAll($fieldname, $fieldvalue, $criteria = null)
    {
        $set_clause = is_numeric($fieldvalue) ? $fieldname . ' = ' . $fieldvalue : $fieldname . ' = ' . $this->db->quoteString($fieldvalue);
        $sql        = 'UPDATE ' . $this->db->prefix('smartpartner_files') . ' SET ' . $set_clause;
        if (null !== $criteria && is_subclass_of($criteria, 'CriteriaElement')) {
Severity: Major
Found in class/FileHandler.php and 1 other location - About 3 hrs to fix
class/PartnerHandler.php on lines 585..597

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

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 category.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 *
 * Module: SmarttPartner
Severity: Minor
Found in admin/category.php - About 3 hrs to fix

    File PersistableObjectHandler.php has 294 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php namespace XoopsModules\Smartpartner;
    /*
     * 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 class/PersistableObjectHandler.php - About 3 hrs to fix

      Method fetchMedia has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fetchMedia($media_name, $index = null)
          {
              global $_FILES;
      
              if (!isset($_FILES[$media_name])) {
      Severity: Major
      Found in class/Uploader.php - About 2 hrs to fix

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

            public function makeMySelBox(
                $title,
                $order = '',
                $preset_id = 0,
                $none = 0,
        Severity: Minor
        Found in class/SmartTree.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 getRedirectMsg has 72 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getRedirectMsg($original_status, $new_status)
            {
                $redirect_msgs = [];
        
                switch ($original_status) {
        Severity: Major
        Found in class/Partner.php - About 2 hrs to fix

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

              public function insert(\XoopsObject $obj, $force = false, $checkObject = true)
              {
                  if (false !== $checkObject) {
                      if (!is_object($obj)) {
                          return false;
          Severity: Major
          Found in class/PersistableObjectHandler.php - About 2 hrs to fix

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

                        case _SPARTNER_STATUS_ACTIVE:
                            $statustxt = _AM_SPARTNER_ACTIVE;
                            $approve   = '';
                            $modify    = "<a href='partner.php?op=mod&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SPARTNER_PARTNER_EDIT . "' alt='" . _AM_SPARTNER_PARTNER_EDIT . "'></a>&nbsp;";
                            $delete    = "<a href='partner.php?op=del&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/delete.png' . "'  title='" . _AM_SPARTNER_PARTNER_DELETE . "' alt='" . _AM_SPARTNER_PARTNER_DELETE . "'></a>&nbsp;";
            Severity: Major
            Found in admin/main.php and 2 other locations - About 2 hrs to fix
            admin/main.php on lines 299..304
            admin/main.php on lines 306..311

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

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

                        case _SPARTNER_STATUS_REJECTED:
                            $statustxt = _AM_SPARTNER_REJECTED;
                            $approve   = '';
                            $modify    = "<a href='partner.php?op=mod&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SPARTNER_PARTNER_EDIT . "' alt='" . _AM_SPARTNER_PARTNER_EDIT . "'></a>&nbsp;";
                            $delete    = "<a href='partner.php?op=del&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/delete.png' . "'  title='" . _AM_SPARTNER_PARTNER_DELETE . "' alt='" . _AM_SPARTNER_PARTNER_DELETE . "'></a>&nbsp;";
            Severity: Major
            Found in admin/main.php and 2 other locations - About 2 hrs to fix
            admin/main.php on lines 292..297
            admin/main.php on lines 299..304

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

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

                        case _SPARTNER_STATUS_INACTIVE:
                            $statustxt = _AM_SPARTNER_INACTIVE;
                            $approve   = '';
                            $modify    = "<a href='partner.php?op=mod&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SPARTNER_PARTNER_EDIT . "' alt='" . _AM_SPARTNER_PARTNER_EDIT . "'></a>&nbsp;";
                            $delete    = "<a href='partner.php?op=del&id=" . $partnersObj[$i]->id() . "'><img src='" . $pathIcon16 . '/delete.png' . "'  title='" . _AM_SPARTNER_PARTNER_DELETE . "' alt='" . _AM_SPARTNER_PARTNER_DELETE . "'></a>&nbsp;";
            Severity: Major
            Found in admin/main.php and 2 other locations - About 2 hrs to fix
            admin/main.php on lines 292..297
            admin/main.php on lines 306..311

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

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

                public function convertResultSet($result, $id_as_key = false, $as_object = true)
                {
                    $ret = [];
                    while (false !== ($myrow = $this->db->fetchArray($result))) {
                        $obj = $this->create(false);
            Severity: Minor
            Found in class/PersistableObjectHandler.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 editpartner has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            function editpartner($showmenu = false, $id = 0)
            {
                global $xoopsDB, $partnerHandler, $xoopsUser, $xoopsConfig,  $xoopsModule;
                /** @var Smartpartner\Helper $helper */
                $helper = Smartpartner\Helper::getInstance();
            Severity: Minor
            Found in admin/partner.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 getUrlLink has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getUrlLink($forWhere)
                {
                    if ('block' === $forWhere) {
                        if ($this->extentedInfo()) {
                            return '<a href="' . SMARTPARTNER_URL . 'partner.php?id=' . $this->id() . '">';
            Severity: Minor
            Found in class/Partner.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 getObjectsForUserSide has 67 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getObjectsForUserSide()
                {
                    global  $categoryHandler, $partnerHandler, $xoopsUser;
                    /** @var Smartpartner\Helper $helper */
                    $helper = Smartpartner\Helper::getInstance();
            Severity: Major
            Found in class/OfferHandler.php - About 2 hrs to fix

              File has 24 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class File extends \XoopsObject
              {
                  /**
                   * constructor
                   * @param null $id
              Severity: Minor
              Found in class/File.php - About 2 hrs to fix

                Method myblocksadmin_update_block has 65 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function myblocksadmin_update_block(
                    $bid,
                    $bside,
                    $bweight,
                    $bvisible,
                Severity: Major
                Found in include/blocksadmin.inc.php - About 2 hrs to fix
                  Severity
                  Category
                  Status
                  Source
                  Language