EscolaLMS/Consultations

View on GitHub

Showing 1,241 of 1,241 total issues

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

    public function update(int $id, ConsultationDto $consultationDto): Consultation;

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 show(int $id): Consultation;

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 ConsultationController has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13.
Open

class ConsultationController extends EscolaLmsBaseController implements ConsultationSwagger
{
    private ConsultationServiceContract $consultationServiceContract;
    private UserServiceContract $userService;

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

The class ConsultationService has a coupling between objects value of 49. Consider to reduce the number of dependencies under 13.
Open

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

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

The class ConsultationAPIController has a coupling between objects value of 18. Consider to reduce the number of dependencies under 13.
Open

class ConsultationAPIController extends EscolaLmsBaseController implements ConsultationAPISwagger
{
    private ConsultationServiceContract $consultationServiceContract;

    public function __construct(

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

<?php

namespace EscolaLms\Consultations\Repositories\Criteria;

use EscolaLms\Core\Repositories\Criteria\Criterion;
Severity: Minor
Found in src/Repositories/Criteria/ConsultationTermEqualCriterion.php and 1 other location - About 40 mins to fix
src/Repositories/Criteria/UserTermConsultationCriterion.php on lines 1..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 93.

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

<?php

namespace EscolaLms\Consultations\Repositories\Criteria;

use EscolaLms\Core\Repositories\Criteria\Criterion;
Severity: Minor
Found in src/Repositories/Criteria/UserTermConsultationCriterion.php and 1 other location - About 40 mins to fix
src/Repositories/Criteria/ConsultationTermEqualCriterion.php on lines 1..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 93.

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

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

The closing brace for the class must go on the next line after the body
Open

}

Expected 1 space after USE keyword; found 0
Open

        ], 5)->create()->each(function (Consultation $consultation) use($users) {

The closing brace for the trait must go on the next line after the body
Open

}
Severity: Minor
Found in src/Dto/Traits/DtoHelper.php by phpcodesniffer

Expected 1 space after USE keyword; found 0
Open

        return DB::transaction(function () use($id) {

Expected 1 space after USE keyword; found 0
Open

        return DB::transaction(function () use($consultation, $consultationDto) {

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

Expected 1 blank line at end of file; 3 found
Open

}

The closing brace for the interface must go on the next line after the body
Open

}

Expected 1 space after USE keyword; found 0
Open

        return DB::transaction(function () use($consultationDto) {

There must be one blank line after the last USE statement; 2 found;
Open

use EscolaLms\Core\Models\User as CoreUser;
Severity: Minor
Found in src/Models/Consultation.php by phpcodesniffer

Expected 1 blank line at end of file; 2 found
Open

Route::post('api/consultations/save-screen', [ConsultationAPIController::class, 'screenSave']);
Severity: Minor
Found in src/routes.php by phpcodesniffer

The method toArray has a boolean flag argument $filters, which is a certain sign of a Single Responsibility Principle violation.
Open

    public function toArray($filters = false): array
Severity: Minor
Found in src/Dto/ConsultationDto.php by phpmd

BooleanArgumentFlag

Since: 1.4.0

A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

Example

class Foo {
    public function bar($flag = true) {
    }
}

Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

Severity
Category
Status
Source
Language