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

View on GitHub

Showing 397 of 397 total issues

The method validateEnum() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
Open

    private function validateEnum(PropertyInterface $property): bool
    {
        $throw = function (string $message) use ($property): void {
            throw new SchemaException(
                sprintf(

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

The method process() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
Open

    public function process(
        PropertyInterface $property,
        $filterList,
        GeneratorConfiguration $generatorConfiguration,
        Schema $schema,

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

Avoid using PHPModelGenerator\Utils\count() function in for loops.
Open

        for ($i = 0; $i < count($schema->getMethods()); $i++) {
            $renderedMethods .= $schema->getMethods()[array_keys($schema->getMethods())[$i]]->getCode() . "\n\n";
        }
Severity: Minor
Found in src/Utils/RenderHelper.php by phpmd

CountInLoopExpression

Since: 2.7.0

Using count/sizeof in loops expressions is considered bad practice and is a potential source of many bugs, especially when the loop manipulates an array, as count happens on each iteration.

Example

class Foo {

  public function bar()
  {
    $array = array();

    for ($i = 0; count($array); $i++) {
      // ...
    }
  }
}

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

Arguments with default values must be at the end of the argument list
Open

        bool $initialClass = false,

Arguments with default values must be at the end of the argument list
Open

        bool $skipNonMappedEnums = false,

Line exceeds 120 characters; contains 121 characters
Open

                                    'Applying multiple transforming filters for property %s is not supported in file %s',

Arguments with default values must be at the end of the argument list
Open

        array $templateValues = [],

Line exceeds 120 characters; contains 150 characters
Open

        if (isset($json['$ref']) && count(array_diff(array_intersect(array_keys($json), self::SCHEMA_SIGNATURE_RELEVANT_FIELDS), ['$ref', 'type']))) {

Arguments with default values must be at the end of the argument list
Open

        bool $reset = false,

Arguments with default values must be at the end of the argument list
Open

        bool $reset = false,

Line exceeds 120 characters; contains 128 characters
Open

                => "array_key_exists('{$property->getName()}', \$modelData) && \$value !== " . var_export($json['const'], true),

Arguments with default values must be at the end of the argument list
Open

        string $type = '',

Line exceeds 120 characters; contains 145 characters
Open

                                    && ($modifiedValue = $nestedCompositionObject->$accessor()) !== ($originalModelData[$key] ?? !$modifiedValue)

Arguments with default values must be at the end of the argument list
Open

        bool $initialClass = false,
Severity: Minor
Found in src/Model/Schema.php by phpcodesniffer

Arguments with default values must be at the end of the argument list
Open

        bool $reset = false,

Arguments with default values must be at the end of the argument list
Open

        string $currentClassName = '',

Arguments with default values must be at the end of the argument list
Open

        string $currentClassName = '',

Line exceeds 120 characters; contains 142 characters
Open

        // TODO: provide better type hints. Currently provides e.g. "string|array[]" instead of "string|string[]" for a recursive string array

Arguments with default values must be at the end of the argument list
Open

        array $exceptionParams = [],

Arguments with default values must be at the end of the argument list
Open

        array $exceptionParams = [],
Severity
Category
Status
Source
Language