efureev/u.php

View on GitHub

Showing 18 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

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

        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

          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

          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

          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

          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

            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

              Avoid too many return statements within this method.
              Open

                          return false;
              Severity: Major
              Found in src/uArray.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return ($parseInfo['completed'] && ($parseInfo['isExists'] || $parseInfo['isString'])) ? $parseInfo['value'] : $default;
                Severity: Major
                Found in src/uArray.php - About 30 mins to fix

                  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
                    Severity
                    Category
                    Status
                    Source
                    Language