XoopsModules25x/xfguestbook

View on GitHub
class/Utility.php

Summary

Maintainability
B
5 hrs
Test Coverage

upload accesses the super-global variable $_FILES.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

upload accesses the super-global variable $_FILES.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

upload accesses the super-global variable $_POST.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

upload accesses the super-global variable $_FILES.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Function upload has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.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 upload has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function upload()
    {
        global $xoopsModule, $preview_name, $msgstop;
        /** @var Helper $helper */
        $helper = Helper::getInstance();
Severity: Minor
Found in class/Utility.php - About 1 hr to fix

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

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    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 get_badips has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function get_badips($all = null)
        {
            global $xoopsDB;
            $ret    = [];
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_badips');
    Severity: Minor
    Found in class/Utility.php - About 25 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 using undefined variables such as '$a_poster' which will lead to PHP notices.
    Open

                    $rank['title'] ? $a_poster['rank'] = $rank['title'] : $a_poster['rank'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                    $poster->user_avatar() ? $a_poster['avatar'] = "<img src='" . XOOPS_URL . '/uploads/' . $poster->user_avatar() . '\' alt=\'\'>' : $a_poster['avatar'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                $xoopsUser ? $a_poster['poster'] = "<a href='../../userinfo.php?uid=$user_id'>" . $poster->uname() . '</a>' : $a_poster['poster'] = $poster->uname();
    Severity: Minor
    Found in class/Utility.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

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

                    $poster->user_avatar() ? $a_poster['avatar'] = "<img src='" . XOOPS_URL . '/uploads/' . $poster->user_avatar() . '\' alt=\'\'>' : $a_poster['avatar'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                    $a_poster['avatar']   = '';
    Severity: Minor
    Found in class/Utility.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

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

                return $a_poster;
    Severity: Minor
    Found in class/Utility.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

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

                    $a_poster['rank_img'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                    $rank['image'] ? $a_poster['rank_img'] = "<img src='" . XOOPS_URL . '/uploads/' . $rank['image'] . '\' alt=\'\'>' : $a_poster['rank_img'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                    $rank['title'] ? $a_poster['rank'] = $rank['title'] : $a_poster['rank'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                    $rank['image'] ? $a_poster['rank_img'] = "<img src='" . XOOPS_URL . '/uploads/' . $rank['image'] . '\' alt=\'\'>' : $a_poster['rank_img'] = '';
    Severity: Minor
    Found in class/Utility.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

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

                $xoopsUser ? $a_poster['poster'] = "<a href='../../userinfo.php?uid=$user_id'>" . $poster->uname() . '</a>' : $a_poster['poster'] = $poster->uname();
    Severity: Minor
    Found in class/Utility.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

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

                    $a_poster['rank']     = '';
    Severity: Minor
    Found in class/Utility.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

    Remove error control operator '@' on line 150.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Remove error control operator '@' on line 142.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Missing class import via use statement (line '33', column '48').
    Open

                    $uploader                = new \XoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $helper->getConfig('photo_maxsize'), $helper->getConfig('photo_maxwidth'), $helper->getConfig('photo_maxheight'));
    Severity: Minor
    Found in class/Utility.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Remove error control operator '@' on line 36.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    ErrorControlOperator

    Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

    Example

    function foo($filePath) {
        $file = @fopen($filPath); // hides exceptions
        $key = @$array[$notExistingKey]; // assigns null to $key
    }

    Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

    Missing class import via use statement (line '113', column '23').
    Open

            $poster = new \XoopsUser($user_id);
    Severity: Minor
    Found in class/Utility.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Avoid using static access to class 'XoopsModules\Xfguestbook\Helper' in method 'get_user_data'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    The method upload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        $msgstop .= $uploader->getErrors();
                    }
    Severity: Minor
    Found in class/Utility.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    The method upload uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $photos_dir              = XOOPS_UPLOAD_PATH . '/' . $xoopsModule->getVar('dirname');
                    $array_allowed_mimetypes = ['image/gif', 'image/pjpeg', 'image/jpeg', 'image/x-png'];
                    $uploader                = new \XoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $helper->getConfig('photo_maxsize'), $helper->getConfig('photo_maxwidth'), $helper->getConfig('photo_maxheight'));
                    if ($uploader->fetchMedia($field) && $uploader->upload()) {
    Severity: Minor
    Found in class/Utility.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    The method get_badips uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                while (list($ip_id, $ip_value) = $xoopsDB->fetchRow($result)) {
                    $ret[] = $ip_value;
                }
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid assigning values to variables in if clauses and the like (line '142', column '15').
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    IfStatementAssignment

    Since: 2.7.0

    Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($foo = 'bar') { // possible typo
                // ...
            }
            if ($baz = 0) { // always false
                // ...
            }
        }
    }

    Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

    The method get_user_data uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                } else {
                    $a_poster['rank']     = '';
                    $a_poster['avatar']   = '';
                    $a_poster['rank_img'] = '';
                }
    Severity: Minor
    Found in class/Utility.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

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

    Avoid using static access to class 'XoopsModules\Xfguestbook\Helper' in method 'upload'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class 'XoopsModules\Xfguestbook\Helper' in method 'getAllCountry'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid unused local variables such as '$action'.
    Open

            global $xoopsDB, $action;
    Severity: Minor
    Found in class/Utility.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$prefix_len'.
    Open

            $prefix_len = mb_strlen($prefix);
    Severity: Minor
    Found in class/Utility.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$action'.
    Open

            global $xoopsDB, $action;
    Severity: Minor
    Found in class/Utility.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

    Avoid unused local variables such as '$ip_id'.
    Open

                while (list($ip_id, $ip_value) = $xoopsDB->fetchRow($result)) {
    Severity: Minor
    Found in class/Utility.php by phpmd

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

        public static function getCountry($criteria = null, $limit = 0, $start = 0)
        {
            global $xoopsDB, $action;
            $ret = [];
            $sql = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_country');
    Severity: Major
    Found in class/Utility.php and 1 other location - About 1 hr to fix
    admin/country_manager.php on lines 212..228

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

    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

    Avoid excessively long variable names like $array_allowed_mimetypes. Keep variable name length under 20.
    Open

                    $array_allowed_mimetypes = ['image/gif', 'image/pjpeg', 'image/jpeg', 'image/x-png'];
    Severity: Minor
    Found in class/Utility.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    The parameter $user_id is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $dir_path is not named in camelCase.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseParameterName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name parameters.

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Method name "Utility::email_exist" is not in camel caps format
    Open

        public static function email_exist($email)
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Method name "Utility::get_user_data" is not in camel caps format
    Open

        public static function get_user_data($user_id)
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Method name "Utility::get_badips" is not in camel caps format
    Open

        public static function get_badips($all = null)
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Method name "Utility::clear_tmp_files" is not in camel caps format
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    The 'get_user_data()' method which returns a boolean should be named 'is...()' or 'has...()'
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    BooleanGetMethodName

    Since: 0.2

    Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

    Example

    class Foo {
        /**
         * @return boolean
         */
        public function getFoo() {} // bad
        /**
         * @return bool
         */
        public function isFoo(); // ok
        /**
         * @return boolean
         */
        public function getFoo($bar); // ok, unless checkParameterizedMethods=true
    }

    Source https://phpmd.org/rules/naming.html#booleangetmethodname

    Line exceeds 120 characters; contains 171 characters
    Open

                    $poster->user_avatar() ? $a_poster['avatar'] = "<img src='" . XOOPS_URL . '/uploads/' . $poster->user_avatar() . '\' alt=\'\'>' : $a_poster['avatar'] = '';
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Line exceeds 120 characters; contains 161 characters
    Open

                $xoopsUser ? $a_poster['poster'] = "<a href='../../userinfo.php?uid=$user_id'>" . $poster->uname() . '</a>' : $a_poster['poster'] = $poster->uname();
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Line exceeds 120 characters; contains 220 characters
    Open

                    $uploader                = new \XoopsMediaUploader($photos_dir, $array_allowed_mimetypes, $helper->getConfig('photo_maxsize'), $helper->getConfig('photo_maxwidth'), $helper->getConfig('photo_maxheight'));
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    Line exceeds 120 characters; contains 159 characters
    Open

                    $rank['image'] ? $a_poster['rank_img'] = "<img src='" . XOOPS_URL . '/uploads/' . $rank['image'] . '\' alt=\'\'>' : $a_poster['rank_img'] = '';
    Severity: Minor
    Found in class/Utility.php by phpcodesniffer

    The variable $preview_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $user_id is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_value is not named in camelCase.
    Open

        public static function get_badips($all = null)
        {
            global $xoopsDB;
            $ret    = [];
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_badips');
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $photos_dir is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $tmp_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $tmp_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_value is not named in camelCase.
    Open

        public static function get_badips($all = null)
        {
            global $xoopsDB;
            $ret    = [];
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_badips');
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $photos_dir is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $photos_dir is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $preview_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $array_allowed_mimetypes is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $ip_id is not named in camelCase.
    Open

        public static function get_badips($all = null)
        {
            global $xoopsDB;
            $ret    = [];
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_badips');
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $photos_dir is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $photos_dir is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $preview_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $user_id is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $array_allowed_mimetypes is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $dir_path is not named in camelCase.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $preview_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $preview_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $dir_path is not named in camelCase.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $user_id is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $tmp_name is not named in camelCase.
    Open

        public static function upload()
        {
            global $xoopsModule, $preview_name, $msgstop;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $a_poster is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The variable $prefix_len is not named in camelCase.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseVariableName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name variables.

    Example

    class ClassName {
        public function doSomething() {
            $data_module = new DataModule();
        }
    }

    Source

    The method get_user_data is not named in camelCase.
    Open

        public static function get_user_data($user_id)
        {
            global $xoopsUser;
            /** @var Helper $helper */
            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method get_badips is not named in camelCase.
    Open

        public static function get_badips($all = null)
        {
            global $xoopsDB;
            $ret    = [];
            $sql    = 'SELECT * FROM ' . $xoopsDB->prefix('xfguestbook_badips');
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method email_exist is not named in camelCase.
    Open

        public static function email_exist($email)
        {
            if (!\filter_var($email, \FILTER_VALIDATE_EMAIL)) {
                return false;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    The method clear_tmp_files is not named in camelCase.
    Open

        public static function clear_tmp_files($dir_path, $prefix = 'tmp_')
        {
            if (!($dir = @\opendir($dir_path))) {
                return 0;
            }
    Severity: Minor
    Found in class/Utility.php by phpmd

    CamelCaseMethodName

    Since: 0.2

    It is considered best practice to use the camelCase notation to name methods.

    Example

    class ClassName {
        public function get_name() {
        }
    }

    Source

    There are no issues that match your filters.

    Category
    Status