EscolaLMS/Consultations

View on GitHub

Showing 16 of 1,241 total issues

File ConsultationService.php has 521 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace EscolaLms\Consultations\Services;

use Auth;
Severity: Major
Found in src/Services/ConsultationService.php - About 1 day to fix

    ConsultationService has 37 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class ConsultationService implements ConsultationServiceContract
    {
        private ConsultationRepositoryContract $consultationRepositoryContract;
        private ConsultationUserRepositoryContract $consultationUserRepositoryContract;
        private JitsiServiceContract $jitsiServiceContract;
    Severity: Minor
    Found in src/Services/ConsultationService.php - About 4 hrs to fix

      Function canGenerateJitsi has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          public function canGenerateJitsi(?string $executedAt, ?string $status, ?string $duration, ?Consultation $consultation = null): bool
          {
              $now = now();
              if (isset($executedAt)) {
                  $dateTo = Carbon::make($executedAt);
      Severity: Minor
      Found in src/Services/ConsultationService.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 generateJitsi has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function generateJitsi(int $consultationTermId, ConsultationUserTermDto $dto): array
          {
              /** @var ConsultationUserPivot $consultationTerm */
              $consultationTerm = $this->consultationUserRepositoryContract->find($consultationTermId);
              /** @var ConsultationUserTerm $term */
      Severity: Minor
      Found in src/Services/ConsultationService.php - About 1 hr to fix

        Method forCurrentUserResponse has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function forCurrentUserResponse(
                ListConsultationsRequest $listConsultationsRequest
            ): AnonymousResourceCollection {
                $search = $listConsultationsRequest->except(['limit', 'skip', 'order', 'order_by', 'paginate']);
                $consultations = $this->getConsultationsListForCurrentUser($search);
        Severity: Minor
        Found in src/Services/ConsultationService.php - About 1 hr to fix

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

              public function getByCurrentUserTutor(): Collection
              {
                  $result = collect();
                  $terms = $this->model->newQuery()
                      ->whereHas('consultationUser', fn (Builder $query) => $query
          Severity: Minor
          Found in src/Repositories/ConsultationUserTermRepository.php - About 1 hr to fix

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

                public function generateJitsiUrlForEmail(int $consultationTermId, int $userId, string $executedAt): ?string
                {
                    /** @var ConsultationUserPivot $consultationTerm */
                    $consultationTerm = $this->consultationUserRepositoryContract->find($consultationTermId);
                    /** @var ConsultationUserTerm $term */
            Severity: Minor
            Found in src/Services/ConsultationService.php - About 1 hr to fix

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

                  public static function prepareFilters(array $search)
                  {
                      $dto = new self($search);
                      $user = auth()->user();
              
              
              Severity: Minor
              Found in src/Dto/FilterListDto.php - About 1 hr to fix

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

                    public function toArray($request)
                    {
                        $consultationServiceContract = app(ConsultationServiceContract::class);
                
                        $consultation = $this->resource->consultationUser->consultation;
                Severity: Minor
                Found in src/Http/Resources/ConsultationUserTermsResource.php - About 1 hr to fix

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

                      public function run()
                      {
                          // create permissions
                          $admin = Role::findOrCreate(UserRole::ADMIN, 'api');
                          $tutor = Role::findOrCreate(UserRole::TUTOR, 'api');
                  Severity: Minor
                  Found in database/seeders/ConsultationsPermissionSeeder.php - About 1 hr to fix

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

                        public static function prepareFilters(array $search)
                        {
                            $dto = new self($search);
                            $user = auth()->user();
                    
                    
                    Severity: Minor
                    Found in src/Dto/FilterListDto.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 toArray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function toArray($request)
                        {
                            $consultationServiceContract = app(ConsultationServiceContract::class);
                            $fields = [
                                'consultation_term_id' => $this->resource->consultation_user_id,
                    Severity: Minor
                    Found in src/Http/Resources/ConsultationTermsResource.php - About 1 hr to fix

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

                          public function toArray($request)
                          {
                              return [
                                  'id' => $this->resource->id,
                                  'first_name' => $this->resource->firstName,
                      Severity: Minor
                      Found in src/Http/Resources/ConsultationUserResource.php - About 1 hr to fix

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

                            public function reminderAboutConsultation(string $reminderStatus): void
                            {
                                /** @var ConsultationUserTerm $userTerm */
                                foreach ($this->getReminderData($reminderStatus) as $userTerm) {
                                    event(new ReminderAboutTerm(
                        Severity: Minor
                        Found in src/Services/ConsultationService.php - About 1 hr to fix

                          Method __construct has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              public function __construct(int $consultation_user_id, int $consultation_id, string $executed_at, string $status, string $duration, ?User $author, ?string $finished_at = null, ?Collection $users = null)
                          Severity: Major
                          Found in src/Dto/ConsultationUserTermResourceDto.php - About 1 hr to fix

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

                                public static function prepareFilters(array $search): self
                                {
                                    $dto = new self($search);
                                    $dto->addToCriteria(new NotNullCriterion($dto->model()->getTable() . '.executed_at'));
                                    if ($dto->getStatus()) {
                            Severity: Minor
                            Found in src/Dto/FilterConsultationTermsListDto.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

                            Severity
                            Category
                            Status
                            Source
                            Language