njuhel/php-swagger-to-md

View on GitHub
src/Swagger2md.php

Summary

Maintainability
D
2 days
Test Coverage

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

        Swagger2md has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Swagger2md
        {
        
            const version = '1.0.0';
        
        
        Severity: Minor
        Found in src/Swagger2md.php - About 2 hrs to fix

          Method renderTable has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function renderTable($name, $anchor, $listKey, $colonsFile, $template, $vars, $store = null)
          Severity: Major
          Found in src/Swagger2md.php - About 50 mins to fix

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

                public function checkTemplates($path = null)
                {
                    if (defined('PHAR_SWG2MD_ROOT_PATH')) {
                        $baseDir = PHAR_SWG2MD_ROOT_PATH;
                    }
            Severity: Minor
            Found in src/Swagger2md.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 renderTable has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function renderTable($name, $anchor, $listKey, $colonsFile, $template, $vars, $store = null)
                {
                    if ($store !== false) {
                        $file = $this->checkAndMakeObjectFolder();
                    }
            Severity: Minor
            Found in src/Swagger2md.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;
            Severity: Major
            Found in src/Swagger2md.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return $this->twigTpl->render($template, $vars);
              Severity: Major
              Found in src/Swagger2md.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $val;
                Severity: Major
                Found in src/Swagger2md.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return $val;
                  Severity: Major
                  Found in src/Swagger2md.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return $this->tempFolder . DIRECTORY_SEPARATOR;
                    Severity: Major
                    Found in src/Swagger2md.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                  return $val['enabled'];
                      Severity: Major
                      Found in src/Swagger2md.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return array_filter($colParamsTitle);
                        Severity: Major
                        Found in src/Swagger2md.php - About 30 mins to fix

                          Function extractStored has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function extractStored()
                              {
                                  $result = array();
                                  foreach ($this->suffixObject as $obj) {
                                      if (is_array($obj) && array_key_exists('file', $obj) && !empty($obj['file'])) {
                          Severity: Minor
                          Found in src/Swagger2md.php - About 25 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

                          The method loadSwaggerFile() has 110 lines of code. Current threshold is set to 100. Avoid really long methods.
                          Open

                              public function loadSwaggerFile($swaggerFile = null)
                              {
                                  $params = getopt('h::v', array(
                                      'templates::',
                                      'tempDir::',
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          The method renderTable() has an NPath complexity of 18432. The configured NPath complexity threshold is 200.
                          Open

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

                          NPathComplexity

                          Since: 0.1

                          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                          Example

                          class Foo {
                              function bar() {
                                  // lots of complicated code
                              }
                          }

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

                          The method loadSwaggerFile() has an NPath complexity of 51840. The configured NPath complexity threshold is 200.
                          Open

                              public function loadSwaggerFile($swaggerFile = null)
                              {
                                  $params = getopt('h::v', array(
                                      'templates::',
                                      'tempDir::',
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          NPathComplexity

                          Since: 0.1

                          The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                          Example

                          class Foo {
                              function bar() {
                                  // lots of complicated code
                              }
                          }

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

                          The method loadSwaggerFile() has a Cyclomatic Complexity of 22. The configured cyclomatic complexity threshold is 10.
                          Open

                              public function loadSwaggerFile($swaggerFile = null)
                              {
                                  $params = getopt('h::v', array(
                                      'templates::',
                                      'tempDir::',
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          CyclomaticComplexity

                          Since: 0.1

                          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                          Example

                          // Cyclomatic Complexity = 11
                          class Foo {
                          1   public function example() {
                          2       if ($a == $b) {
                          3           if ($a1 == $b1) {
                                          fiddle();
                          4           } elseif ($a2 == $b2) {
                                          fiddle();
                                      } else {
                                          fiddle();
                                      }
                          5       } elseif ($c == $d) {
                          6           while ($c == $d) {
                                          fiddle();
                                      }
                          7        } elseif ($e == $f) {
                          8           for ($n = 0; $n < $h; $n++) {
                                          fiddle();
                                      }
                                  } else {
                                      switch ($z) {
                          9               case 1:
                                              fiddle();
                                              break;
                          10              case 2:
                                              fiddle();
                                              break;
                          11              case 3:
                                              fiddle();
                                              break;
                                          default:
                                              fiddle();
                                              break;
                                      }
                                  }
                              }
                          }

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

                          The method renderTable() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10.
                          Open

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

                          CyclomaticComplexity

                          Since: 0.1

                          Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

                          Example

                          // Cyclomatic Complexity = 11
                          class Foo {
                          1   public function example() {
                          2       if ($a == $b) {
                          3           if ($a1 == $b1) {
                                          fiddle();
                          4           } elseif ($a2 == $b2) {
                                          fiddle();
                                      } else {
                                          fiddle();
                                      }
                          5       } elseif ($c == $d) {
                          6           while ($c == $d) {
                                          fiddle();
                                      }
                          7        } elseif ($e == $f) {
                          8           for ($n = 0; $n < $h; $n++) {
                                          fiddle();
                                      }
                                  } else {
                                      switch ($z) {
                          9               case 1:
                                              fiddle();
                                              break;
                          10              case 2:
                                              fiddle();
                                              break;
                          11              case 3:
                                              fiddle();
                                              break;
                                          default:
                                              fiddle();
                                              break;
                                      }
                                  }
                              }
                          }

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

                          Missing class import via use statement (line '229', column '71').
                          Open

                                  file_put_contents($this->output, $this->swagger->markdown(new \Swagger2md\Context()));
                          Severity: Minor
                          Found in src/Swagger2md.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 '195', column '62').
                          Open

                                  $this->swagger = \SwaggerValidator\Swagger::load(new \Swagger2md\Context());
                          Severity: Minor
                          Found in src/Swagger2md.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 '170', column '34').
                          Open

                                      $this->twigTpl = new \Twig_Environment(new \Twig_Loader_Filesystem($this->templateFolder), array(
                          Severity: Minor
                          Found in src/Swagger2md.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 '161', column '34').
                          Open

                                      $this->twigTpl = new \Twig_Environment(new \Twig_Loader_Filesystem($this->templateFolder), array(
                          Severity: Minor
                          Found in src/Swagger2md.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 '161', column '56').
                          Open

                                      $this->twigTpl = new \Twig_Environment(new \Twig_Loader_Filesystem($this->templateFolder), array(
                          Severity: Minor
                          Found in src/Swagger2md.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 '170', column '56').
                          Open

                                      $this->twigTpl = new \Twig_Environment(new \Twig_Loader_Filesystem($this->templateFolder), array(
                          Severity: Minor
                          Found in src/Swagger2md.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

                          The method loadSwaggerFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      self::$verboseLevel = 0;
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          Avoid using static access to class '\Phar' in method 'checkTemplates'.
                          Open

                                  if (\Phar::running()) {
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          The method checkTemplates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      $pathReal = realpath($path);
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          Avoid using static access to class '\Swagger2md\Swagger2md' in method 'renderTable'.
                          Open

                                      \Swagger2md\Swagger2md::printOutV('Rendering this template : ' . $template);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          Avoid using static access to class '\SwaggerValidator\Swagger' in method 'loadSwaggerFile'.
                          Open

                                  \SwaggerValidator\Swagger::setSwaggerFile(getcwd() . DIRECTORY_SEPARATOR . $swaggerFile);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          Avoid using static access to class '\Swagger2md\Swagger2md' in method 'renderTable'.
                          Open

                                      \Swagger2md\Swagger2md::printOutV('Rendering this template : ' . $template);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          Avoid using static access to class '\Swagger2md\Swagger2md' in method 'renderTemplate'.
                          Open

                                  \Swagger2md\Swagger2md::printOutV('Rendering this template : ' . $template);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          The method loadSwaggerFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      $this->templateFolder = $this->checkTemplates();
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          The method loadSwaggerFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      $this->twigTpl = new \Twig_Environment(new \Twig_Loader_Filesystem($this->templateFolder), array(
                                          'cache'            => false,
                                          'debug'            => (self::$verboseLevel > 0),
                                          'strict_variables' => false,
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          The method renderTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      \Swagger2md\Swagger2md::printOutV('Rendering this template : ' . $template);
                                      return $this->twigTpl->render($template, $vars);
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          Avoid using static access to class '\SwaggerValidator\Swagger' in method 'loadSwaggerFile'.
                          Open

                                  $this->swagger = \SwaggerValidator\Swagger::load(new \Swagger2md\Context());
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          Avoid using static access to class '\Phar' in method 'checkTemplates'.
                          Open

                                  elseif (\Phar::running()) {
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          The method loadSwaggerFile uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      $this->output = 'php://stdout';
                                      self::printOutV('The result will be print in the stdout.');
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          The method checkTemplates uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                          Open

                                  else {
                                      $baseDir = __DIR__ . DIRECTORY_SEPARATOR;
                                  }
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ElseExpression

                          Since: 1.4.0

                          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

                          Example

                          class Foo
                          {
                              public function bar($flag)
                              {
                                  if ($flag) {
                                      // one branch
                                  } else {
                                      // another branch
                                  }
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#elseexpression

                          Avoid using static access to class '\SwaggerValidator\Common\Context' in method 'loadSwaggerFile'.
                          Open

                                      \SwaggerValidator\Common\Context::setConfigDropAllDebugLog();
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          Avoid using static access to class '\Swagger2md\Swagger2md' in method 'renderTable'.
                          Open

                                      \Swagger2md\Swagger2md::printOutV('Rendering this template : ' . $template);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          StaticAccess

                          Since: 1.4.0

                          Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

                          Example

                          class Foo
                          {
                              public function bar()
                              {
                                  Bar::baz();
                              }
                          }

                          Source https://phpmd.org/rules/cleancode.html#staticaccess

                          The method exitCode() contains an exit expression.
                          Open

                                  exit($code);
                          Severity: Minor
                          Found in src/Swagger2md.php by phpmd

                          ExitExpression

                          Since: 0.2

                          An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

                          Example

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

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

                          Constant version should be defined in uppercase
                          Open

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

                          ConstantNamingConventions

                          Since: 0.2

                          Class/Interface constant names should always be defined in uppercase.

                          Example

                          class Foo {
                              const MY_NUM = 0; // ok
                              const myTest = ""; // fail
                          }

                          Source https://phpmd.org/rules/naming.html#constantnamingconventions

                          There are no issues that match your filters.

                          Category
                          Status