avalanche-development/swagger-router-middleware

View on GitHub

Showing 11 of 18 total issues

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

    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

      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

        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

        Severity
        Category
        Status
        Source
        Language