mambax7/gbook

View on GitHub

Showing 307 of 307 total issues

The parameter $id_field is not named in camelCase.
Open

    public static function cloneRecord($tableName, $id_field, $id)
    {
        $new_id = false;
        $table  = $GLOBALS['xoopsDB']->prefix($tableName);
        // copy content of the record you wish to clone 
Severity: Minor
Found in class/Common/SysUtility.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

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

    $db = \XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in testdata/index.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 22 and the first side effect is on line 19.
Open

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

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

    public static function cloneRecord($tableName, $id_field, $id)
Severity: Minor
Found in class/Common/SysUtility.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 63 and the first side effect is on line 28.
Open

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

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

    public function __construct(XoopsDatabase $db = null)
Severity: Minor
Found in class/EntriesHandler.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 36 and the first side effect is on line 25.
Open

<?php
Severity: Minor
Found in include/onupdate.php by phpcodesniffer

Identical blocks of code found in 2 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: Minor
Found in include/config.php and 1 other location - About 45 mins to fix
config/config.php on lines 28..35

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 2 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: Minor
Found in config/config.php and 1 other location - About 45 mins to fix
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): string
Severity: Minor
Found in class/Common/SysUtility.php - About 35 mins to fix

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

    use XoopsModules\Gbook;
    Severity: Minor
    Found in admin/menu.php by phpcodesniffer

    There must be one USE keyword per declaration
    Open

    use XoopsModules\Gbook\{
    Severity: Minor
    Found in testdata/index.php by phpcodesniffer

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

    use XoopsThemeForm;
    Severity: Minor
    Found in class/Entries.php by phpcodesniffer

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

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

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

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

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

    use XoopsModule;

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

    use XoopsDatabaseFactory;
    Severity: Minor
    Found in class/Helper.php by phpcodesniffer

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

        public static function getEditor($helper = null, $options = null)
        {
            /** @var Gbook\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

    There must be one USE keyword per declaration
    Open

    use XoopsModules\Gbook\{
    Severity: Minor
    Found in sign.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
    Severity
    Category
    Status
    Source
    Language