XoopsModules25x/xoopspartners

View on GitHub

Showing 346 of 346 total issues

Avoid variables with short names like $db. Configured minimum length is 3.
Open

    protected $db;
Severity: Minor
Found in class/Partners.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

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

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 28 and the first side effect is on line 26.
Open

<?php
Severity: Minor
Found in language/english/admin.php by phpcodesniffer

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 30 and the first side effect is on line 28.
Open

<?php
Severity: Minor
Found in language/french/admin.php by phpcodesniffer

Avoid deeply nested control flow statements.
Open

                            if (file_exists($templateFolder . $v)) {
                                unlink($templateFolder . $v);
                            }
Severity: Major
Found in include/onupdate.php - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if ($uploader->upload()) {
                                $image = $uploader->getSavedFileName();  // get file name to save in db
                            }
    Severity: Major
    Found in join.php - About 45 mins to fix

      Function loadSampleData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function loadSampleData()
      {
          global $xoopsConfig;
      
          $moduleDirName = basename(dirname(__DIR__));
      Severity: Minor
      Found in testdata/index.php - About 45 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

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

          'paths'          => [
              'dirname'    => $moduleDirName,
              'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
              'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
              'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
      Severity: Major
      Found in include/config.php and 2 other locations - About 45 mins to fix
      config/config.php on lines 27..34
      config/paths.php on lines 11..18

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

      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

          'paths'         => [
              'dirname'    => $moduleDirName,
              'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
              'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
              'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
      Severity: Major
      Found in config/paths.php and 2 other locations - About 45 mins to fix
      config/config.php on lines 27..34
      include/config.php on lines 27..34

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

      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

          'paths'          => [
              'dirname'    => $moduleDirName,
              'admin'      => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/admin',
              'modPath'    => XOOPS_ROOT_PATH . '/modules/' . $moduleDirName,
              'modUrl'     => XOOPS_URL . '/modules/' . $moduleDirName,
      Severity: Major
      Found in config/config.php and 2 other locations - About 45 mins to fix
      config/paths.php on lines 11..18
      include/config.php on lines 27..34

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

      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 truncateHtml has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true)
      Severity: Minor
      Found in class/Common/SysUtility.php - About 35 mins to fix

        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 closing brace must go on the next line following the body; found 1 blank lines before brace
        Open

        }
        Severity: Minor
        Found in testdata/index.php by phpcodesniffer

        Scope keyword "public" must be followed by a single space
        Open

            public  $dirname;
        Severity: Minor
        Found in class/Common/Breadcrumb.php by phpcodesniffer

        The closing brace for the class must go on the next line after the body
        Open

        }
        Severity: Minor
        Found in class/Utility.php by phpcodesniffer

        There must be one blank line after the last USE statement; 3 found;
        Open

        use XoopsModules\Xoopspartners;
        Severity: Minor
        Found in class/PartnersHandler.php by phpcodesniffer

        There must be one blank line after the last USE statement; 2 found;
        Open

        use XoopsModules\Xoopspartners\Helper;
        Severity: Minor
        Found in class/Common/SysUtility.php by phpcodesniffer

        Expected 1 blank line at end of file; 2 found
        Open

        ];
        Severity: Minor
        Found in config/config.php by phpcodesniffer

        Expected 1 blank line at end of file; 2 found
        Open

        ];
        Severity: Minor
        Found in config/imageconfig.php by phpcodesniffer

        Missing class import via use statement (line '101', column '41').
        Open

                                $fileInfo = new \SplFileInfo($templateFolder . $v);
        Severity: Minor
        Found in include/onupdate.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 60.
        Open

            public static function recurseCopy($src, $dst)
            {
                $dir = \opendir($src);
                //        @mkdir($dst);
                if (!@\mkdir($dst) && !\is_dir($dst)) {
        Severity: Minor
        Found in class/Common/FilesManagement.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

        Severity
        Category
        Status
        Source
        Language