efureev/u.php

View on GitHub

Showing 114 of 114 total issues

Function generateRandomKey has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
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 - About 5 hrs 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 save has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

    public static function save($key, array &$array, $value, $replace = true)
    {
        if ($key === '') {
            $array[ $key ] = $value;

Severity: Minor
Found in src/uArray.php - About 4 hrs 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 class uArray has an overall complexity of 72 which is very high. The configured complexity threshold is 50.
Open

class uArray
{

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

The class uFile has an overall complexity of 58 which is very high. The configured complexity threshold is 50.
Open

class uFile
{

    /**
     * Return File Extension
Severity: Minor
Found in src/uFile.php by phpmd

Method parseAndValidateKeys has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private static function parseAndValidateKeys($key, array &$array, $mode = '')
    {
        $parseInfo = [
            'keys'         => [],
            'lastKey'      => '',
Severity: Major
Found in src/uArray.php - About 2 hrs to fix

    Method generateRandomKey has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function generateRandomKey($length = 32)
        {
            if (!is_int($length)) {
                throw new \Exception('First parameter ($length) must be an integer');
            }
    Severity: Major
    Found in src/uSecurity.php - About 2 hrs to fix

      Function parseAndValidateKeys has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function parseAndValidateKeys($key, array &$array, $mode = '')
          {
              $parseInfo = [
                  'keys'         => [],
                  'lastKey'      => '',
      Severity: Minor
      Found in src/uArray.php - About 2 hrs 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 isAssociative has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function isAssociative($array, $allStrings = true)
          {
              if (!is_array($array) || empty($array)) {
                  return false;
              }
      Severity: Minor
      Found in src/uArray.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 save has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function save($key, array &$array, $value, $replace = true)
          {
              if ($key === '') {
                  $array[ $key ] = $value;
      
      
      Severity: Minor
      Found in src/uArray.php - About 1 hr to fix

        Avoid using short method names like uFile::ls(). The configured minimum method name length is 3.
        Open

            public static function ls($dir)
            {
                $contents = [];
                $flags = \FilesystemIterator::KEY_AS_PATHNAME
                    | \FilesystemIterator::CURRENT_AS_FILEINFO
        Severity: Minor
        Found in src/uFile.php by phpmd

        ShortMethodName

        Since: 0.2

        Detects when very short method names are used.

        Example

        class ShortMethod {
            public function a( $index ) { // Violation
            }
        }

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

        Method perms has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function perms($file, $perms = null)
            {
                if (null === $perms) {
                    if (!file_exists($file)) {
                        return false;
        Severity: Minor
        Found in src/uFile.php - About 1 hr to fix

          Function perms has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function perms($file, $perms = null)
              {
                  if (null === $perms) {
                      if (!file_exists($file)) {
                          return false;
          Severity: Minor
          Found in src/uFile.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

          Function normalizePath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function normalizePath($path, $slash = DIRECTORY_SEPARATOR)
              {
                  $path = rtrim(strtr($path, '/\\', $slash . $slash), $slash);
                  if (strpos($slash . $path, "{$slash}.") === false && strpos($path, "{$slash}{$slash}") === false) {
                      return $path;
          Severity: Minor
          Found in src/uFile.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

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

                              $mCurSource[ $key ] = [];
          Severity: Minor
          Found in src/uArray.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

          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

          The class uFile is not named in CamelCase.
          Open

          class uFile
          {
          
              /**
               * Return File Extension
          Severity: Minor
          Found in src/uFile.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 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

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

                      $m = floor($value % 60);
          Severity: Minor
          Found in src/uTime.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 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 $h. Configured minimum length is 3.
          Open

                      $h = floor($value / 60);
          Severity: Minor
          Found in src/uTime.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

          Severity
          Category
          Status
          Source
          Language