gdbots/pbjc-php

View on GitHub

Showing 75 of 579 total issues

Method parse has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function parse(array $data)
    {
        $schemaId = SchemaId::fromString($data['id']);

        $parameters = [
Severity: Major
Found in src/SchemaParser.php - About 2 hrs to fix

    Function fromFile has a Cognitive Complexity of 16 (exceeds 5 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 2 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

    Method getFieldDescriptor has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function getFieldDescriptor(SchemaId $schemaId, array $field)
        {
            // force default type to be "string"
            if (!isset($field['type'])) {
                $field['type'] = 'string';
    Severity: Minor
    Found in src/SchemaParser.php - About 2 hrs to fix

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

          public static function loadFile($file, $schemaOrCallable = null)
          {
              $content = @file_get_contents($file);
              if ('' === trim($content)) {
                  throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
      Severity: Minor
      Found in src/Util/XmlUtils.php - About 1 hr to fix

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

            protected function generateMessage(SchemaDescriptor $schema, GeneratorResponse $response)
            {
                $className = $this->schemaToClassName($schema, true);
                $psr = $this->schemaToNativeNamespace($schema);
                $file = str_replace('\\', '/', "{$psr}\\{$className}");
        Severity: Minor
        Found in src/Generator/PhpGenerator.php - About 1 hr to fix

          Method generateMessage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function generateMessage(SchemaDescriptor $schema, GeneratorResponse $response)
              {
                  $id = $schema->getId();
                  $className = $this->schemaToClassName($schema, true);
                  $file = "{$id->getVendor()}/{$id->getPackage()}";
          Severity: Minor
          Found in src/Generator/JsGenerator.php - About 1 hr to fix

            Method getSchemas has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function getSchemas()
                {
                    return [
                        [
                            'data' => __DIR__ . '/Fixtures/json-schema/article.json',
            Severity: Minor
            Found in tests/JsonValidatorTest.php - About 1 hr to fix

              Method convertDomElementToArray has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public static function convertDomElementToArray(\DomElement $element, $checkPrefix = true)
                  {
                      $prefix = (string)$element->prefix;
                      $empty = true;
                      $config = [];
              Severity: Minor
              Found in src/Util/XmlUtils.php - About 1 hr to fix

                Method execute has 41 lines of code (exceeds 25 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

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

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

                    Function getFieldDescriptor has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getFieldDescriptor(SchemaId $schemaId, array $field)
                        {
                            // force default type to be "string"
                            if (!isset($field['type'])) {
                                $field['type'] = 'string';
                    Severity: Minor
                    Found in src/SchemaParser.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 __construct has a Cognitive Complexity of 13 (exceeds 5 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

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

                        public function run($language, CompileOptions $options)
                        {
                            $namespaces = $options->getNamespaces();
                    
                            if (!$namespaces || count($namespaces) === 0) {
                    Severity: Minor
                    Found in src/Compiler.php - About 1 hr to fix

                      Method setUp has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function setUp()
                          {
                              SchemaStore::addSchema(
                                  SchemaId::fromString('pbj:vendor2:package2:category2:message2:1-0-0'),
                                  new SchemaDescriptor(
                      Severity: Minor
                      Found in tests/SchemaDescriptorTest.php - About 1 hr to fix

                        Method validate has 36 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/FieldAttributeEqualTo.php - About 1 hr to fix

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

                              protected function render($template, array $parameters)
                              {
                                  return str_replace(
                                      [
                                          '    ',
                          Severity: Minor
                          Found in src/Generator/JsonSchemaGenerator.php - About 1 hr to fix

                            Function fromFile has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function fromFile($file)
                                {
                                    /** @var \DOMDocument $xmlDomDocument */
                                    if (!$xmlDomDocument = XmlUtils::loadFile($file, __DIR__ . '/../xsd/enums.xsd')) {
                                        throw new \RuntimeException(sprintf(
                            Severity: Minor
                            Found in src/EnumParser.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 updateFieldOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function updateFieldOptions(SchemaDescriptor $schema, FieldDescriptor $field)
                                {
                                    if ($enum = $field->getEnum()) {
                                        if (null === $field->getLanguage(static::LANGUAGE)->get('default', null)) {
                                            $default = $field->getDefault();
                            Severity: Minor
                            Found in src/Generator/PhpGenerator.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 updateFieldOptions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function updateFieldOptions(SchemaDescriptor $schema, FieldDescriptor $field)
                                {
                                    if ($enum = $field->getEnum()) {
                                        if (null === $field->getLanguage(static::LANGUAGE)->get('default', null)) {
                                            $default = $field->getDefault();
                            Severity: Minor
                            Found in src/Generator/JsGenerator.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 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
                              Severity
                              Category
                              Status
                              Source
                              Language