njuhel/php-swagger-to-md

View on GitHub

Showing 181 of 181 total issues

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

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/SwaggerValidator/DataType/TypeInteger.php and 1 other location - About 1 day to fix
src/SwaggerValidator/DataType/TypeNumber.php on lines 1..60

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

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

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/SwaggerValidator/DataType/TypeNumber.php and 1 other location - About 1 day to fix
src/SwaggerValidator/DataType/TypeInteger.php on lines 1..60

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

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 3 locations. Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/SwaggerValidator/Object/Contact.php and 2 other locations - About 1 day to fix
src/SwaggerValidator/Object/Info.php on lines 1..58
src/SwaggerValidator/Object/License.php on lines 1..58

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

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 3 locations. Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/SwaggerValidator/Object/License.php and 2 other locations - About 1 day to fix
src/SwaggerValidator/Object/Contact.php on lines 1..58
src/SwaggerValidator/Object/Info.php on lines 1..58

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

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 3 locations. Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL <swaggervalidator@nabbar.com>.
 *
Severity: Major
Found in src/SwaggerValidator/Object/Info.php and 2 other locations - About 1 day to fix
src/SwaggerValidator/Object/Contact.php on lines 1..58
src/SwaggerValidator/Object/License.php on lines 1..58

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

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

    public function markdown(\SwaggerValidator\Common\Context $context)
    {
        $method       = __FUNCTION__;
        $templateVars = array(
            'partType' => \Swagger2md\Swagger2md::getInstance()->renderTemplate('PartTypeFormat', array('type' => \SwaggerValidator\Common\FactorySwagger::TYPE_OBJECT)),
Severity: Minor
Found in src/SwaggerValidator/DataType/TypeObject.php - About 5 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 Swagger2md.php has 363 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/*
 * Copyright 2016 Nicolas JUHEL<swaggervalidator@nabbar.com>.
 *
Severity: Minor
Found in src/Swagger2md.php - About 4 hrs to fix

    Method loadSwaggerFile has 95 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function loadSwaggerFile($swaggerFile = null)
        {
            $params = getopt('h::v', array(
                'templates::',
                'tempDir::',
    Severity: Major
    Found in src/Swagger2md.php - About 3 hrs to fix

      Function markdown has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public function markdown(\SwaggerValidator\Common\Context $context)
          {
              $method       = __FUNCTION__;
              $keyTags      = \SwaggerValidator\Common\FactorySwagger::KEY_TAGS;
              $generalItems = $this->getMethodGeneric($context, $method);
      Severity: Minor
      Found in src/SwaggerValidator/Object/Swagger.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 markdown has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function markdown(\SwaggerValidator\Common\Context $context)
          {
              $method       = __FUNCTION__;
              $templateVars = array(
                  'items' => array(),
      Severity: Minor
      Found in src/SwaggerValidator/DataType/TypeArrayItems.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 makeRequestExample has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function makeRequestExample(\SwaggerValidator\Common\Context $context, $operation)
          {
              $keyParameters = \SwaggerValidator\Common\FactorySwagger::KEY_PARAMETERS;
              $keyResponses  = \SwaggerValidator\Common\FactorySwagger::KEY_RESPONSES;
              $keyConsumes   = \SwaggerValidator\Common\FactorySwagger::KEY_CONSUMES;
      Severity: Minor
      Found in src/SwaggerValidator/Object/Operation.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 markdown has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function markdown(\SwaggerValidator\Common\Context $context)
          {
              $method               = __FUNCTION__;
              $schemaKey            = \SwaggerValidator\Common\FactorySwagger::KEY_SCHEMA;
              $templateVars         = array();
      Severity: Minor
      Found in src/SwaggerValidator/Object/ParameterBody.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 loadSwaggerFile has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function loadSwaggerFile($swaggerFile = null)
          {
              $params = getopt('h::v', array(
                  'templates::',
                  'tempDir::',
      Severity: Minor
      Found in src/Swagger2md.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

      The class Swagger2md has 17 public methods. Consider refactoring Swagger2md to keep number of public methods under 10.
      Open

      class Swagger2md
      {
      
          const version = '1.0.0';
      
      
      Severity: Minor
      Found in src/Swagger2md.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 Swagger2md has an overall complexity of 87 which is very high. The configured complexity threshold is 50.
      Open

      class Swagger2md
      {
      
          const version = '1.0.0';
      
      
      Severity: Minor
      Found in src/Swagger2md.php by phpmd

      Method makeRequestExample has 71 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function makeRequestExample(\SwaggerValidator\Common\Context $context, $operation)
          {
              $keyParameters = \SwaggerValidator\Common\FactorySwagger::KEY_PARAMETERS;
              $keyResponses  = \SwaggerValidator\Common\FactorySwagger::KEY_RESPONSES;
              $keyConsumes   = \SwaggerValidator\Common\FactorySwagger::KEY_CONSUMES;
      Severity: Major
      Found in src/SwaggerValidator/Object/Operation.php - About 2 hrs to fix

        Method markdown has 69 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function markdown(\SwaggerValidator\Common\Context $context)
            {
                $method       = __FUNCTION__;
                $templateVars = array(
                    'partType' => \Swagger2md\Swagger2md::getInstance()->renderTemplate('PartTypeFormat', array('type' => \SwaggerValidator\Common\FactorySwagger::TYPE_OBJECT)),
        Severity: Major
        Found in src/SwaggerValidator/DataType/TypeObject.php - About 2 hrs to fix

          Method renderTable has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function renderTable($name, $anchor, $listKey, $colonsFile, $template, $vars, $store = null)
              {
                  if ($store !== false) {
                      $file = $this->checkAndMakeObjectFolder();
                  }
          Severity: Major
          Found in src/Swagger2md.php - About 2 hrs to fix

            Function getTags has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getTags(\SwaggerValidator\Common\Context $context, $tags)
                {
                    $method  = __FUNCTION__;
                    $keyTags = \SwaggerValidator\Common\FactorySwagger::KEY_TAGS;
                    $curPath = $context->getRoutePath();
            Severity: Minor
            Found in src/SwaggerValidator/Object/PathItem.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

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

                protected function getResourceForKey($key)
                {
                    $resources = explode('/', trim($key, '/'));
            
                    if (count($resources) < 2) {
            Severity: Major
            Found in src/SwaggerValidator/Object/Paths.php and 1 other location - About 2 hrs to fix
            src/SwaggerValidator/Object/PathItem.php on lines 153..171

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

            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

            Severity
            Category
            Status
            Source
            Language