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

View on GitHub

Showing 387 of 387 total issues

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

class ExtendObjectPropertiesMatchingPatternPropertiesPostProcessor extends PostProcessor
{
    /**
     * @param Schema $schema
     * @param GeneratorConfiguration $generatorConfiguration

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

Method addAdditionalPropertiesSerialization has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function addAdditionalPropertiesSerialization(
        Schema $schema,
        GeneratorConfiguration $generatorConfiguration,
    ): void {
        $validationProperty = null;

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

        protected function addMaxPropertiesValidator(string $propertyName, JsonSchema $propertySchema): void
        {
            $json = $propertySchema->getJson();
    
            if (!isset($json['maxProperties'])) {
    Severity: Major
    Found in src/PropertyProcessor/Property/BaseProcessor.php and 1 other location - About 1 hr to fix
    src/PropertyProcessor/Property/BaseProcessor.php on lines 228..248

    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 113.

    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

        protected function addMinPropertiesValidator(string $propertyName, JsonSchema $propertySchema): void
        {
            $json = $propertySchema->getJson();
    
            if (!isset($json['minProperties'])) {
    Severity: Major
    Found in src/PropertyProcessor/Property/BaseProcessor.php and 1 other location - About 1 hr to fix
    src/PropertyProcessor/Property/BaseProcessor.php on lines 198..218

    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 113.

    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 process has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
        {
            $json = $schema->getJsonSchema()->getJson();
    
            if ((!$this->addForModelsWithoutAdditionalPropertiesDefinition && !isset($json['additionalProperties']))

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

        public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
        {
            $property = parent::process($propertyName, $propertySchema);
    
            $className = $this->schemaProcessor->getGeneratorConfiguration()->getClassNameGenerator()->getClassName(
    Severity: Minor
    Found in src/PropertyProcessor/Property/ObjectProcessor.php - About 1 hr to fix

      Method resolveReference has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function resolveReference(
              string $propertyName,
              array $path,
              PropertyMetaDataCollection $propertyMetaDataCollection,
          ): PropertyInterface {
      Severity: Minor
      Found in src/Model/SchemaDefinition/SchemaDefinition.php - About 1 hr to fix

        Method transferComposedPropertiesToSchema has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function transferComposedPropertiesToSchema(PropertyInterface $property): void
            {
                foreach ($property->getValidators() as $validator) {
                    $validator = $validator->getValidator();
        
        
        Severity: Minor
        Found in src/PropertyProcessor/Property/BaseProcessor.php - About 1 hr to fix

          Method process has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function process(string $propertyName, JsonSchema $propertySchema): PropertyInterface
              {
                  $property = parent::process($propertyName, $propertySchema);
          
                  $property->onResolve(function () use ($property, $propertyName, $propertySchema): void {
          Severity: Minor
          Found in src/PropertyProcessor/Property/MultiTypeProcessor.php - About 1 hr to fix

            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

              Method process has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
                  {
                      $json = $schema->getJsonSchema()->getJson();
              
                      if (!isset($json['patternProperties'])) {

                Method validateEnum has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private function validateEnum(PropertyInterface $property): bool
                    {
                        $throw = function (string $message) use ($property): void {
                            throw new SchemaException(
                                sprintf(
                Severity: Minor
                Found in src/SchemaProcessor/PostProcessor/EnumPostProcessor.php - About 1 hr to fix

                  Method renderEnum has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function renderEnum(
                          GeneratorConfiguration $generatorConfiguration,
                          JsonSchema $jsonSchema,
                          string $name,
                          array $values,
                  Severity: Minor
                  Found in src/SchemaProcessor/PostProcessor/EnumPostProcessor.php - About 1 hr to fix

                    Method __construct has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function __construct(
                            GeneratorConfiguration $generatorConfiguration,
                            FilterInterface $filter,
                            PropertyInterface $property,
                            array $filterOptions = [],
                    Severity: Minor
                    Found in src/Model/Validator/FilterValidator.php - About 1 hr to fix

                      Method processSubProperties has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function processSubProperties(
                              string $propertyName,
                              JsonSchema $propertySchema,
                              PropertyInterface $property,
                          ): array {
                      Severity: Minor
                      Found in src/PropertyProcessor/Property/MultiTypeProcessor.php - About 1 hr to fix

                        Method process has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
                            {
                                $this->transferPatternPropertiesFilterToProperty($schema, $generatorConfiguration);
                        
                                $schema->addSchemaHook(

                          Method addUpdateAdditionalProperties has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private function addUpdateAdditionalProperties(Schema $schema): void
                              {
                                  $schema->addBaseValidator(
                                      new class ($schema) extends PropertyTemplateValidator {
                                          public function __construct(Schema $schema)

                            Method getCompositionProperties has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                protected function getCompositionProperties(PropertyInterface $property, JsonSchema $propertySchema): array
                                {
                                    $propertyFactory = new PropertyFactory(new PropertyProcessorFactory());
                                    $compositionProperties = [];
                                    $json = $propertySchema->getJson()['propertySchema']->getJson();

                              Method __construct has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function __construct(
                                      SchemaProcessor $schemaProcessor,
                                      Schema $schema,
                                      JsonSchema $propertiesStructure,
                                      ?string $propertyName = null,
                              Severity: Minor
                              Found in src/Model/Validator/AdditionalPropertiesValidator.php - About 1 hr to fix

                                Method getTypeHint has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    public function getTypeHint(bool $outputType = false, array $skipDecorators = []): string
                                    {
                                        if (isset($this->renderedTypeHints[$outputType])) {
                                            return $this->renderedTypeHints[$outputType];
                                        }
                                Severity: Minor
                                Found in src/Model/Property/Property.php - About 1 hr to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language