wol-soft/php-json-schema-model-generator

View on GitHub
src/SchemaProcessor/PostProcessor/Internal/CompositionValidationPostProcessor.php

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

Function generateValidatorPropertyMap has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    private function generateValidatorPropertyMap(Schema $schema, GeneratorConfiguration $generatorConfiguration): array
    {
        $validatorPropertyMap = [];

        // get all base validators which are composed value validators and set up a map of affected object properties

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 generateValidatorPropertyMap has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function generateValidatorPropertyMap(Schema $schema, GeneratorConfiguration $generatorConfiguration): array
    {
        $validatorPropertyMap = [];

        // get all base validators which are composed value validators and set up a map of affected object properties

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

                public function getCode(PropertyInterface $property, bool $batchUpdate = false): string

    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

    Avoid unused parameters such as '$generatorConfiguration'.
    Open

        private function generateValidatorPropertyMap(Schema $schema, GeneratorConfiguration $generatorConfiguration): array

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    Avoid unused parameters such as '$batchUpdate'.
    Open

                public function getCode(PropertyInterface $property, bool $batchUpdate = false): string

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

    Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

    syntax error, unexpected ')'
    Open

                    ))

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            },

    Line indented incorrectly; expected 16 spaces, found 24
    Open

                            static function (int $validatorIndex): string {

    There are no issues that match your filters.

    Category
    Status