Rossmann-IT/yii2-cron

View on GitHub

Showing 14 of 84 total issues

Function onload has 89 lines of code (exceeds 25 allowed). Consider refactoring.
Open

window.onload = function () {

    // If pretty URLs are enabled ('urlManager' => ['enablePrettyUrl' => 'true'])
    // one can use relative URLs, so controller_url can be emtpy.
    // But when the index action is called implicitly (when no action is given in the URL)
Severity: Major
Found in src/assets/manager_actions.js - About 3 hrs to fix

    Task has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Task extends ActiveRecord implements TaskInterface {
    
        /**
         * @return array
         */
    Severity: Minor
    Found in src/models/Task.php - About 3 hrs to fix

      Function checkAndRunTasks has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function checkAndRunTasks($tasks)
          {
              $invocationTimestamp = time();
              $invocationDatetime = date('Y-m-d H:i:00');
      
      
      Severity: Minor
      Found in src/components/TaskRunner.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

      Method runTask has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function runTask($task)
          {
              $result = $task->acquireLock();
              if ($result) {
                  $run = $task->createTaskRun();
      Severity: Major
      Found in src/components/TaskRunner.php - About 2 hrs to fix

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

            public static function runTask($task)
            {
                $result = $task->acquireLock();
                if ($result) {
                    $run = $task->createTaskRun();
        Severity: Minor
        Found in src/components/TaskRunner.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 acquireLock has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function acquireLock() {
                if (!$this->id) {
                    throw new \LogicException('Task ID must be set to acquire a lock');
                }
                $db = \Yii::$app->getDb();
        Severity: Minor
        Found in src/models/Task.php - About 1 hr to fix

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

              public static function parseCrontab($cron, $taskClass)
              {
                  $cronArray = explode(PHP_EOL, $cron);
                  $tasks      = [];
                  foreach ($cronArray as $cronElement) {
          Severity: Minor
          Found in src/components/TaskManager.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 checkAndRunTasks has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function checkAndRunTasks($tasks)
              {
                  $invocationTimestamp = time();
                  $invocationDatetime = date('Y-m-d H:i:00');
          
          
          Severity: Minor
          Found in src/components/TaskRunner.php - About 1 hr to fix

            Method parseCrontab has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function parseCrontab($cron, $taskClass)
                {
                    $cronArray = explode(PHP_EOL, $cron);
                    $tasks      = [];
                    foreach ($cronArray as $cronElement) {
            Severity: Minor
            Found in src/components/TaskManager.php - About 1 hr to fix

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

                  protected static function getControllersList($paths, $namespacesList)
                  {
                      $controllers = [];
                      foreach ($paths as $pathIndex => $path) {
                          if (!file_exists($path)) {
              Severity: Minor
              Found in src/components/TaskLoader.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 acquireLock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function acquireLock() {
                      if (!$this->id) {
                          throw new \LogicException('Task ID must be set to acquire a lock');
                      }
                      $db = \Yii::$app->getDb();
              Severity: Minor
              Found in src/models/Task.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 editTask has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public static function editTask($task, $time, $command, $status = TaskInterface::TASK_STATUS_ACTIVE,
                                                  $comment = null)
              Severity: Minor
              Found in src/components/TaskManager.php - About 35 mins to fix

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

                    public static function loadController($className)
                    {
                        foreach (self::$classFolders as $f) {
                            $f        = rtrim($f, '/');
                            $filename = $f . '/' . $className . '.php';
                Severity: Minor
                Found in src/components/TaskLoader.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 parseCommand has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                    public static function parseCommand($command)
                    {
                        if (preg_match('/([@\w\\\\]+)::(\w+)\((.*)\)/', $command, $match)) {
                            $params = explode(',', $match[3]);
                            // trim params and strip quotes
                Severity: Minor
                Found in src/components/TaskManager.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

                Severity
                Category
                Status
                Source
                Language