VSVverkeerskunde/gvq-api

View on GitHub

Showing 1,426 of 1,426 total issues

The method sendKickOffMailAfterLaunch uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $documentPath = $this->projectDir . '/public/documents/nl/'.$documentName;
        }
Severity: Minor
Found in src/Mail/Service/SwiftMailService.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\Swift_Attachment' in method 'sendKickOffMailAfterLaunch'.
Open

        $message->attach(Swift_Attachment::fromPath($documentPath));
Severity: Minor
Found in src/Mail/Service/SwiftMailService.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method buildForm() has an NPath complexity of 32768. The configured NPath complexity threshold is 200.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        /** @var Category[] $categories */
        $categories = $options['categories']->toArray();
        /** @var Language[] $languages */

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

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

Avoid using static access to class '\Symfony\Component\Yaml\Yaml' in method 'getFiles'.
Open

        return Yaml::parseFile($this->configFilePath);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method getKickOffDocumentName uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            return 'Briefing voor bedrijven 2021.pdf';
        }
Severity: Minor
Found in src/Mail/Service/SwiftMailService.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\Ramsey\Uuid\Uuid' in method 'denormalize'.
Open

            Uuid::fromString($data['id']),

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Ramsey\Uuid\Uuid' in method 'answerQuestion'.
Open

            $answer = $this->answerRepository->getById(Uuid::fromString($answerId));

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Ramsey\Uuid\Uuid' in method 'createCurrentQuestionResponse'.
Open

            Uuid::fromString($quizId)

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method __construct has 10 parameters. Consider reducing the number of parameters to less than 10.
Open

    private function __construct(
        string $id,
        string $language,
        int $year,
        CategoryEntity $categoryEntity,

The method answerQuestion uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->apply(
                    new AnsweredCorrect(
                        $this->quiz->getId(),
                        $currentQuestion,
Severity: Minor
Found in src/Quiz/Aggregate/QuizAggregate.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method answerQuestion uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $answer = $this->answerRepository->getById(Uuid::fromString($answerId));
            if (null === $answer) {
                throw new \InvalidArgumentException(
                    'No answer with id "'.$answerId.'"'

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\Ramsey\Uuid\Uuid' in method 'denormalize'.
Open

            Uuid::fromString($data['id']),

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method getAll uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $json = $this->serializer->serialize($categories, 'json');
            $response = new Response($json);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method sortByNewest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                } else {
                    return 0;
                }
Severity: Minor
Found in src/Question/Models/Questions.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method buildForm() has 144 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        /** @var Category[] $categories */
        $categories = $options['categories']->toArray();
        /** @var Language[] $languages */

Avoid using static access to class '\VSV\GVQ_API\Question\Repositories\Entities\QuestionEntity' in method 'update'.
Open

        $newQuestionEntity = QuestionEntity::fromQuestion($question);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method getAll uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $questionsAsJson = $this->serializer->serialize($questions, 'json');
            $response = new Response($questionsAsJson);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method showQuiz uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $channel = $request->get('channel') === 'league' ? 'league' : 'quiz';

            return $this->render(
                'quiz/quiz-placeholder.html.twig',

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method canPlayQuiz uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $authChecker = $this->get('security.authorization_checker');

            $allowedRoles = ['ROLE_ADMIN', 'ROLE_VSV', 'ROLE_TEST'];

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method __construct has 10 parameters. Consider reducing the number of parameters to less than 10.
Open

    public function __construct(
        Year $year,
        UserRepository $userRepository,
        CompanyRepository $companyRepository,
        DashboardService $dashboardService,
Severity
Category
Status
Source
Language