Showing 28 of 452 total issues

File EventService.php has 286 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
 
namespace jmp\Services;
 
 
 
Severity: Minor
Found in api/src/jmp/Services/EventService.php - About 2 hrs to fix

    Method createRegistration has 53 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    public function createRegistration(Request $request, Response $response): Response
    {
    // Parse input
    $parsedBody = $request->getParsedBody();
    $registration = new Registration($parsedBody);
    Severity: Major
    Found in api/src/jmp/Controllers/RegistrationController.php - About 2 hrs to fix

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

      public function createRegistration(Request $request, Response $response): Response
      {
      // Parse input
      $parsedBody = $request->getParsedBody();
      $registration = new Registration($parsedBody);
      Severity: Minor
      Found in api/src/jmp/Controllers/RegistrationController.php - About 2 hrs to fix

      Method updateRegistration has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      public function updateRegistration(Request $request, Response $response, $args): Response
      {
      $eventId = $args['eventId'];
      $userId = $args['userId'];
      $newRegistrationState = $request->getParsedBodyParam('registrationState');
      Severity: Minor
      Found in api/src/jmp/Controllers/RegistrationController.php - About 1 hr to fix

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

        public function getEventsByGroupAndEventTypeWithPagination(?int $groupId, ?int $eventTypeId, int $limit, bool $getAll, bool $getElapsed, User $user, int $offset = 0): array
        {
        $sql = <<< SQL
        SELECT DISTINCT event.id,
        event.title,
        Severity: Minor
        Found in api/src/jmp/Services/EventService.php - About 1 hr to fix

          Method getUpdatedUser has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          private function getUpdatedUser(array $userUpdates, User $currentUser): User
          {
          $username = $userUpdates['username'];
          $lastname = $userUpdates['lastname'];
          $firstname = $userUpdates['firstname'];
          Severity: Minor
          Found in api/src/jmp/Services/UserService.php - About 1 hr to fix

            Method getEventById has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            public function getEventById(int $eventId)
            {
            $sql = <<< SQL
            SELECT event.id,
            event.title,
            Severity: Minor
            Found in api/src/jmp/Services/EventService.php - About 1 hr to fix

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

              public function createPresence(Request $request, Response $response): Response
              {
              $presence = new Presence($request->getParsedBody());
               
              // Validation of user id's
              Severity: Minor
              Found in api/src/jmp/Controllers/PresenceController.php - About 1 hr to fix

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

                public function getEventsByGroupAndEventType(?int $groupId, ?int $eventTypeId, bool $getAll, bool $getElapsed, User $user): array
                {
                $sql = <<< SQL
                SELECT DISTINCT event.id,
                event.title,
                Severity: Minor
                Found in api/src/jmp/Services/EventService.php - About 1 hr to fix

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

                  public function updateRegistration(Request $request, Response $response, $args): Response
                  {
                  $eventId = $args['eventId'];
                  $userId = $args['userId'];
                  $newRegistrationState = $request->getParsedBodyParam('registrationState');
                  Severity: Minor
                  Found in api/src/jmp/Controllers/RegistrationController.php - About 1 hr to fix

                  Method updateUser has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  public function updateUser(int $id, array $updates): Optional
                  {
                  $optional = $this->getFullUserByUserId($id);
                  if ($optional->isFailure()) {
                  return Optional::failure();
                  Severity: Minor
                  Found in api/src/jmp/Services/UserService.php - About 1 hr to fix

                    Method getRegistrationByUserIdAndEventId has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    public function getRegistrationByUserIdAndEventId(int $userId, int $eventId): Optional
                    {
                    $sql = <<< SQL
                    SELECT DISTINCT registration.event_id as eventId,
                    registration.user_id as userId,
                    Severity: Minor
                    Found in api/src/jmp/Services/RegistrationService.php - About 1 hr to fix

                      Method getEventsByGroupAndEventTypeWithPagination has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      public function getEventsByGroupAndEventTypeWithPagination(?int $groupId, ?int $eventTypeId, int $limit, bool $getAll, bool $getElapsed, User $user, int $offset = 0): array
                      Severity: Major
                      Found in api/src/jmp/Services/EventService.php - About 50 mins to fix

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

                        public function listEvents(Request $request, Response $response): Response
                        {
                        if ((bool)$this->user->isAdmin !== true && isset($request->getQueryParams()['all']) === true) {
                        return $response->withStatus(403);
                        }
                        Severity: Minor
                        Found in api/src/jmp/Controllers/EventsController.php - About 45 mins to fix

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

                        public function deleteRegistration(Request $request, Response $response, $args): Response
                        {
                        $eventId = $args['eventId'];
                        $userId = $args['userId'];
                         
                         
                        Severity: Minor
                        Found in api/src/jmp/Controllers/RegistrationController.php - About 45 mins to fix

                        Method getEventByGroupAndEventWithOffset has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        public function getEventByGroupAndEventWithOffset(int $groupId, int $eventTypeId, bool $getAll, bool $getElapsed, User $user, int $offset = 0): array
                        Severity: Minor
                        Found in api/src/jmp/Services/EventService.php - About 45 mins to fix

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

                          public function getEventsByGroupAndEventType(?int $groupId, ?int $eventTypeId, bool $getAll, bool $getElapsed, User $user): array
                          Severity: Minor
                          Found in api/src/jmp/Services/EventService.php - About 35 mins to fix

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

                            private function getUpdatedUser(array $userUpdates, User $currentUser): User
                            {
                            $username = $userUpdates['username'];
                            $lastname = $userUpdates['lastname'];
                            $firstname = $userUpdates['firstname'];
                            Severity: Minor
                            Found in api/src/jmp/Services/UserService.php - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                            return $this->getBadRequestResponseWithKey($response, 'reason', $message);
                            Severity: Major
                            Found in api/src/jmp/Controllers/RegistrationController.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                              return Optional::failure();
                              Severity: Major
                              Found in api/src/jmp/Services/EventService.php - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language