gdbots/pbjc-php

View on GitHub

Showing 579 of 579 total issues

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

    protected function extractImportsFromFields(array $fields)
    {
        $imports = [];

        foreach ($fields as $field) {
Severity: Minor
Found in src/Generator/PhpGenerator.php - About 1 hr to fix

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

        public function fromFile($file)
        {
            if (!array_key_exists($file, $this->files)) {
                $xmlData = $this->getXmlData($file);
    
    
    Severity: Minor
    Found in src/SchemaParser.php - About 1 hr to fix

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

                                      foreach ((array)$fb->$method() as $schema) {
                                          $eb[(string)$schema] = [$this->getClassName($schema)];
      
                                          if ($extends = $schema->getExtends()) {
                                              do {
      Severity: Major
      Found in src/Validator/SchemaInheritanceFields.php and 1 other location - About 1 hr to fix
      src/Validator/SchemaInheritanceFields.php on lines 59..69

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

      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

                                      foreach ((array)$fa->$method() as $schema) {
                                          $ea[(string)$schema] = [$this->getClassName($schema)];
      
                                          if ($extends = $schema->getExtends()) {
                                              do {
      Severity: Major
      Found in src/Validator/SchemaInheritanceFields.php and 1 other location - About 1 hr to fix
      src/Validator/SchemaInheritanceFields.php on lines 72..82

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

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

          public static function writePbjSchemaStoresFile(PackageEvent $event)
          {
              if (!$event->isDevMode()) {
                  return;
              }
      Severity: Minor
      Found in src/Composer/ScriptHandler.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

      Function execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function execute(InputInterface $input, OutputInterface $output)
          {
              $io = new SymfonyStyle($input, $output);
      
              $file = $input->getOption('config') ?: sprintf('%s/pbjc.yml', getcwd());
      Severity: Minor
      Found in src/Command/CompileCommand.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 writePbjSchemaStoresFile has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function writePbjSchemaStoresFile(PackageEvent $event)
          {
              if (!$event->isDevMode()) {
                  return;
              }
      Severity: Minor
      Found in src/Composer/ScriptHandler.php - About 1 hr to fix

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

            private function getXmlData($file)
            {
                /** @var \DOMDocument $xmlDomDocument */
                if (!$xmlDomDocument = XmlUtils::loadFile($file, __DIR__ . '/../xsd/schema.xsd')) {
                    throw new \RuntimeException(sprintf(
        Severity: Minor
        Found in src/SchemaParser.php - About 1 hr to fix

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

                  if (isset(self::$schemasByCurie[$curie])) {
                      /** @var SchemaDescriptor $tmpSchema */
                      $tmpSchema = self::$schemasByCurie[$curie];
          
                      if ($schemaId->getVersion()->compare($tmpSchema->getId()->getVersion()) === 1) {
          Severity: Major
          Found in src/SchemaStore.php and 1 other location - About 1 hr to fix
          src/SchemaStore.php on lines 84..93

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

          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

                  if (isset(self::$schemasByCurieMajor[$curieMajor])) {
                      /** @var SchemaDescriptor $tmpSchema */
                      $tmpSchema = self::$schemasByCurieMajor[$curieMajor];
          
                      if ($schemaId->getVersion()->compare($tmpSchema->getId()->getVersion()) === 1) {
          Severity: Major
          Found in src/SchemaStore.php and 1 other location - About 1 hr to fix
          src/SchemaStore.php on lines 72..81

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

          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

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

              public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
              {
                  $fa = array_merge($a->getInheritedFields(), $a->getFields());
                  $fb = array_merge($b->getInheritedFields(), $b->getFields());
          
          
          Severity: Minor
          Found in src/Validator/FieldMustContainsAnyOfClasses.php - About 1 hr to fix

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

                public static function phpize($value)
                {
                    $value = (string)$value;
                    $lowercaseValue = strtolower($value);
            
            
            Severity: Minor
            Found in src/Util/XmlUtils.php - About 1 hr to fix

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

                  public function testGenerateEnum()
                  {
                      $enum = new EnumDescriptor('gdbots:tests:some-enum', 'int', ['K1' => 1, 'K2' => 2, 'K3' => 3]);
                      $expected = <<<OUTPUT
              import Enum from '@gdbots/common/Enum';
              Severity: Minor
              Found in tests/Generator/JsGeneratorTest.php - About 1 hr to fix

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

                    public function __construct($id, array $parameters = [])
                    {
                        $this->id = $id instanceof SchemaId ? $id : SchemaId::fromString($id);
                
                        foreach ($parameters as $key => $value) {
                Severity: Minor
                Found in src/SchemaDescriptor.php - About 1 hr to fix

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

                      public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
                      {
                          $fa = array_merge($a->getInheritedFields(), $a->getFields());
                          $fb = array_merge($b->getInheritedFields(), $b->getFields());
                  
                  
                  Severity: Minor
                  Found in src/Validator/FieldMaxLength.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

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

                      public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
                      {
                          $fa = array_merge($a->getInheritedFields(), $a->getFields());
                          $fb = array_merge($b->getInheritedFields(), $b->getFields());
                  
                  
                  Severity: Minor
                  Found in src/Validator/FieldGreaterOrEqualThan.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

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

                      public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
                      {
                          $fa = array_merge($a->getInheritedFields(), $a->getFields());
                          $fb = array_merge($b->getInheritedFields(), $b->getFields());
                  
                  
                  Severity: Minor
                  Found in src/Validator/FieldLessOrEqualThan.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

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

                      public function validate(SchemaDescriptor $a, SchemaDescriptor $b)
                      {
                          $fa = array_merge($a->getInheritedFields(), $a->getFields());
                          $fb = array_merge($b->getInheritedFields(), $b->getFields());
                  
                  
                  Severity: Minor
                  Found in src/Validator/FieldMinLength.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

                  Function extractImportsFromFields has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function extractImportsFromFields(array $fields)
                      {
                          $imports = [];
                  
                          foreach ($fields as $field) {
                  Severity: Minor
                  Found in src/Generator/PhpGenerator.php - About 55 mins 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

                  Function getPreviousSchema has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function getPreviousSchema(SchemaId $schemaId)
                      {
                          $id = $schemaId->toString();
                  
                          if (isset(self::$schemas[$id])) {
                  Severity: Minor
                  Found in src/SchemaStore.php - About 55 mins 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

                  Severity
                  Category
                  Status
                  Source
                  Language