gdbots/pbjc-php

View on GitHub

Showing 579 of 579 total issues

FieldDescriptor has 30 functions (exceeds 20 allowed). Consider refactoring.
Open

final class FieldDescriptor
{
    /**
     * Regular expression pattern for matching a valid field name.  The pattern allows
     * for camelCase fields name but snake_case is recommend.
Severity: Minor
Found in src/FieldDescriptor.php - About 3 hrs to fix

    The class FieldDescriptorTest has 24 public methods. Consider refactoring FieldDescriptorTest to keep number of public methods under 10.
    Open

    class FieldDescriptorTest extends \PHPUnit_Framework_TestCase
    {
        /** FieldDescriptor */
        protected $field;
    
    
    Severity: Minor
    Found in tests/FieldDescriptorTest.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    The class XmlUtils has an overall complexity of 52 which is very high. The configured complexity threshold is 50.
    Open

    class XmlUtils
    {
        /**
         * This class should not be instantiated.
         */
    Severity: Minor
    Found in src/Util/XmlUtils.php by phpmd

    The class FieldDescriptor has an overall complexity of 73 which is very high. The configured complexity threshold is 50.
    Open

    final class FieldDescriptor
    {
        /**
         * Regular expression pattern for matching a valid field name.  The pattern allows
         * for camelCase fields name but snake_case is recommend.
    Severity: Minor
    Found in src/FieldDescriptor.php by phpmd

    The class Generator has 12 public methods. Consider refactoring Generator to keep number of public methods under 10.
    Open

    abstract class Generator
    {
        const TEMPLATE_DIR = __DIR__ . '/Twig/';
        const LANGUAGE = 'unknown';
        const EXTENSION = '.unk';
    Severity: Minor
    Found in src/Generator/Generator.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    The class Generator has an overall complexity of 50 which is very high. The configured complexity threshold is 50.
    Open

    abstract class Generator
    {
        const TEMPLATE_DIR = __DIR__ . '/Twig/';
        const LANGUAGE = 'unknown';
        const EXTENSION = '.unk';
    Severity: Minor
    Found in src/Generator/Generator.php by phpmd

    The class SchemaParser has an overall complexity of 63 which is very high. The configured complexity threshold is 50.
    Open

    class SchemaParser
    {
        /** @var array */
        protected $files = [];
    
    
    Severity: Minor
    Found in src/SchemaParser.php by phpmd

    Method generateManifest has 83 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function generateManifest(array $schemas)
        {
            $response = new GeneratorResponse();
            $manifests = ['all' => []];
    
    
    Severity: Major
    Found in src/Generator/Generator.php - About 3 hrs to fix

      Function validate has a Cognitive Complexity of 23 (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/FieldAttributeEqualTo.php - About 3 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

      Function __construct has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function __construct($name, array $parameters)
          {
              if (!$name || strlen($name) > 127 || preg_match(self::VALID_NAME_PATTERN, $name) === false) {
                  throw new \InvalidArgumentException(
                      sprintf(
      Severity: Minor
      Found in src/FieldDescriptor.php - About 3 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

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

      class FieldDescriptorTest extends \PHPUnit_Framework_TestCase
      {
          /** FieldDescriptor */
          protected $field;
      
      
      Severity: Minor
      Found in tests/FieldDescriptorTest.php - About 2 hrs to fix

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

        abstract class Generator
        {
            const TEMPLATE_DIR = __DIR__ . '/Twig/';
            const LANGUAGE = 'unknown';
            const EXTENSION = '.unk';
        Severity: Minor
        Found in src/Generator/Generator.php - About 2 hrs to fix

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

              public function __construct()
              {
                  $enums = [];
                  $schemas = [];
          
          
          Severity: Major
          Found in src/Compiler.php - About 2 hrs to fix

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

            Function loadFile has a Cognitive Complexity of 19 (exceeds 5 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 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 __construct has 63 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function __construct($name, array $parameters)
                {
                    if (!$name || strlen($name) > 127 || preg_match(self::VALID_NAME_PATTERN, $name) === false) {
                        throw new \InvalidArgumentException(
                            sprintf(
            Severity: Major
            Found in src/FieldDescriptor.php - About 2 hrs to fix

              Function validate has a Cognitive Complexity of 17 (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/FieldMustContainsAnyOfClasses.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

              File FieldDescriptor.php has 258 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              
              namespace Gdbots\Pbjc;
              
              use Gdbots\Common\Util\NumberUtils;
              Severity: Minor
              Found in src/FieldDescriptor.php - About 2 hrs to fix

                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

                  Severity
                  Category
                  Status
                  Source
                  Language