symplely/coroutine

View on GitHub
Coroutine/FileSystem.php

Summary

Maintainability
F
4 days
Test Coverage

File FileSystem.php has 859 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

declare(strict_types=1);

namespace Async;
Severity: Major
Found in Coroutine/FileSystem.php - About 2 days to fix

    FileSystem has 40 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    final class FileSystem
    {
      /**
       * File access modes.
       *
    Severity: Minor
    Found in Coroutine/FileSystem.php - About 5 hrs to fix

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

        public static function meta($fd = null, ?string $info = null)
        {
          if (!\is_resource($fd) && ($info == 'status' || $info == 'size'))
            return $info == 'status' ? 400 : 0;
          elseif (!\is_resource($fd))
      Severity: Minor
      Found in Coroutine/FileSystem.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

      Method open has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

        public static function open(string $path, string $flag = 'r', int $mode = \S_IRWXU, $contexts = null)
        {
          if (isset(self::$fileFlags[$flag])) {
            if (self::isUv() && (\strpos($path, '://') === false)) {
              return new Kernel(
      Severity: Minor
      Found in Coroutine/FileSystem.php - About 1 hr to fix

        Method touch has 41 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

          public static function touch($path = null, int $time = null, int $atime = null)
          {
            if (self::isUv()) {
              return new Kernel(
                function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $time, $atime) {
        Severity: Minor
        Found in Coroutine/FileSystem.php - About 1 hr to fix

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

            public static function open(string $path, string $flag = 'r', int $mode = \S_IRWXU, $contexts = null)
            {
              if (isset(self::$fileFlags[$flag])) {
                if (self::isUv() && (\strpos($path, '://') === false)) {
                  return new Kernel(
          Severity: Minor
          Found in Coroutine/FileSystem.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 watch has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public static function watch(string $path, int $watchTask)
            {
              if (self::isUv()) {
                return new Kernel(
                  function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $watchTask) {
          Severity: Minor
          Found in Coroutine/FileSystem.php - About 1 hr to fix

            Method read has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Wontfix

              public static function read($fd = null, int $offset = 0, int $length = 8192)
              {
                if (self::isUv() && (self::meta($fd, 'wrapper_type') !== 'http')) {
                  return new Kernel(
                    function (TaskInterface $task, CoroutineInterface $coroutine) use ($fd, $offset, $length) {
            Severity: Minor
            Found in Coroutine/FileSystem.php - About 1 hr to fix

              Function contents has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                public static function contents($fd = null, int $size = 256, float $timeout_seconds = 0.5)
                {
                  if (!\is_resource($fd))
                    return yield \value(false);
              
              
              Severity: Minor
              Found in Coroutine/FileSystem.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 write has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Wontfix

                public static function write($fd = null, string $buffer = null, $offset = -1)
                {
                  if (self::isUv() && (self::meta($fd, 'wrapper_type') !== 'http')) {
                    return new Kernel(
                      function (TaskInterface $task, CoroutineInterface $coroutine) use ($fd, $buffer, $offset) {
              Severity: Minor
              Found in Coroutine/FileSystem.php - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                    return isset($meta[$info]) ? $meta[$info] : $meta;
                Severity: Major
                Found in Coroutine/FileSystem.php - About 30 mins to fix

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function stat(string $path = '', ?string $info = null)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $info) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 4 hrs to fix
                  Coroutine/FileSystem.php on lines 633..660

                  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 175.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function lstat(string $path = '', ?string $info = null)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $info) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 4 hrs to fix
                  Coroutine/FileSystem.php on lines 685..712

                  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 175.

                  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

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                    public static function link(string $from, string $to)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 131..152
                  Coroutine/FileSystem.php on lines 397..418

                  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 139.

                  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

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                    public static function rename(string $from, string $to)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 246..267
                  Coroutine/FileSystem.php on lines 397..418

                  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 139.

                  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

                  Similar blocks of code found in 3 locations. Consider refactoring.
                  Open

                    public static function chmod(string $filename, int $mode)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($filename, $mode) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 2 other locations - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 131..152
                  Coroutine/FileSystem.php on lines 246..267

                  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 139.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function symlink(string $from = null, string $to = null, int $flag = 0)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($from, $to, $flag) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 430..452

                  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 134.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function chown(string $path, int $uid, int $gid)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($path, $uid, $gid) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 277..299

                  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 134.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function rmdir(string $path)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($path) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 215..235

                  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 126.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                    public static function unlink(string $path)
                    {
                      if (self::isUv()) {
                        return new Kernel(
                          function (TaskInterface $task, CoroutineInterface $coroutine) use ($path) {
                  Severity: Major
                  Found in Coroutine/FileSystem.php and 1 other location - About 2 hrs to fix
                  Coroutine/FileSystem.php on lines 366..386

                  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 126.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                if ($result < 0) {
                                  // @codeCoverageIgnoreStart
                                  \uv_fs_close($coroutine->getUV(), $fd, function () use ($task, $coroutine) {
                                    $coroutine->fsRemove();
                                    $task->setException(new \Exception("write error"));
                  Severity: Minor
                  Found in Coroutine/FileSystem.php and 1 other location - About 50 mins to fix
                  Coroutine/FileSystem.php on lines 1123..1135

                  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 97.

                  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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                                if ($status < 0) {
                                  // @codeCoverageIgnoreStart
                                  \uv_fs_close($coroutine->getUV(), $fd, function () use ($task, $coroutine) {
                                    $coroutine->fsRemove();
                                    $task->setException(new \Exception("read error"));
                  Severity: Minor
                  Found in Coroutine/FileSystem.php and 1 other location - About 50 mins to fix
                  Coroutine/FileSystem.php on lines 1184..1196

                  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 97.

                  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

                  There are no issues that match your filters.

                  Category
                  Status