XoopsModules25x/news

View on GitHub

Showing 310 of 310 total issues

Method getStoriesByIds has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

        $ids,
        $checkRight = true,
        $asobject = true,
        $order = 'published',
        $onlyOnline = true
Severity: Minor
Found in class/NewsStory.php - About 35 mins to fix

    Function news_resizePicture has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function news_resizePicture(
        $src_path,
        $dst_path,
        $param_width,
        $param_height,
    Severity: Minor
    Found in include/functions.php - About 35 mins 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 createUploadName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function createUploadName($folder, $filename, $trimname = false)
        {
            $workingfolder = $folder;
            if ('/' !== \xoops_substr($workingfolder, mb_strlen($workingfolder) - 1, 1)) {
                $workingfolder .= '/';
    Severity: Minor
    Found in class/Files.php - About 35 mins 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 getEditor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getEditor($helper = null, $options = null)
        {
            /** @var Helper $helper */
            if (null === $options) {
                $options           = [];
    Severity: Minor
    Found in class/Common/SysUtility.php - About 35 mins 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 getTopicsList has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getTopicsList($frontpage = false, $perms = false)
        {
            $ret = [];
            $sql = 'SELECT topic_id, topic_pid, topic_title, topic_color FROM ' . $this->table . ' WHERE 1 ';
            if ($frontpage) {
    Severity: Minor
    Found in class/NewsTopic.php - About 35 mins 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 makeSelBoxOptions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function makeSelBoxOptions($fieldName, $selected, $key, &$ret, $prefix_orig, $prefix_curr = ''): void
        {
            if ($key > 0) {
                $value = $this->tree[$key]['obj']->getVar($this->myId);
                $ret   .= '<option value="' . $value . '"';
    Severity: Minor
    Found in class/ObjectTree.php - About 35 mins 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 news_notify_iteminfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    function news_notify_iteminfo($category, $item_id)
    {
        if ('global' === $category) {
            $item['name'] = '';
            $item['url']  = '';
    Severity: Minor
    Found in include/notification.inc.php - About 35 mins 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 delete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function delete($keyword): void
        {
            if (\is_array($keyword)) {
                foreach ($keyword as $onekeyword) {
                    if (isset($this->keywords[$onekeyword])) {
    Severity: Minor
    Found in class/Blacklist.php - About 35 mins 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 hometext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function hometext($format = 'Show')
        {
            $myts   = MyTextSanitizer::getInstance();
            $html   = 1;
            $smiley = 1;
    Severity: Minor
    Found in class/XoopsStory.php - About 35 mins 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 resizePicture has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function resizePicture(
            $src_path,
            $dst_path,
            $param_width,
            $param_height,
    Severity: Minor
    Found in class/Utility.php - About 35 mins 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 getEditor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getEditor($helper = null, $options = null)
        {
            /** @var Helper $helper */
            if (null === $options) {
                $options           = [];
    Severity: Minor
    Found in class/Utility.php - About 35 mins 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 bodytext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function bodytext($format = 'Show')
        {
            $myts   = MyTextSanitizer::getInstance();
            $html   = 1;
            $smiley = 1;
    Severity: Minor
    Found in class/XoopsStory.php - About 35 mins 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 hometext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function hometext($format = 'Show')
        {
            $hometext = '';
            $myts     = \MyTextSanitizer::getInstance();
            $html     = $smiley = $xcodes = 1;
    Severity: Minor
    Found in class/NewsStory.php - About 35 mins 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 bodytext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function bodytext($format = 'Show')
        {
            $myts   = \MyTextSanitizer::getInstance();
            $html   = 1;
            $smiley = 1;
    Severity: Minor
    Found in class/NewsStory.php - About 35 mins 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

    Avoid too many return statements within this method.
    Open

        return false;
    Severity: Major
    Found in include/install_function.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

          return null;
      Severity: Major
      Found in include/notification.inc.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return null;
        Severity: Major
        Found in include/notification.inc.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return null;
          Severity: Major
          Found in class/NewsStory.php - About 30 mins to fix

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

                            if ($counter == $current_page) {
                                $ret .= '<option value="' . $this->url . (($counter - 1) * $this->perpage) . '" selected>' . $title . '</option>';
                            } else {
                                $ret .= '<option value="' . $this->url . (($counter - 1) * $this->perpage) . '">' . $title . '</option>';
                            }
            Severity: Minor
            Found in class/PageNav.php and 1 other location - About 30 mins to fix
            class/PageNav.php on lines 128..132

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

            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 ($counter == $current_page) {
                                $ret .= '<option value="' . $this->url . (($counter - 1) * $this->perpage) . '" selected>' . $counter . '</option>';
                            } else {
                                $ret .= '<option value="' . $this->url . (($counter - 1) * $this->perpage) . '">' . $counter . '</option>';
                            }
            Severity: Minor
            Found in class/PageNav.php and 1 other location - About 30 mins to fix
            class/PageNav.php on lines 167..171

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

            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

            Severity
            Category
            Status
            Source
            Language