gdbots/pbjc-php

View on GitHub

Showing 579 of 579 total issues

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

CASE statements must be defined using a colon
Open

                case TypeName::STRING_ENUM;

CASE statements must be defined using a colon
Open

                case TypeName::INT_ENUM;

CASE statements must be defined using a colon
Open

                case TypeName::INT_ENUM;

CASE statements must be defined using a colon
Open

                case TypeName::STRING_ENUM;

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

CASE statements must be defined using a colon
Open

                case TypeName::MESSAGE;

Missing class import via use statement (line '58', column '27').
Open

                throw new \RuntimeException(sprintf(
Severity: Minor
Found in src/SchemaValidator.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid too many return statements within this method.
Open

                return '0x' === $value[0] . $value[1] ? hexdec($value) : (float)$value;
Severity: Major
Found in src/Util/XmlUtils.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

                    return hexdec($value);
    Severity: Major
    Found in src/Util/XmlUtils.php - About 30 mins to fix

      The method validate() contains an eval expression.
      Open

                                                      eval(sprintf('class %s extends %s {};', $class, array_values($classes)[$i - 1]));

      EvalExpression

      Since: 0.2

      An eval-expression is untestable, a security risk and bad practice. Therefore it should be avoided. Consider to replace the eval-expression with regular code.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  eval('$param = 23;');
              }
          }
      }

      Source https://phpmd.org/rules/design.html#evalexpression

      Missing class import via use statement (line '47', column '23').
      Open

                  throw new \InvalidArgumentException(implode("\n", static::getXmlErrors($internalErrors)));
      Severity: Minor
      Found in src/Util/XmlUtils.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Missing class import via use statement (line '35', column '23').
      Open

                  throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
      Severity: Minor
      Found in src/Util/XmlUtils.php by phpmd

      MissingImport

      Since: 2.7.0

      Importing all external classes in a file through use statements makes them clearly visible.

      Example

      function make() {
          return new \stdClass();
      }

      Source http://phpmd.org/rules/cleancode.html#MissingImport

      Avoid too many return statements within this method.
      Open

                      return (float)$value;
      Severity: Major
      Found in src/Util/XmlUtils.php - About 30 mins to fix

        Missing class import via use statement (line '86', column '27').
        Open

                        throw new \InvalidArgumentException(implode("\n", $messages), 0, $e);
        Severity: Minor
        Found in src/Util/XmlUtils.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '27', column '24').
        Open

                    $ref = new \ReflectionClass(new FieldDescriptor('reflection', ['type' => 'string']));

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        The method validate() contains an eval expression.
        Open

                                                        eval(sprintf('class %s {};', $class));

        EvalExpression

        Since: 0.2

        An eval-expression is untestable, a security risk and bad practice. Therefore it should be avoided. Consider to replace the eval-expression with regular code.

        Example

        class Foo {
            public function bar($param)  {
                if ($param === 42) {
                    eval('$param = 23;');
                }
            }
        }

        Source https://phpmd.org/rules/design.html#evalexpression

        Missing class import via use statement (line '57', column '27').
        Open

                        throw new \InvalidArgumentException('Document types are not allowed.');
        Severity: Minor
        Found in src/Util/XmlUtils.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Avoid too many return statements within this method.
        Open

                        return $value;
        Severity: Major
        Found in src/Util/XmlUtils.php - About 30 mins to fix

          Remove error control operator '@' on line 74.
          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 by phpmd

          ErrorControlOperator

          Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

          Example

          function foo($filePath) {
              $file = @fopen($filPath); // hides exceptions
              $key = @$array[$notExistingKey]; // assigns null to $key
          }

          Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

          Severity
          Category
          Status
          Source
          Language