Rossmann-IT/yii2-cron

View on GitHub

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

      The class TasksController has 12 public methods. Consider refactoring TasksController to keep number of public methods under 10.
      Open

      class TasksController extends Controller {
          /** @var string */
          protected static $tasksControllersFolder;
      
          /** @var string */
      Severity: Minor
      Found in src/controllers/TasksController.php by phpmd

      TooManyPublicMethods

      Since: 0.1

      A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

      By default it ignores methods starting with 'get' or 'set'.

      Example

      Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

      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

        Avoid excessively long variable names like $tasksControllersFolder. Keep variable name length under 20.
        Open

            public $tasksControllersFolder = [];
        Severity: Minor
        Found in src/CronModule.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $tasksControllersFolder. Keep variable name length under 20.
        Open

            protected static $tasksControllersFolder;
        Severity: Minor
        Found in src/controllers/TasksController.php by phpmd

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        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

              The class m160712_111111_task_manager_init is not named in CamelCase.
              Open

              class m160712_111111_task_manager_init extends Migration {
              
                  /**
                   * for Oracle you need to overwrite the typeMap in \yii\db\oci\QueryBuilder
                   * to get an equivalent for AUTO_INCREMENT, for example

              CamelCaseClassName

              Since: 0.2

              It is considered best practice to use the CamelCase notation to name classes.

              Example

              class class_name {
              }

              Source

              Avoid variables with short names like $db. Configured minimum length is 3.
              Open

                      $db = \Yii::$app->getDb();
              Severity: Minor
              Found in src/models/Task.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              Avoid variables with short names like $db. Configured minimum length is 3.
              Open

                      $db = (new Query())
              Severity: Minor
              Found in src/models/TaskRun.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              Avoid variables with short names like $id. Configured minimum length is 3.
              Open

                  public function __construct($id, $module, $config = []) {
              Severity: Minor
              Found in src/controllers/TasksController.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              Avoid variables with short names like $js. Configured minimum length is 3.
              Open

                  public $js = [
                      'manager_actions.js',
                  ];
              Severity: Minor
              Found in src/assets/TasksAsset.php by phpmd

              ShortVariable

              Since: 0.2

              Detects when a field, local, or parameter has a very short name.

              Example

              class Something {
                  private $q = 15; // VIOLATION - Field
                  public static function main( array $as ) { // VIOLATION - Formal
                      $r = 20 + $this->q; // VIOLATION - Local
                      for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                          $r += $this->q;
                      }
                  }
              }

              Source https://phpmd.org/rules/naming.html#shortvariable

              The class m160718_111111_task_manager is not named in CamelCase.
              Open

              class m160718_111111_task_manager extends Migration {
              
                  /**
                   * for Oracle you need to overwrite the typeMap in \yii\db\oci\QueryBuilder
                   * to get an equivalent for AUTO_INCREMENT, for example

              CamelCaseClassName

              Since: 0.2

              It is considered best practice to use the CamelCase notation to name classes.

              Example

              class class_name {
              }

              Source

              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

              Severity
              Category
              Status
              Source
              Language