XoopsModules25x/xlanguage

View on GitHub

Showing 589 of 589 total issues

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 20 and the first side effect is on line 63.
Open

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

The parameter $in_charset is not named in camelCase.
Open

    public static function convertItem($value, $out_charset, $in_charset)
    {
        if (mb_strtolower($in_charset) == mb_strtolower($out_charset)) {
            return $value;
        }
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

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

        $db     = XoopsDatabaseFactory::getDatabaseConnection();
Severity: Minor
Found in class/Helper.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

The property $lang_base is not named in camelCase.
Open

class Language extends Xlanguage\Blanguage
{
    public $lang_base;

    /**
Severity: Minor
Found in class/Language.php by phpmd

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

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

    public function get($id, $isBase = true)
Severity: Minor
Found in class/LanguageHandler.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 43 and the first side effect is on line 32.
Open

<?php
Severity: Minor
Found in include/onupdate.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 20 and the first side effect is on line 17.
Open

<?php
Severity: Minor
Found in language/english/common.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 24 and the first side effect is on line 21.
Open

<?php

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

    public function get($id, $isBase = true)
    {
        $array = [];
        $lang  = null;
        $id    = (int)$id;
Severity: Minor
Found in class/LanguageHandler.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

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

    public function getAll($isBase = true)
    {
        $prefix = $isBase ? 'xlanguage_base' : 'xlanguage_ext';
        $ret    = [];
        if (isset($this->cachedConfig[$prefix])) {
Severity: Minor
Found in class/LanguageHandler.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

Avoid deeply nested control flow statements.
Open

                            if ('html' === $fileInfo->getExtension() && 'index.html' !== $fileInfo->getFilename()) {
                                if (is_file($templateFolder . $v)) {
                                    unlink($templateFolder . $v);
                                }
                            }
Severity: Major
Found in include/onupdate.php - About 45 mins to fix

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

          public function getAllList()
          {
              $baseArray = $this->getAll();
      
              $extArray = $this->getAll(false);
      Severity: Minor
      Found in class/LanguageHandler.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\Xlanguage\{Helper,
      Severity: Minor
      Found in include/common.php by phpcodesniffer

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

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

      There must be one USE keyword per declaration
      Open

      use XoopsModules\Xlanguage\{Helper,
      Severity: Minor
      Found in include/onuninstall.php by phpcodesniffer

      There must be one USE keyword per declaration
      Open

      use XoopsModules\Xlanguage\{
      Severity: Minor
      Found in admin/index.php by phpcodesniffer

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

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

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

      ];
      Severity: Minor
      Found in config/config.php by phpcodesniffer
      Severity
      Category
      Status
      Source
      Language