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

View on GitHub

Showing 529 of 529 total issues

Function process has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    public function process(
        PropertyInterface $property,
        mixed $filterList,
        GeneratorConfiguration $generatorConfiguration,
        Schema $schema,
Severity: Minor
Found in src/PropertyProcessor/Filter/FilterProcessor.php - About 4 hrs 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

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

    protected function addLengthValidator(PropertyInterface $property, JsonSchema $propertySchema): void
    {
        $json = $propertySchema->getJson();

        if (isset($json[static::JSON_FIELD_MIN_LENGTH])) {
Severity: Major
Found in src/PropertyProcessor/Property/StringProcessor.php and 1 other location - About 4 hrs to fix
src/PropertyProcessor/Property/ArrayProcessor.php on lines 82..107

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

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

    private function addLengthValidation(PropertyInterface $property, JsonSchema $propertySchema): void
    {
        $json = $propertySchema->getJson();

        if (isset($json[self::JSON_FIELD_MIN_ITEMS])) {
Severity: Major
Found in src/PropertyProcessor/Property/ArrayProcessor.php and 1 other location - About 4 hrs to fix
src/PropertyProcessor/Property/StringProcessor.php on lines 83..108

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

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

    protected function transferPatternPropertiesFilterToProperty(
        Schema $schema,
        GeneratorConfiguration $generatorConfiguration,
    ): void {
        $patternPropertiesValidators = array_filter(

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

GeneratorConfiguration has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class GeneratorConfiguration
{
    /** @var string */
    protected $namespacePrefix = '';
    /** @var bool */
Severity: Minor
Found in src/Model/GeneratorConfiguration.php - About 3 hrs to fix

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

        public function process(
            PropertyInterface $property,
            mixed $filterList,
            GeneratorConfiguration $generatorConfiguration,
            Schema $schema,
    Severity: Major
    Found in src/PropertyProcessor/Filter/FilterProcessor.php - About 3 hrs to fix

      PropertyProxy has 25 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class PropertyProxy extends AbstractProperty
      {
          /**
           * PropertyProxy constructor.
           *
      Severity: Minor
      Found in src/Model/Property/PropertyProxy.php - About 2 hrs to fix

        Schema has 24 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Schema
        {
            use JsonSchemaTrait;
        
            /** @var string */
        Severity: Minor
        Found in src/Model/Schema.php - About 2 hrs to fix

          Property has 23 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Property extends AbstractProperty
          {
              /** @var PropertyType|null */
              protected $outputType;
              /** @var bool */
          Severity: Minor
          Found in src/Model/Property/Property.php - About 2 hrs to fix

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

                public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
                {
                    $generatorConfiguration->addFilter(new EnumFilter());
            
                    foreach ($schema->getProperties() as $property) {
            Severity: Major
            Found in src/SchemaProcessor/PostProcessor/EnumPostProcessor.php - About 2 hrs to fix

              Method transferPatternPropertiesFilterToProperty has 58 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function transferPatternPropertiesFilterToProperty(
                      Schema $schema,
                      GeneratorConfiguration $generatorConfiguration,
                  ): void {
                      $patternPropertiesValidators = array_filter(

                Function addSerializeFunctionsForTransformingFilters has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                    private function addSerializeFunctionsForTransformingFilters(
                        Schema $schema,
                        GeneratorConfiguration $generatorConfiguration,
                    ): void {
                        foreach ($schema->getProperties() as $property) {

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

                    private function addSerializeFunctionsForTransformingFilters(
                        Schema $schema,
                        GeneratorConfiguration $generatorConfiguration,
                    ): void {
                        foreach ($schema->getProperties() as $property) {

                  Method generateValidators has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
                      {
                          $json = $propertySchema->getJson()['propertySchema']->getJson();
                  
                          if (!isset($json['then']) && !isset($json['else'])) {
                  Severity: Major
                  Found in src/PropertyProcessor/ComposedValue/IfProcessor.php - About 2 hrs to fix

                    Method generateValidators has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function generateValidators(PropertyInterface $property, JsonSchema $propertySchema): void
                        {
                            $json = $propertySchema->getJson()['propertySchema']->getJson();
                    
                            if (empty($json[$propertySchema->getJson()['type']]) &&

                      Method createMergedProperty has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function createMergedProperty(
                              Schema $schema,
                              PropertyInterface $property,
                              array $compositionProperties,
                              JsonSchema $propertySchema,
                      Severity: Minor
                      Found in src/SchemaProcessor/SchemaProcessor.php - About 1 hr to fix

                        Method getCheck has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function getCheck(): string
                            {
                                /**
                                 * Add a method to the schema to gather values from a nested object which are modified.
                                 * This is required to adopt filter changes to the values which are passed into a merged property
                        Severity: Minor
                        Found in src/Model/Validator/ComposedPropertyValidator.php - About 1 hr to fix

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

                              private function generateValidatorPropertyMap(Schema $schema): 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

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

                              public function process(Schema $schema, GeneratorConfiguration $generatorConfiguration): void
                              {
                                  $generatorConfiguration->addFilter(new EnumFilter());
                          
                                  foreach ($schema->getProperties() as $property) {
                          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

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

                          class ExtendObjectPropertiesMatchingPatternPropertiesPostProcessor extends PostProcessor
                          {
                              /**
                               * @throws SchemaException
                               */

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language