swaggest/php-code-builder

View on GitHub

Showing 65 of 65 total issues

Method processArray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function processArray()
    {
        $schema = $this->schema;

        if (is_bool($schema->additionalItems)) {
Severity: Minor
Found in src/JsonSchema/SchemaBuilder.php - About 1 hr to fix

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

            if (!empty($schema->properties) || $this->hasConstraints($schema)) {
                if ($this->processed->contains($schema)) {
                    $or [] = $this->processed->offsetGet($schema);
                    $namedTypeAdded = true;
                } else {
    Severity: Major
    Found in src/Markdown/TypeBuilder.php and 1 other location - About 1 hr to fix
    src/JSDoc/TypeBuilder.php on lines 138..152

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

    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 (!empty($schema->properties)) {
                    if ($this->processed->contains($schema)) {
                        $or [] = $this->processed->offsetGet($schema);
                        $typeAdded = true;
                    } else {
    Severity: Major
    Found in src/JSDoc/TypeBuilder.php and 1 other location - About 1 hr to fix
    src/Markdown/TypeBuilder.php on lines 198..211

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

    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

    Consider simplifying this complex logical expression.
    Open

                    if ($name === $names->items
                        || $name === $names->additionalProperties
                        || $name === $names->additionalItems
                        || $name === $names->not
                        || $name === $names->if
    Severity: Major
    Found in src/JsonSchema/SchemaExporterInterface.php - About 1 hr to fix

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

          private function typeName(Schema $schema, $path, $raw = false)
          {
              if ($fromRefs = $schema->getFromRefs()) {
                  $path = $fromRefs[count($fromRefs) - 1];
              }
      Severity: Minor
      Found in src/Markdown/TypeBuilder.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 processLogicType has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          private function processLogicType()
          {
              if ($this->schema->allOf !== null) {
                  foreach ($this->schema->allOf as $i => $item) {
                      $this->result->add($this->phpBuilder->getType($item, $this->path . '->allOf[' . $i . ']'));
      Severity: Minor
      Found in src/JsonSchema/TypeBuilder.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

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

              if ($type === null) {
                  $type = [];
      
                  if (!empty($schema->properties) || !empty($schema->additionalProperties) || !empty($schema->patternProperties)) {
                      $type[] = Schema::OBJECT;
      Severity: Minor
      Found in src/JSDoc/TypeBuilder.php and 1 other location - About 45 mins to fix
      src/Markdown/TypeBuilder.php on lines 122..132

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

      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

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

              if ($type === null) {
                  $type = [];
      
                  if (!empty($schema->properties) || !empty($schema->additionalProperties) || !empty($schema->patternProperties)) {
                      $type[] = Schema::OBJECT;
      Severity: Minor
      Found in src/Markdown/TypeBuilder.php and 1 other location - About 45 mins to fix
      src/JSDoc/TypeBuilder.php on lines 61..71

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

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

          public function prepend($name, $value = '', $id = null)
          {
              $tags = array();
              if ($id) {
                  $tags[$id] = new PhpDocTag($name, $value);
      Severity: Minor
      Found in src/PhpDoc.php - About 45 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

      Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function __construct($schema, $varName, $path, PhpBuilder $phpBuilder, $createVarName = true)
      Severity: Minor
      Found in src/JsonSchema/SchemaBuilder.php - About 35 mins to fix

        Function renderProperties has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function renderProperties()
            {
                $result = '';
                foreach ($this->properties as $property) {
                    if ($property->isMagical()) {
        Severity: Minor
        Found in src/PhpClass.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

        Function processArrayType has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function processArrayType()
            {
                $schema = $this->schema;
        
                /** @var string $pathItems */
        Severity: Minor
        Found in src/JsonSchema/TypeBuilder.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

        Function makePhpConstantName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function makePhpConstantName($rawName)
            {
                $phpName = preg_replace("/([^a-zA-Z0-9_]+)/", "_", $rawName);
                if (is_string($phpName)) {
                    $phpName = trim($phpName, '_');
        Severity: Minor
        Found in src/PhpCode.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

        Avoid too many return statements within this method.
        Open

                                return false;
        Severity: Major
        Found in src/JsonSchema/PhpBuilder.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return PhpStdType::null();
          Severity: Major
          Found in src/JsonSchema/TypeBuilder.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $res;
            Severity: Major
            Found in src/Markdown/TypeBuilder.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return false;
              Severity: Major
              Found in src/JsonSchema/PhpBuilder.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return true;
                Severity: Major
                Found in src/JsonSchema/PhpBuilder.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return PhpStdType::arr();
                  Severity: Major
                  Found in src/JsonSchema/TypeBuilder.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return null;
                    Severity: Major
                    Found in src/JsonSchema/TypeBuilder.php - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language