EscolaLMS/Consultations

View on GitHub

Showing 1,278 of 1,278 total issues

File ConsultationService.php has 561 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function rejectTerm(int $consultationTermId, ConsultationUserTermDto $dto): bool
        {
            /** @var ConsultationUserPivot $consultationTerm */
            $consultationTerm = $this->consultationUserRepositoryContract->find($consultationTermId);
    
    
    Severity: Major
    Found in src/Services/ConsultationService.php and 1 other location - About 6 hrs to fix
    src/Services/ConsultationService.php on lines 173..195

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 220.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        public function approveTerm(int $consultationTermId, ConsultationUserTermDto $dto): bool
        {
            /** @var ConsultationUserPivot $consultationTerm */
            $consultationTerm = $this->consultationUserRepositoryContract->find($consultationTermId);
    
    
    Severity: Major
    Found in src/Services/ConsultationService.php and 1 other location - About 6 hrs to fix
    src/Services/ConsultationService.php on lines 197..219

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 220.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    ConsultationService has 38 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 5 hrs to fix

      The class ConsultationAPIController has 13 public methods. Consider refactoring ConsultationAPIController to keep number of public methods under 10.
      Open

      class ConsultationAPIController extends EscolaLmsBaseController implements ConsultationAPISwagger
      {
          private ConsultationServiceContract $consultationServiceContract;
      
          public function __construct(

      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

      The class ConsultationService has an overall complexity of 85 which is very high. The configured complexity threshold is 50.
      Open

      class ConsultationService implements ConsultationServiceContract
      {
          private ConsultationRepositoryContract $consultationRepositoryContract;
          private ConsultationUserRepositoryContract $consultationUserRepositoryContract;
          private JitsiServiceContract $jitsiServiceContract;
      Severity: Minor
      Found in src/Services/ConsultationService.php by phpmd

      The class ConsultationService has 26 non-getter- and setter-methods. Consider refactoring ConsultationService to keep number of methods under 25.
      Open

      class ConsultationService implements ConsultationServiceContract
      {
          private ConsultationRepositoryContract $consultationRepositoryContract;
          private ConsultationUserRepositoryContract $consultationUserRepositoryContract;
          private JitsiServiceContract $jitsiServiceContract;
      Severity: Minor
      Found in src/Services/ConsultationService.php by phpmd

      TooManyMethods

      Since: 0.1

      A class with too many 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'.

      The default was changed from 10 to 25 in PHPMD 2.3.

      Example

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

      The class ConsultationService has 26 public methods. Consider refactoring ConsultationService to keep number of public methods under 10.
      Open

      class ConsultationService implements ConsultationServiceContract
      {
          private ConsultationRepositoryContract $consultationRepositoryContract;
          private ConsultationUserRepositoryContract $consultationUserRepositoryContract;
          private JitsiServiceContract $jitsiServiceContract;
      Severity: Minor
      Found in src/Services/ConsultationService.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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function up(): void
          {
              Schema::create('consultations_participants', function (Blueprint $table) {
                  $table->id();
                  $table->bigInteger('consultation_id')->unsigned()->index();
      database/migrations/2022_02_15_104923_remove_participant_table.php on lines 14..26

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 145.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

          public function down(): void
          {
              Schema::create('consultations_participants', function (Blueprint $table) {
                  $table->id();
                  $table->bigInteger('consultation_id')->unsigned()->index();
      database/migrations/2022_02_02_135907_create_consultations_participants_table.php on lines 10..22

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 145.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              Schema::create('consultation_terms', function (Blueprint $table) {
                  $table->id();
                  $table->bigInteger('user_id')->unsigned();
                  $table->bigInteger('order_item_id')->unsigned();
                  $table->dateTime('executed_at')->nullable();
      database/migrations/2022_02_10_075849_add_pivot_table_for_order_items_and_user.php on lines 20..31

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 141.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Identical blocks of code found in 2 locations. Consider refactoring.
      Open

              Schema::create('consultation_terms', function (Blueprint $table) {
                  $table->id();
                  $table->bigInteger('user_id')->unsigned();
                  $table->bigInteger('order_item_id')->unsigned();
                  $table->dateTime('executed_at')->nullable();
      database/migrations/2022_03_23_140827_change_columns_in_consultationuser_table.php on lines 33..44

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 141.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      FilterListDto has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class FilterListDto extends BaseDto
      {
          private string $name;
          private int $consultationTermId;
          private array $status;
      Severity: Minor
      Found in src/Dto/FilterListDto.php - About 2 hrs to fix

        Function canGenerateJitsi has a Cognitive Complexity of 19 (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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            public function index(ListConsultationsRequest $listConsultationsRequest): JsonResponse
            {
                $search = $listConsultationsRequest->except(['limit', 'skip']);
                $consultations = $this->consultationServiceContract
                    ->getConsultationsList($search, false, OrderDto::instantiateFromRequest($listConsultationsRequest))
        Severity: Major
        Found in src/Http/Controllers/ConsultationController.php and 1 other location - About 1 hr to fix
        src/Http/Controllers/ConsultationAPIController.php on lines 39..52

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            public function index(ListAPIConsultationsRequest $listConsultationsRequest): JsonResponse
            {
                $search = $listConsultationsRequest->except(['limit', 'skip']);
                $consultations = $this->consultationServiceContract
                    ->getConsultationsList($search, true, OrderDto::instantiateFromRequest($listConsultationsRequest))
        Severity: Major
        Found in src/Http/Controllers/ConsultationAPIController.php and 1 other location - About 1 hr to fix
        src/Http/Controllers/ConsultationController.php on lines 42..55

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 120.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method generateJitsi has 44 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

          Avoid excessively long class names like RemoveNotUsedColumnsFromConsultationsTable. Keep class name length under 40.
          Open

          class RemoveNotUsedColumnsFromConsultationsTable extends Migration
          {
              /**
               * Run the migrations.
               *

          LongClassName

          Since: 2.9

          Detects when classes or interfaces are declared with excessively long names.

          Example

          class ATooLongClassNameThatHintsAtADesignProblem {
          
          }
          
          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
          
          }

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

          Avoid excessively long class names like AddConsultationIdColumnForConsultationTermsTable. Keep class name length under 40.
          Open

          class AddConsultationIdColumnForConsultationTermsTable extends Migration
          {
              /**
               * Run the migrations.
               *

          LongClassName

          Since: 2.9

          Detects when classes or interfaces are declared with excessively long names.

          Example

          class ATooLongClassNameThatHintsAtADesignProblem {
          
          }
          
          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
          
          }

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

          Avoid excessively long class names like RemoveRedundantColumnsFromConsultationsTable. Keep class name length under 40.
          Open

          class RemoveRedundantColumnsFromConsultationsTable extends Migration
          {
          
              public function up(): void
              {

          LongClassName

          Since: 2.9

          Detects when classes or interfaces are declared with excessively long names.

          Example

          class ATooLongClassNameThatHintsAtADesignProblem {
          
          }
          
          interface ATooLongInterfaceNameThatHintsAtADesignProblem {
          
          }

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

          Severity
          Category
          Status
          Source
          Language