symplely/coroutine

View on GitHub
Coroutine/Coroutine.php

Summary

Maintainability
F
5 days
Test Coverage

File Coroutine.php has 965 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

<?php

declare(strict_types=1);

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

    Coroutine has 70 functions (exceeds 20 allowed). Consider refactoring.
    Wontfix

    final class Coroutine implements CoroutineInterface
    {
      /**
       * checker for main supervisor task running state
       *
    Severity: Major
    Found in Coroutine/Coroutine.php - About 1 day to fix

      Function execute has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

        public function execute($isReturn = false)
        {
          while (!$this->taskQueue->isEmpty()) {
            /** @var TaskInterface|FiberInterface */
            $task = $this->taskQueue->dequeue();
      Severity: Minor
      Found in Coroutine/Coroutine.php - About 1 day 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 create has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        public static function create(\Generator $gen)
        {
          $stack = new \SplStack;
          $exception = null;
      
      
      Severity: Minor
      Found in Coroutine/Coroutine.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

      Function close has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        public function close()
        {
          if ($this->uv instanceof \UVLoop) {
            foreach ($this->timers as $timer) {
              if ($timer instanceof \UVTimer && \uv_is_active($timer))
      Severity: Minor
      Found in Coroutine/Coroutine.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 execute has 66 lines of code (exceeds 25 allowed). Consider refactoring.
      Wontfix

        public function execute($isReturn = false)
        {
          while (!$this->taskQueue->isEmpty()) {
            /** @var TaskInterface|FiberInterface */
            $task = $this->taskQueue->dequeue();
      Severity: Major
      Found in Coroutine/Coroutine.php - About 2 hrs to fix

        Function input has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          public static function input(int $size = 256, bool $error = false)
          {
            //Check on STDIN stream
            $blocking = \stream_set_blocking(\STDIN, false);
            if ($error && !$blocking) {
        Severity: Minor
        Found in Coroutine/Coroutine.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 shutdown has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          public function shutdown(?int $skipTask = 1)
          {
            if ($skipTask === 1)
              $skipTask = Co::getUnique('parent');
        
        
        Severity: Minor
        Found in Coroutine/Coroutine.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 close has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Wontfix

          public function close()
          {
            if ($this->uv instanceof \UVLoop) {
              foreach ($this->timers as $timer) {
                if ($timer instanceof \UVTimer && \uv_is_active($timer))
        Severity: Minor
        Found in Coroutine/Coroutine.php - About 1 hr to fix

          Method create has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Wontfix

            public static function create(\Generator $gen)
            {
              $stack = new \SplStack;
              $exception = null;
          
          
          Severity: Minor
          Found in Coroutine/Coroutine.php - About 1 hr to fix

            Method __construct has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Wontfix

              public function __construct()
              {
                $this->maxTaskId = Co::getUnique('dirty') === 1 ? Co::getUnique('max') : \random_int(10000, 9999999999);
                Co::reset();
                Co::setLoop($this);
            Severity: Minor
            Found in Coroutine/Coroutine.php - About 1 hr to fix

              Function __construct has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                public function __construct()
                {
                  $this->maxTaskId = Co::getUnique('dirty') === 1 ? Co::getUnique('max') : \random_int(10000, 9999999999);
                  Co::reset();
                  Co::setLoop($this);
              Severity: Minor
              Found in Coroutine/Coroutine.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 cancelTask has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                public function cancelTask(int $tid, $customState = null, string $errorMessage = 'Invalid task ID!')
                {
                  if (!isset($this->taskMap[$tid])) {
                    return false;
                  }
              Severity: Minor
              Found in Coroutine/Coroutine.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 executeFiber has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                protected function executeFiber(Fiber $fiber)
                {
                  // Skip and reschedule, if `fiber` in suspend state
                  if ($fiber->isSuspended())
                    return $this->scheduleFiber($fiber);
              Severity: Minor
              Found in Coroutine/Coroutine.php - About 1 hr to fix

                Method addTimeout has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  public function addTimeout($task = null, float $timeout = 0.0, int $tid = null)
                  {
                    if ($this->isUv()) {
                      $interval = (int) \round($timeout * 1000);
                      $timer = \uv_timer_init($this->uv);
                Severity: Minor
                Found in Coroutine/Coroutine.php - About 1 hr to fix

                  Function cancelProgress has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public function cancelProgress(TaskInterface $task)
                    {
                      $channel = $task->getCustomState();
                      if (\is_array($channel) && (\count($channel) == 2)) {
                        [$channel, $channelTask] = $channel;
                  Severity: Minor
                  Found in Coroutine/Coroutine.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 removeSignal has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public function removeSignal($signal, $listener)
                    {
                      if (!$this->signaler || !$this->signaler->count($signal))
                        return;
                  
                  
                  Severity: Minor
                  Found in Coroutine/Coroutine.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 addTimeout has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    public function addTimeout($task = null, float $timeout = 0.0, int $tid = null)
                    {
                      if ($this->isUv()) {
                        $interval = (int) \round($timeout * 1000);
                        $timer = \uv_timer_init($this->uv);
                  Severity: Minor
                  Found in Coroutine/Coroutine.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 executeFiber has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                    protected function executeFiber(Fiber $fiber)
                    {
                      // Skip and reschedule, if `fiber` in suspend state
                      if ($fiber->isSuspended())
                        return $this->scheduleFiber($fiber);
                  Severity: Minor
                  Found in Coroutine/Coroutine.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 ioSocketStream has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Wontfix

                    protected function ioSocketStream($timeout)
                    {
                      if (empty($this->waitingForRead) && empty($this->waitingForWrite)) {
                        return;
                      }
                  Severity: Minor
                  Found in Coroutine/Coroutine.php - About 1 hr to fix

                    Function clearTimeout has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public function clearTimeout(TaskInterface $task): void
                      {
                        $timer = $task->getTimer();
                        if ($this->isUv() && $timer instanceof \UVTimer && \uv_is_active($timer)) {
                          @\uv_timer_stop($timer);
                    Severity: Minor
                    Found in Coroutine/Coroutine.php - About 55 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 updateCompleted has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      public function updateCompleted(
                        int $taskId,
                        array $completeList = [],
                        ?callable $onClear = null,
                        bool $cancel = false,
                    Severity: Minor
                    Found in Coroutine/Coroutine.php - About 55 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 (!$this->future->isEmpty())
                                  continue;
                    Severity: Major
                    Found in Coroutine/Coroutine.php - About 45 mins to fix

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

                        protected function addEvent($stream)
                        {
                          if (!isset($this->events[(int) $stream])) {
                            $meta = \stream_get_meta_data($stream);
                            switch ($meta['stream_type'] ?? '') {
                      Severity: Minor
                      Found in Coroutine/Coroutine.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 ioWaiting has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                        protected function ioWaiting()
                        {
                          $isUv = $this->isUv();
                          while (true) {
                            if ($this->isCoroutinesDone()) {
                      Severity: Minor
                      Found in Coroutine/Coroutine.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

                      Method updateCompleted has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          int $taskId,
                          array $completeList = [],
                          ?callable $onClear = null,
                          bool $cancel = false,
                          bool $forceUpdate = false
                      Severity: Minor
                      Found in Coroutine/Coroutine.php - About 35 mins to fix

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

                          public function addSignal($signal, $listener)
                          {
                            if (!$this->signaler)
                              return;
                        
                        
                        Severity: Minor
                        Found in Coroutine/Coroutine.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 ioSocketStream has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                          protected function ioSocketStream($timeout)
                          {
                            if (empty($this->waitingForRead) && empty($this->waitingForWrite)) {
                              return;
                            }
                        Severity: Minor
                        Found in Coroutine/Coroutine.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 updateScheduler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                          protected function updateScheduler(string $type, $stream, bool $removeEvent = false)
                          {
                            if ($type == 'read') {
                              list(, $tasks) = $this->waitingForRead[(int) $stream];
                              $this->removeReader($stream, $removeEvent);
                        Severity: Minor
                        Found in Coroutine/Coroutine.php - About 25 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

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

                          public function addReader($stream, $task, bool $addEvent = true): CoroutineInterface
                          {
                            $already = true;
                            if (isset($this->waitingForRead[(int) $stream])) {
                              $already = false;
                        Severity: Major
                        Found in Coroutine/Coroutine.php and 1 other location - About 2 hrs to fix
                        Coroutine/Coroutine.php on lines 1066..1080

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

                        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 function addWriter($stream, $task, bool $addEvent = true): CoroutineInterface
                          {
                            $already = true;
                            if (isset($this->waitingForWrite[(int) $stream])) {
                              $already = false;
                        Severity: Major
                        Found in Coroutine/Coroutine.php and 1 other location - About 2 hrs to fix
                        Coroutine/Coroutine.php on lines 1050..1064

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

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

                          protected function removeWriteEvent($stream)
                          {
                            if (!isset($this->events[(int) $stream])) {
                              return;
                            }
                        Severity: Major
                        Found in Coroutine/Coroutine.php and 1 other location - About 1 hr to fix
                        Coroutine/Coroutine.php on lines 359..377

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

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

                          protected function removeReadEvent($stream)
                          {
                            if (!isset($this->events[(int) $stream])) {
                              return;
                            }
                        Severity: Major
                        Found in Coroutine/Coroutine.php and 1 other location - About 1 hr to fix
                        Coroutine/Coroutine.php on lines 379..397

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

                        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