mambax7/publisher

View on GitHub

Showing 3,032 of 3,032 total issues

The class Utility has 36 non-getter- and setter-methods. Consider refactoring Utility to keep number of methods under 25.
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

TooManyMethods

Since: 0.1

A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

The default was changed from 10 to 25 in PHPMD 2.3.

Example

Source https://phpmd.org/rules/codesize.html#toomanymethods

The class Utility has an overall complexity of 196 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

The class Utility has 36 public methods. Consider refactoring Utility to keep number of public methods under 10.
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

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

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

class VoteHandler extends \XoopsPersistableObjectHandler
{
    private const TABLE      = 'publisher_rating';
    private const ENTITY     = Vote::class;
    private const ENTITYNAME = 'Vote';
Severity: Minor
Found in class/VoteHandler.php by phpmd

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

        if (Request::getString('deleteMimes', '', 'POST')) {
            $aMimes = Request::getArray('mimes', [], 'POST');

            $crit = new \Criteria('mime_id', '(' . \implode(',', $aMimes) . ')', 'IN');

Severity: Major
Found in class/MimetypesUtility.php and 1 other location - About 3 hrs to fix
class/MimetypesUtility.php on lines 355..365

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

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

        if (Request::getString('deleteMimes', '', 'POST')) {
            $aMimes = Request::getArray('mimes', [], 'POST');

            $crit = new \Criteria('mime_id', '(' . \implode(',', $aMimes) . ')', 'IN');

Severity: Major
Found in class/MimetypesUtility.php and 1 other location - About 3 hrs to fix
class/MimetypesUtility.php on lines 500..510

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

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

function xoops_module_update_publisher(\XoopsModule $module, ?string $previousVersion = null)
{
    //    global $GLOBALS['xoopsDB'];
    $moduleDirName = \basename(\dirname(__DIR__));
    //    $moduleDirNameUpper = \mb_strtoupper($moduleDirName);
Severity: Major
Found in include/onupdate.php - About 3 hrs to fix

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

    function publisher_search($queryArray, $andor, $limit, $offset, $userid, $categories = [], $sortby = 0, $searchin = '', $extra = '')
    {
        $helper        = Helper::getInstance();
        $ret           = $item = [];
        $hightlightKey = '';
    Severity: Minor
    Found in include/search.inc.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 search has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function search($icons): void
        {
            $helper = Helper::getInstance();
            /** @var MimetypeHandler $mimetypeHandler */
            $mimetypeHandler = $helper->getHandler('Mimetype');
    Severity: Minor
    Found in class/MimetypesUtility.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 getItemsFromSearch has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = [], $sortby = 0, $searchin = '', $extra = '')
        {
            $count            = 0;
            $ret              = [];
            $criteriaKeywords = $criteriaPermissions = $criteriaUser = null;
    Severity: Minor
    Found in class/ItemHandler.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

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

                    for ($j = 0; $j < $opcount; ++$j) {
                        $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
                        $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
                        $ele->addOption($optval, $optkey);
                    }
    Severity: Major
    Found in admin/preferences.php and 1 other location - About 3 hrs to fix
    admin/preferences.php on lines 125..129

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

    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

                    for ($j = 0; $j < $opcount; ++$j) {
                        $optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
                        $optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
                        $ele->addOption($optval, $optkey);
                    }
    Severity: Major
    Found in admin/preferences.php and 1 other location - About 3 hrs to fix
    admin/preferences.php on lines 135..139

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

    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

            } else {
                this.navigatorInner.height(this.slides.length * this.settings.navigatorHeight);
    
                this.navigatorOuter.height(this.settings.maxItemDisplay * this.settings.navigatorHeight);
                this.navigatorOuter.width(this.settings.navigatorWidth);
    Severity: Major
    Found in assets/js/script.easing.js and 1 other location - About 3 hrs to fix
    assets/js/script.easing.js on lines 115..120

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

    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

            if (this.settings.navPosition == 'horizontal') {
                this.navigatorInner.width(this.slides.length * this.settings.navigatorWidth);
                this.navigatorOuter.width(this.settings.maxItemDisplay * this.settings.navigatorWidth);
                this.navigatorOuter.height(this.settings.navigatorHeight);
    
    
    Severity: Major
    Found in assets/js/script.easing.js and 1 other location - About 3 hrs to fix
    assets/js/script.easing.js on lines 120..125

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

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

        public function getItemsFromSearch($queryArray = [], $andor = 'AND', $limit = 0, $offset = 0, $userid = 0, $categories = [], $sortby = 0, $searchin = '', $extra = '')
        {
            $count            = 0;
            $ret              = [];
            $criteriaKeywords = $criteriaPermissions = $criteriaUser = null;
    Severity: Major
    Found in class/ItemHandler.php - About 3 hrs to fix

      Consider simplifying this complex logical expression.
      Open

          if (document.documentElement.getBoundingClientRect) {
              // Get Offset using getBoundingClientRect
              // http://ejohn.org/blog/getboundingclientrect-is-awesome/
              var getOffset = function (el) {
                  var box = el.getBoundingClientRect();
      Severity: Critical
      Found in assets/js/ajaxupload.3.9.js - About 3 hrs to fix

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

            switch ($helper->getConfig('format_order_by')) {
                case 'title':
                    $sort  = 'title';
                    $order = 'ASC';
                    break;
        Severity: Major
        Found in index.php and 2 other locations - About 2 hrs to fix
        category.php on lines 81..110
        item.php on lines 104..133

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

        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

        switch ($helper->getConfig('format_order_by')) {
            case 'title':
                $sort  = 'title';
                $order = 'ASC';
                break;
        Severity: Major
        Found in item.php and 2 other locations - About 2 hrs to fix
        category.php on lines 81..110
        index.php on lines 151..180

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

        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

        switch ($helper->getConfig('format_order_by')) {
            case 'title':
                $sort  = 'title';
                $order = 'ASC';
                break;
        Severity: Major
        Found in category.php and 2 other locations - About 2 hrs to fix
        index.php on lines 151..180
        item.php on lines 104..133

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

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

            protected function getLocalImagePath($src)
            {
                $src = ltrim($src, '/'); //strip off the leading '/'
                if (!$this->docRoot) {
                    $this->debug(3, 'We have no document root set, so as a last resort, lets check if the image is in the current dir and serve that.');
        Severity: Minor
        Found in thumb.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

        Severity
        Category
        Status
        Source
        Language