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

View on GitHub

Showing 77 of 387 total issues

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

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

                                  public function __construct(
                                      SchemaProcessor $schemaProcessor,
                                      Schema $schema,
                                      JsonSchema $itemStructure,
                                      PropertyInterface $property,
                              Severity: Minor
                              Found in src/Model/Validator/ArrayItemValidator.php - About 1 hr to fix

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

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

                                  Function addAdditionalPropertiesSerialization has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                  Open

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

                                  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

                                  Function validateEnum has a Cognitive Complexity of 10 (exceeds 5 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

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

                                      protected function addComposedValueValidator(PropertyInterface $property, JsonSchema $propertySchema): void
                                      {
                                          $composedValueKeywords = ['allOf', 'anyOf', 'oneOf', 'not', 'if'];
                                          $propertyFactory = new PropertyFactory(new ComposedValueProcessorFactory($property instanceof BaseProperty));
                                  
                                  
                                  Severity: Minor
                                  Found in src/PropertyProcessor/Property/AbstractPropertyProcessor.php - About 1 hr to fix

                                    Method addSetAdditionalPropertyMethod has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                        private function addSetAdditionalPropertyMethod(
                                            Schema $schema,
                                            GeneratorConfiguration $generatorConfiguration,
                                            ?PropertyInterface $validationProperty,
                                        ): void {
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language