Mirocow/yii2-queue

View on GitHub

Showing 23 of 23 total issues

File QueueComponent.php has 361 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace mirocow\queue\components;

use Amp\Loop;
Severity: Minor
Found in components/QueueComponent.php - About 4 hrs to fix

    Function pop has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

        public function pop(string $queueName)
        {
            // Move delayed messages into waiting
            if ($this->now < time()) {
                $this->now = time();
    Severity: Minor
    Found in drivers/RedisConnection.php - About 3 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 run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public function run()
        {
            /** @var MessageModel $message */
            $message = $this->getMessage();
            $actionClassName = $this::$actionClassName;
    Severity: Minor
    Found in components/WorkerComponent.php - About 3 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

    QueueComponent has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class QueueComponent extends \yii\base\Component implements \mirocow\queue\interfaces\QueueInterface
    {
    
        /**
         * Version.
    Severity: Minor
    Found in components/QueueComponent.php - About 2 hrs to fix

      Function argumentsValidate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          private function argumentsValidate($class, $method, $arguments)
          {
              if (isset($this->_validClassMethods[$class]) && isset($this->_validClassMethods[$class][$method])) {
                  $refFunc = $this->_validClassMethods[$class][$method];
                  $userArguments = array_keys($arguments);
      Severity: Minor
      Found in components/WorkerComponent.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 run has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function run($channelName = null, $watcherId = null)
          {
              if (!$channelName) {
                  $channels = $this->getChannelNamesList();
              } else {
      Severity: Minor
      Found in components/QueueComponent.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 child has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function child($message = [], $watcherId, ChannelComponent $channel)
          {
              if ($this->multithreading) {
                  $pid = pcntl_fork();
              } else {
      Severity: Minor
      Found in components/QueueComponent.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 push has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function push(string $payload, string $queueName, $delay = 0, $priority = NULL)
          {
              if ($priority !== null) {
                  throw new NotSupportedException('Job priority is not supported in the driver.');
              }
      Severity: Minor
      Found in drivers/FileConnection.php - About 1 hr to fix

        Method delete has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function delete(string $queueName, int $id = null)
            {
                $removed = false;
                $this->touchIndex($queueName, function (&$data) use ($queueName, $id, &$removed) {
                    if (!empty($data['waiting'])) {
        Severity: Minor
        Found in drivers/FileConnection.php - About 1 hr to fix

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

              private function argumentsValidate($class, $method, $arguments)
              {
                  if (isset($this->_validClassMethods[$class]) && isset($this->_validClassMethods[$class][$method])) {
                      $refFunc = $this->_validClassMethods[$class][$method];
                      $userArguments = array_keys($arguments);
          Severity: Minor
          Found in components/WorkerComponent.php - About 1 hr to fix

            Method run has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function run($channelName = null, $watcherId = null)
                {
                    if (!$channelName) {
                        $channels = $this->getChannelNamesList();
                    } else {
            Severity: Minor
            Found in components/QueueComponent.php - About 1 hr to fix

              Method pop has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function pop(string $queueName)
                  {
                      $id = null;
                      $ttr = null;
                      $attempt = null;
              Severity: Minor
              Found in drivers/FileConnection.php - About 1 hr to fix

                Method touchIndex has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function touchIndex($queueName, $callback)
                    {
                        $fileName = "$this->path/queue__{$queueName}.data";
                        $isNew = !file_exists($fileName);
                
                
                Severity: Minor
                Found in drivers/FileConnection.php - About 1 hr to fix

                  Method run has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function run()
                      {
                          /** @var MessageModel $message */
                          $message = $this->getMessage();
                          $actionClassName = $this::$actionClassName;
                  Severity: Minor
                  Found in components/WorkerComponent.php - About 1 hr to fix

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

                        public function init()
                        {
                            parent::init();
                    
                            self::$_daemonize = $this->daemonize;
                    Severity: Minor
                    Found in components/QueueComponent.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 status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function status(string $queueName, $id = null){
                            if($id) {
                                if (!is_numeric($id) || $id <= 0) {
                                    throw new InvalidParamException("Unknown messages ID: $id.");
                                }
                    Severity: Minor
                    Found in drivers/RedisConnection.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 daemonize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected static function daemonize()
                        {
                            if (!static::$_daemonize || static::$_OS !== self::OS_TYPE_LINUX) {
                                return;
                            }
                    Severity: Minor
                    Found in components/QueueComponent.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 processMessage has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function processMessage(MessageModel $messageModel, $watcherId = null, $pid)
                        {
                            /** @var WorkerComponent $worker */
                            if ($worker = $this->getWorker($messageModel->worker)) {
                                pcntl_signal_dispatch();
                    Severity: Minor
                    Found in components/QueueComponent.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 0;
                    Severity: Major
                    Found in drivers/FileConnection.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                              return $id;
                      Severity: Major
                      Found in drivers/FileConnection.php - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language