efureev/u.php

View on GitHub

Showing 114 of 114 total issues

The class uColor is not named in CamelCase.
Open

class uColor
{

    /**
     * Convert a hexa decimal color code to its RGB equivalent
Severity: Minor
Found in src/uColor.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

The class uArray is not named in CamelCase.
Open

class uArray
{

    /**
     * Проверяет, является ли массив ассоциативным
Severity: Minor
Found in src/uArray.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

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

            function ($m) use (&$parseInfo, &$array) {
Severity: Minor
Found in src/uArray.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 class uString is not named in CamelCase.
Open

class uString
{

    /**
     * Start string with $startStr
Severity: Minor
Found in src/uString.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

The class uList is not named in CamelCase.
Open

class uList
{

    /**
     * Return range integer list
Severity: Minor
Found in src/uList.php by phpmd

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

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

    public static function isIndexed(array $array, $consecutive = false)
    {
        if (empty($array)) {
            return true;
        }
Severity: Minor
Found in src/uArray.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

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

}
Severity: Minor
Found in src/uColor.php by phpcodesniffer

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

    public static function sizeFormat($bytes, $decimals = 0)
    {
        $bytes = floatval($bytes);

        if ($bytes < 1024) {
Severity: Minor
Found in src/uFile.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

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

}
Severity: Minor
Found in src/uList.php by phpcodesniffer

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

}
Severity: Minor
Found in src/uFile.php by phpcodesniffer

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

}
Severity: Minor
Found in src/uSecurity.php by phpcodesniffer

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

    public static function get($key, array $array, $default = null, $ignoreString = true)
    {
        if ($key === '') {
            if (!array_key_exists((string)$key, $array)) {
                return $default;
Severity: Minor
Found in src/uArray.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

The method isIndexed has a boolean flag argument $consecutive, which is a certain sign of a Single Responsibility Principle violation.
Open

    public static function isIndexed(array $array, $consecutive = false)
Severity: Minor
Found in src/uArray.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

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

Avoid too many return statements within this method.
Open

            return number_format($bytes / pow(1024, 5), $decimals, '.', '') . ' PiB';
Severity: Major
Found in src/uFile.php - About 30 mins to fix

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

        public function generateRandomKey($length = 32)
        {
            if (!is_int($length)) {
                throw new \Exception('First parameter ($length) must be an integer');
            }
    Severity: Minor
    Found in src/uSecurity.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

    Avoid too many return statements within this method.
    Open

                return number_format($bytes / pow(1024, 4), $decimals, '.', '') . ' TiB';
    Severity: Major
    Found in src/uFile.php - About 30 mins to fix

      The method isAssociative has a boolean flag argument $allStrings, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function isAssociative($array, $allStrings = true)
      Severity: Minor
      Found in src/uArray.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

      Missing class import via use statement (line '229', column '55').
      Open

              $dirIter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, $flags));
      Severity: Minor
      Found in src/uFile.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

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

                  throw new \Exception('First parameter ($length) must be greater than 0');
      Severity: Minor
      Found in src/uSecurity.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

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

                  throw new \Exception('First parameter ($length) must be greater than 0');
      Severity: Minor
      Found in src/uSecurity.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

      Severity
      Category
      Status
      Source
      Language