avalanche-development/swagger-router-middleware

View on GitHub

Showing 18 of 18 total issues

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

class Router implements LoggerAwareInterface
{

    use LoggerAwareTrait;

Severity: Minor
Found in src/Router.php by phpmd

Method __invoke has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __invoke(Request $request, Response $response, callable $next)
    {
        $this->log('start');

        if ($this->isDocumentationRoute($request)) {
Severity: Minor
Found in src/Router.php - About 1 hr to fix

    Function parseQueryString has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function parseQueryString(Request $request)
        {
            $params = [];
            $queryString = $request->getUri()->getQuery();
            $setList = explode('&', $queryString);
    Severity: Minor
    Found in src/Parser/Query.php - About 1 hr 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 __invoke has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public function __invoke(Request $request, Response $response, callable $next)
        {
            $this->log('start');
    
            if ($this->isDocumentationRoute($request)) {
    Severity: Minor
    Found in src/Router.php - About 1 hr 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 getSecurity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getSecurity(array $operation)
        {
            $securityRequirement = [];
    
            if (isset($operation['security'])) {
    Severity: Minor
    Found in src/Router.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 getParser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getParser(Request $request, array $parameter, $route)
        {
            switch ($parameter['in']) {
                case 'query':
                    $parser = new Parser\Query($request, $parameter);
    Severity: Minor
    Found in src/ParameterParser.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 resolveRefs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function resolveRefs(array $chunk)
        {
            $resolvedChunk = [];
            foreach ($chunk as $key => $value) {
                if ($key === '$ref') {
    Severity: Minor
    Found in src/Router.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 getValue has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getValue()
        {
            if ($this->parameter['type'] === 'file') {
                $files = $this->request->getUploadedFiles();
                if (!array_key_exists($this->parameter['name'], $files)) {
    Severity: Minor
    Found in src/Parser/Form.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 getDelimiter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getDelimiter(array $parameter)
        {
            $collectionFormat = 'csv';
            if (isset($parameter['collectionFormat'])) {
                $collectionFormat = $parameter['collectionFormat'];
    Severity: Minor
    Found in src/Parser/ExplodeTrait.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

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

                    throw new \Exception('reference not found in swagger');
    Severity: Minor
    Found in src/Router.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 '261', column '23').
    Open

                throw new \Exception('No security schemes defined');
    Severity: Minor
    Found in src/Router.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 '54', column '27').
    Open

                    throw new \Exception('Invalid swagger - could not decode');
    Severity: Minor
    Found in src/Router.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 (array) $value;
    Severity: Major
    Found in src/Parser/Form.php - About 30 mins to fix

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

                      throw new \Exception('Security scheme is not defined');
      Severity: Minor
      Found in src/Router.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 $this->explodeValue($value, $this->parameter);
      Severity: Major
      Found in src/Parser/Form.php - About 30 mins to fix

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

                    throw new \Exception('invalid json reference found in swagger');
        Severity: Minor
        Found in src/Router.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

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

            protected function getParameters(array $pathItem, array $operation)
            {
                $uniqueParameters = [];
                if (array_key_exists('parameters', $pathItem)) {
                    foreach ($pathItem['parameters'] as $parameter) {
        Severity: Minor
        Found in src/Router.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

        Avoid unused parameters such as '$request'.
        Open

            protected function encodeResponse(Request $request, Response $response)
        Severity: Minor
        Found in src/Router.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

        Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

        Severity
        Category
        Status
        Source
        Language